Changeset 9676 in orxonox.OLD for trunk/src/lib/lang/new_object_list.cc
- Timestamp:
- Aug 21, 2006, 11:09:53 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/lang/new_object_list.cc
r9675 r9676 20 20 21 21 22 NewObjectListBase::NewObjectListBase(const std::string& className )23 : _ id(-1), _name(className)22 NewObjectListBase::NewObjectListBase(const std::string& className, int id) 23 : _name(className) 24 24 { 25 25 if (NewObjectListBase::_classesByID == NULL) … … 29 29 NewObjectListBase::_classesByName = new classNameMap; 30 30 } 31 assert(!NewObjectListBase::classNameExists(className) && "Classes should only be included once, and no two classes should have the same name /ID(key value)");31 assert(!NewObjectListBase::classNameExists(className) && "Classes should only be included once, and no two classes should have the same name (key value)"); 32 32 33 34 this->_id = NewObjectListBase::_idCounter++; 33 if (id != -1) 34 { 35 assert(!NewObjectListBase::classIDExists(id) && "Classes should only be included once, and no two classes should have the same ID (key value)"); 36 } 37 else 38 { 39 this->_id = NewObjectListBase::_classesByID->size(); 40 } 35 41 36 42 (*NewObjectListBase::_classesByID)[this->_id] = this; … … 38 44 } 39 45 46 47 /** 48 * Destructor. 49 * 50 * This destructor deletes the NewObjectList, and cleans up the NewObjectList sorted Maps. 51 */ 40 52 NewObjectListBase::~NewObjectListBase() 41 53 { … … 53 65 } 54 66 55 int NewObjectListBase::_idCounter = 0;56 67 NewObjectListBase::classIDMap* NewObjectListBase::_classesByID = NULL; 57 68 NewObjectListBase::classNameMap* NewObjectListBase::_classesByName = NULL; 58 69 59 70 71 72 /** 73 * @returns the Registered Class Count. 74 */ 75 unsigned int NewObjectListBase::classCount() 76 { 77 assert (NewObjectListBase::_classesByID != NULL); 78 return NewObjectListBase::_classesByID->size(); 79 }; 60 80 61 81 /** … … 67 87 { 68 88 return (NewObjectListBase::_classesByName->find(name) != NewObjectListBase::_classesByName->end()); 69 // classNameMap::iterator it; 70 // for (it = NewObjectListBase::_classesByID->begin(); it != NewObjectListBase::_classesByID->end(); it++) 71 // if(*it != NULL && (*it)->name() != name) 72 // return true; 73 // return false; 89 } 90 91 /** 92 * @brief Checks if a Class with name already exists. 93 * @param name The Name of the Class to check. 94 * @return true if such a class already exists. 95 */ 96 bool NewObjectListBase::classIDExists(int id) 97 { 98 return (NewObjectListBase::_classesByID->find(id) != NewObjectListBase::_classesByID->end()); 74 99 } 75 100
Note: See TracChangeset
for help on using the changeset viewer.