Changeset 9701 in orxonox.OLD for branches/new_class_id/src/lib
- Timestamp:
- Aug 25, 2006, 11:20:21 AM (18 years ago)
- Location:
- branches/new_class_id/src/lib/lang
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/lang/new_class_id.cc
r9698 r9701 17 17 18 18 #include "new_class_id.h" 19 19 #include "new_object_list.h" 20 20 21 21 NewClassID::NewClassID() … … 24 24 }; 25 25 26 NewClassID::NewClassID(const NewObjectListBase* objList) 27 { 28 29 objList->acquireID(_id, _name); 30 31 } 32 33 26 34 NewClassID NullClass::_classID; -
branches/new_class_id/src/lib/lang/new_class_id.h
r9698 r9701 10 10 #include <string> 11 11 12 class NewObjectListBase; 13 12 14 //! A class to dynamically allocate ClassID's and support a isA operator 13 15 class NewClassID … … 15 17 public: 16 18 NewClassID(); 17 NewClassID( int id, const std::string& name) : _id(id), _name(name) { };19 NewClassID(const NewObjectListBase* id); 18 20 // the copy constructor is also defined. 19 const int& id() const { return _id; };20 const std::string& name() const { return _name; };21 const int& id() const { return *_id; }; 22 const std::string& name() const { return *_name; }; 21 23 22 bool operator==( NewClassID id) const { return _id == id._id || _name == id._name; };23 bool operator==(int id) const { return _id == id; };24 bool operator==(const std::string& name) const { return _name == name; };25 bool operator!=( NewClassID id) const { return _id != id._id && _name != id._name;};26 bool operator!=(int id) const { return _id != id; };27 bool operator!=(const std::string& name) const { return _name != name; };24 bool operator==(const NewClassID& id) const { return *_id == *id._id /* || _name == id._name */; }; 25 bool operator==(int id) const { return *_id == id; }; 26 bool operator==(const std::string& name) const { return *_name == name; }; 27 bool operator!=(const NewClassID& id) const { return *_id != *id._id /* && _name != id._name*/; }; 28 bool operator!=(int id) const { return *_id != id; }; 29 bool operator!=(const std::string& name) const { return *_name != name; }; 28 30 29 31 private: 30 int_id;31 std::string_name;32 const int* _id; 33 const std::string* _name; 32 34 }; 33 35 -
branches/new_class_id/src/lib/lang/new_object_list.cc
r9696 r9701 27 27 */ 28 28 NewObjectListBase::NewObjectListBase(const std::string& className, int id) 29 : _name(className) 29 30 { 30 31 if (NewObjectListBase::_classesByID == NULL) … … 44 45 assert(!NewObjectListBase::classIDExists(id) && "Classes should only be included once, and no two classes should have the same ID (key value)"); 45 46 47 _id = id; 46 48 /// Some Output, that will fall out later 47 49 //std::cout << "register new ObjectList " << className << " ID: " << this->_id << std::endl; 48 50 49 this->_identity = NewClassID( id, className);51 this->_identity = NewClassID(this); 50 52 (*NewObjectListBase::_classesByID)[this->_identity.id()] = this; 51 53 (*NewObjectListBase::_classesByName)[this->_identity.name()] = this; … … 157 159 * @param objectName the Name of the Object to search for 158 160 */ 159 BaseObject* NewObjectListBase::get Object(int classID, const std::string& objectName)161 BaseObject* NewObjectListBase::getBaseObject(int classID, const std::string& objectName) 160 162 { 161 163 const NewObjectListBase* const base = NewObjectListBase::getObjectList(classID); … … 172 174 * @param objectName the Name of the Object to search for 173 175 */ 174 BaseObject* NewObjectListBase::get Object(const std::string& className, const std::string& objectName)176 BaseObject* NewObjectListBase::getBaseObject(const std::string& className, const std::string& objectName) 175 177 { 176 178 const NewObjectListBase* const base = NewObjectListBase::getObjectList(className); … … 187 189 * @param objectName the Name of the Object to search for 188 190 */ 189 BaseObject* NewObjectListBase::get Object(const NewClassID& classID, const std::string& objectName)191 BaseObject* NewObjectListBase::getBaseObject(const NewClassID& classID, const std::string& objectName) 190 192 { 191 193 const NewObjectListBase* const base = NewObjectListBase::getObjectList(classID); -
branches/new_class_id/src/lib/lang/new_object_list.h
r9698 r9701 51 51 52 52 public: 53 inline const NewClassID& identity() const { return _identity; }; 54 inline int id() const { return _identity.id(); }; 55 inline const std::string& name() const { return _identity.name(); }; 56 bool operator==(int id) const { return _identity == id; }; 57 bool operator==(const NewClassID& id) const { return _identity == id; }; 58 bool operator==(const std::string& name) const { return _identity == name; }; 53 inline const NewClassID& identity() const { return _identity; } 54 inline int id() const { return _id; }; 55 inline const std::string& name() const { return _name; }; 56 bool operator==(int id) const { return _id == id; }; 57 bool operator==(const NewClassID& id) const { return id == _id; }; 58 bool operator==(const std::string& name) const { return _name == name; }; 59 60 void acquireID(const int*& id, const std::string*& name) const { id = &_id; name = &_name; }; 59 61 60 62 virtual void debug() const = 0; … … 130 132 typedef std::map<std::string, NewObjectListBase*> classNameMap; //!< The Generic Map. 131 133 132 NewClassID _identity; //!< The Identity of the Class (ID and Name). 134 int _id; 135 const std::string _name; //!< The Name of the Class. 136 NewClassID _identity; //!< The Identity of the Class. (equal to _id and _name) 133 137 134 138 private:
Note: See TracChangeset
for help on using the changeset viewer.