Changeset 9726 in orxonox.OLD for branches/new_class_id/src/lib/lang
- Timestamp:
- Sep 9, 2006, 7:42:16 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib/lang
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/lang/object_list.cc
r9725 r9726 19 19 #include <cassert> 20 20 21 22 #include <stdio.h>23 24 21 /** 25 22 * @brief Constructor, that creates an ObjectList while checking (development mode) for uniqueness of all Keys (names and ID's) … … 33 30 if (ObjectListBase::_classesByID == NULL) 34 31 { 35 ObjectListBase::_classesByID = new classIDMap;32 ObjectListBase::_classesByID = new IDMap; 36 33 assert (ObjectListBase::_classesByName == NULL); 37 ObjectListBase::_classesByName = new classNameMap;34 ObjectListBase::_classesByName = new NameMap; 38 35 } 39 36 assert(!ObjectListBase::classNameExists(className) && "Classes should only be included once, and no two classes should have the same name (key value)"); … … 83 80 } 84 81 85 ObjectListBase:: classIDMap* ObjectListBase::_classesByID = NULL;86 ObjectListBase:: classNameMap* ObjectListBase::_classesByName = NULL;82 ObjectListBase::IDMap* ObjectListBase::_classesByID = NULL; 83 ObjectListBase::NameMap* ObjectListBase::_classesByName = NULL; 87 84 std::list<std::string> ObjectListBase::_classNames; 88 85 … … 156 153 { 157 154 assert (ObjectListBase::_classesByID != NULL); 158 ObjectListBase:: classIDMap::iterator it = ObjectListBase::_classesByID->find(classID);155 ObjectListBase::IDMap::iterator it = ObjectListBase::_classesByID->find(classID); 159 156 if (it != ObjectListBase::_classesByID->end()) 160 157 return (*it).second; … … 171 168 { 172 169 assert (ObjectListBase::_classesByName != NULL); 173 ObjectListBase:: classNameMap::iterator it = ObjectListBase::_classesByName->find(className);170 ObjectListBase::NameMap::iterator it = ObjectListBase::_classesByName->find(className); 174 171 if (it != ObjectListBase::_classesByName->end()) 175 172 return (*it).second; … … 243 240 ObjectListBase::_classNames.clear(); 244 241 245 for (classNameMap::const_iterator it = ObjectListBase::_classesByName->begin(); 246 it != ObjectListBase::_classesByName->end(); 247 ++it) 248 { 242 for (NameMap::const_iterator it = ObjectListBase::_classesByName->begin(); 243 it != ObjectListBase::_classesByName->end(); 244 ++it) 249 245 ObjectListBase::_classNames.push_back((*it).second->name()); 250 }251 246 } 252 247 return ObjectListBase::_classNames; … … 294 289 printf("Listing all %d ObjectLists \n", ObjectListBase::_classesByID->size()); 295 290 296 for ( classNameMap::const_iterator it = ObjectListBase::_classesByName->begin();291 for (NameMap::const_iterator it = ObjectListBase::_classesByName->begin(); 297 292 it != ObjectListBase::_classesByName->end(); 298 293 ++it) 299 {300 294 (*it).second->debug(level); 301 302 }303 304 295 } 305 296 … … 339 330 return -1; 340 331 } 341 -
branches/new_class_id/src/lib/lang/object_list.h
r9724 r9726 9 9 10 10 #include "class_id.h" 11 #include <cassert>12 11 #include <map> 13 12 #include <list> 14 13 #include <string> 14 15 #include <cassert> 15 16 #include <iostream> 16 17 … … 101 102 static int StringToID(const std::string& className); 102 103 103 //! Only use t to unsubscribe a BaseObject.104 //! Only used to unsubscribe a BaseObject. (just try to make a valid iterator, stupid :)) 104 105 virtual void unregisterObject(IteratorBase* _iterators) = 0; 105 106 … … 117 118 118 119 protected: 119 typedef std::map<int, ObjectListBase*> classIDMap; //!< The Generic Map.120 typedef std::map<std::string, ObjectListBase*> classNameMap; //!< The Generic Map.120 typedef std::map<int, ObjectListBase*> IDMap; //!< The Generic Map. 121 typedef std::map<std::string, ObjectListBase*> NameMap; //!< The Generic Map. 121 122 122 123 private: … … 126 127 127 128 private: 128 static classIDMap*_classesByID; //!< A Map of all the classes in existance.129 static classNameMap*_classesByName; //!< A Map of all the classes in existance.129 static IDMap* _classesByID; //!< A Map of all the classes in existance. 130 static NameMap* _classesByName; //!< A Map of all the classes in existance. 130 131 static std::list<std::string> _classNames; //!< A list of all the registered ClassNames. 131 132 }; … … 135 136 //// TEMPLATISATION ///// 136 137 ///////////////////////// 137 //! Defines a Object sList handler for objects of type T.138 //! Defines a ObjectList handler for objects of type T. 138 139 /** 139 140 * The ObjectList is a generic way to store every object created from a Class 'T' 140 * in toa List. The list can be retrieved, and used constantly over iterators,141 * in a List. The list can be retrieved, and used constantly over iterators, 141 142 * as with normal std::list. 142 143 * 143 144 * Furthermore the linkage over the single Lists is given over the Superclass ObjectListBase. 144 145 * 145 * 146 * 146 * The approach of ObjectList is an intrusive one, meaning, that each Class that wants to 147 * support it must implement a Declaration and a Definition for the ObjectList, as mentioned 148 * in the next statement: 147 149 * 148 150 * To define a Class with a ObjectList, you have to: … … 152 154 * 153 155 * @note The Class must define the compare with const std::string& operator for this to work. 156 * The operator==(const std::string& name) should compare the object's name with name. 154 157 * 155 158 *
Note: See TracChangeset
for help on using the changeset viewer.