Changeset 9678 in orxonox.OLD for trunk/src/lib/lang
- Timestamp:
- Aug 21, 2006, 11:59:18 PM (18 years ago)
- Location:
- trunk/src/lib/lang
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/lang/new_class_id.cc
r9674 r9678 18 18 #include "new_class_id.h" 19 19 #include <cassert> 20 #include "debug.h" 20 21 21 22 /////////////////////////////////////////////////////////// … … 45 46 46 47 48 /** 49 * @brief Seeks in the Inheritance if it matches objectList. 50 * @param objectList The ObjectList this should be a member of (by Pointer-comparison). 51 * @return True if found, false if not. 52 */ 53 bool NewClassID::isA(const NewObjectListBase& objectList) const 54 { 55 ClassList::const_iterator it; 56 for (it = this->_classes.begin(); it != this->_classes.end(); ++it) 57 if ((*it)._objectList == &objectList) 58 return true; 59 return false; 60 } 61 62 /** 63 * @brief Seeks in the Inheritance if it matches objectList. 64 * @param classID The ClassID of the class this should be a member of. 65 * @return True if found, false if not. 66 */ 67 bool NewClassID::isA(int classID) const 68 { 69 ClassList::const_iterator it; 70 for (it = this->_classes.begin(); it != this->_classes.end(); ++it) 71 if (*(*it)._objectList == classID) 72 return true; 73 return false; 74 } 75 76 /** 77 * @brief Seeks in the Inheritance if it matches objectList. 78 * @param className The ClassName of the class this should be a member of. 79 * @return True if found, false if not. 80 */ 81 bool NewClassID::isA(const std::string& className) const 82 { 83 ClassList::const_iterator it; 84 for (it = this->_classes.begin(); it != this->_classes.end(); ++it) 85 if (*(*it)._objectList == className) 86 return true; 87 return false; 88 } 89 90 91 void NewClassID::listInheritance() const 92 { 93 PRINT(0)("Listing inheritance diagram for ....: "); 94 ClassList::const_iterator it; 95 for (it = this->_classes.begin(); it != this->_classes.end(); ++it) 96 PRINT(0)(" -> %s", (*it)._objectList->name().c_str()); 97 PRINT(0)("\n"); 98 99 } -
trunk/src/lib/lang/new_class_id.h
r9673 r9678 24 24 25 25 26 int leafClassID() const { return _classes.front()._objectList->id(); } 27 26 28 template<class T> void registerObject(T* object, NewObjectList<T>& list); 27 29 bool isA(const NewObjectListBase& objectList) const; 28 bool isA(int id) const;30 bool isA(int classID) const; 29 31 bool isA(const std::string& className) const; 30 32 33 void listInheritance() const; 34 31 35 private: 32 33 36 ////////////////////////////// 34 37 //// Type Definition Part //// 35 38 ////////////////////////////// 36 39 //! A ClassEntry so we can store Classes inside of Objects 37 struct ClassEntry{ 40 struct ClassEntry 41 { 38 42 /** Simple Constuctor @param objectList the NewObjectList, @param iterator the (intrusive) Iterator inside of the ObjectList */ 39 43 inline ClassEntry (NewObjectListBase* objectList, NewObjectListBase::IteratorBase* iterator) : _objectList(objectList), _iterator(iterator) {} … … 42 46 }; 43 47 typedef std::list<ClassEntry> ClassList; //!< Type definition for the List. 48 44 49 ClassList _classes; //!< All Classes this object is part of. 45 50 }; … … 56 61 */ 57 62 template<class T> 58 63 inline void NewClassID::registerObject(T* object, NewObjectList<T>& objectList) 59 64 { 60 this->_classes.push_ back(ClassEntry(&objectList, objectList.registerObject(object)));65 this->_classes.push_front(ClassEntry(&objectList, objectList.registerObject(object))); 61 66 } 62 67 -
trunk/src/lib/lang/test_object_list.cc
r9677 r9678 12 12 // bool operator==(const std::string& name) const { return _objectName == name; }; 13 13 14 //NewObjectListDeclaration(NewBaseObject);14 NewObjectListDeclaration(NewBaseObject); 15 15 16 16 protected: 17 17 NewBaseObject(const std::string& objectName = "") : _objectName(objectName) 18 18 { 19 //this->registerObject(this, objectList);19 this->registerObject(this, objectList); 20 20 }; 21 21 template<class T> 22 22 inline void registerObject(T* object, NewObjectList<T>& objectList) { _id.registerObject(object, objectList); }; 23 pr ivate:23 protected: 24 24 NewClassID _id; 25 25 std::string _objectName; … … 27 27 28 28 }; 29 //NewObjectListDefinition(NewBaseObject);29 NewObjectListDefinition(NewBaseObject); 30 30 31 31 … … 43 43 //ObjectListDeclaration(Test); 44 44 }; 45 NewObjectListDefinitionID(Test, 0);45 NewObjectListDefinitionID(Test, -1); 46 46 47 47 Test::Test() 48 48 { 49 49 this->registerObject(this, Test::objectList); 50 51 this->_id.listInheritance(); 52 50 53 // this->setClassID(CL_PARENT_NODE, "Test"); 51 54 // std::cout << "Test()\n";
Note: See TracChangeset
for help on using the changeset viewer.