Changeset 9705 in orxonox.OLD for branches/new_class_id/src/lib/lang
- Timestamp:
- Aug 25, 2006, 9:44:53 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib/lang
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/lang/base_object.h
r9691 r9705 48 48 inline const std::string& getClassName() const { return _classes.front()._objectList->name(); } 49 49 50 inline const NewClassID& getClassID() const { return *_leafClassID; } 50 51 /** @returns the ID of the Topmost object of the ClassStack */ 51 52 inline const int& getLeafClassID() const { return _leafClassID->id(); } -
branches/new_class_id/src/lib/lang/new_object_list.cc
r9701 r9705 104 104 105 105 /** 106 * @brief searches for a NewClassID in the list of all NewObjectLists, and returns its Identity 107 * @param id: The Id to search for 108 * @returns the ClassID if found and NullClass' identity if not. 109 */ 110 const NewClassID& NewObejctListBase::retrieveIdentity(int id) 111 { 112 const NewObjectListBase* const base = NewObjectListBase::getObjectList(id); 113 114 if (base != NULL) 115 return base->_identity; 116 else 117 return NullClass::classID(); 118 } 119 120 /** 121 * @brief searches for a NewClassID in the list of all NewObjectLists, and returns its Identity 122 * @param name: The Name to search for 123 * @returns the ClassID if found and NullClass' identity if not. 124 */ 125 const NewClassID& NewObjectListBase::retrieveIdentity(const std::string& name) 126 { 127 const NewObjectListBase* const base = NewObjectListBase::getObjectList(name); 128 129 if (base != NULL) 130 return base->_identity; 131 else 132 return NullObject::classID(); 133 } 134 135 136 /** 106 137 * @brief Checks if a Class with name already exists. 107 138 * @param name The Name of the Class to check. -
branches/new_class_id/src/lib/lang/new_object_list.h
r9702 r9705 44 44 //! A fast iterator Base-Class, for iterator-casting and storing. 45 45 /** 46 * @note This Iterator is explicitely used only for storage purposes 46 * @note This Iterator is explicitely used only for storage purposes in the BaseObject 47 47 */ 48 48 class IteratorBase { }; 49 49 50 typedef std::list<BaseObject*> base_list; 51 typedef base_list::iterator base_iterator; 52 50 53 public: 54 /** @returns The Identity of the Class stored within. */ 51 55 inline const NewClassID& identity() const { return _identity; } 56 /** @returns the ID of the Identity of the ObjectList */ 52 57 inline int id() const { return _id; }; 58 /** @returns The Name of the Class stored in this ObjectList */ 53 59 inline const std::string& name() const { return _name; }; 54 bool operator==(int id) const { return _id == id; }; 55 bool operator==(const NewClassID& id) const { return id == _id; }; 56 bool operator==(const std::string& name) const { return _name == name; }; 57 58 void acquireID(const int*& id, const std::string*& name) const { id = &_id; name = &_name; }; 59 60 virtual void debug() const = 0; 60 /** @param id The id to compare @returns true on match, false otherwise */ 61 inline bool operator==(int id) const { return _id == id; }; 62 /** @param id The id to compare @returns true on match, false otherwise */ 63 inline bool operator==(const NewClassID& id) const { return id == _id; }; 64 /** @param name The name to compare @returns true on match, false otherwise */ 65 inline bool operator==(const std::string& name) const { return _name == name; }; 66 /** @param id The id to check @returns true on match, false otherwise */ 67 inline void acquireID(const int*& id, const std::string*& name) const { id = &_id; name = &_name; }; 68 /** @brief fills a list of Objects into a BaseObject*-List. @param list the list to fill */ 69 virtual void getBaseObjectList(base_list* list) const = 0; 70 71 static const NewClassID& retrieveIdentity(int id); 72 static const NewClassID& retrieveIdentity(const std::string& name); 73 74 static const NewObjectListBase* const getObjectList(int classID); 75 static const NewObjectListBase* const getObjectList(const std::string& className); 76 static const NewObjectListBase* const getObjectList(const NewClassID& classID); 77 78 static BaseObject* getBaseObject(int classID, const std::string& objectName); 79 static BaseObject* getBaseObject(const std::string& className, const std::string& objectName); 80 static BaseObject* getBaseObject(const NewClassID& classID, const std::string& objectName); 81 82 /** @returns an Object with Name name out of this List @param name the name of the Object. */ 83 virtual BaseObject* getBaseObject(const std::string& name) const = 0; 84 85 static const std::list<std::string>& getClassNames(); 61 86 62 87 static unsigned int classCount(); … … 64 89 static int StringToID(const std::string& className); 65 90 66 static const std::list<std::string>& getClassNames(); 67 91 virtual void debug() const = 0; 92 93 //! Only uset to unsubscribe a BaseObject. 68 94 virtual void unregisterObject(IteratorBase* _iterators) = 0; 69 70 public:71 typedef std::list<BaseObject*> base_list;72 typedef std::list<BaseObject*>::iterator base_iterator;73 74 virtual void getBaseObjectList(base_list* list) const = 0;75 76 static const NewObjectListBase* const getObjectList(int classID);77 static const NewObjectListBase* const getObjectList(const std::string& className);78 static const NewObjectListBase* const getObjectList(const NewClassID& classID);79 80 static BaseObject* getBaseObject(int classID, const std::string& objectName);81 static BaseObject* getBaseObject(const std::string& className, const std::string& objectName);82 static BaseObject* getBaseObject(const NewClassID& classID, const std::string& objectName);83 84 virtual BaseObject* getBaseObject(const std::string& name) const = 0;85 95 86 96 protected: … … 99 109 typedef std::map<std::string, NewObjectListBase*> classNameMap; //!< The Generic Map. 100 110 111 private: 101 112 int _id; 102 113 const std::string _name; //!< The Name of the Class. … … 146 157 T* getObject(const std::string& name) const; 147 158 inline const list& objects() const { return _objects; }; 159 bool exists(const T* const object) const; 148 160 149 161 inline iterator begin() { return _objects.begin(); }; … … 157 169 inline T* back() const { return _objects.back(); }; 158 170 171 159 172 NewObjectListBase::IteratorBase* registerObject(T* object); 160 v oid unregisterObject(IteratorBase* iterator);173 virtual void unregisterObject(IteratorBase* iterator); 161 174 162 175 virtual void debug() const; … … 233 246 234 247 /** 248 * @brief checks if Object object exists in this ClassList. 249 * @param object the Object to check for 250 * @returns True if the object is found within the List, false otherwise 251 */ 252 template <class T> 253 bool NewObjectList<T>::exists(const T* const object) const 254 { 255 return (std::find(_objects.begin(), _objects.end(), object) != _objects.end()); 256 } 257 258 259 /** 235 260 * @brief retrieves a List of BaseObjects 236 261 * @param list the list to push the ObjectList into.
Note: See TracChangeset
for help on using the changeset viewer.