Changeset 7165 in orxonox.OLD for trunk/src/lib/lang
- Timestamp:
- Feb 18, 2006, 5:38:37 PM (19 years ago)
- Location:
- trunk/src/lib/lang
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/lang/class_list.cc
r7164 r7165 53 53 54 54 //! a List of all known Classes. 55 std:: vector<ClassList>* ClassList::classList = NULL;55 std::list<ClassList>* ClassList::classList = NULL; 56 56 57 57 //! a List of all strings of all classes, that have registered so far. … … 70 70 { 71 71 if (unlikely(classList == NULL)) 72 ClassList::classList = new std::vector<ClassList>();72 ClassList::classList = new list<ClassList>(); 73 73 74 74 PRINTF(5)("subscribe a '%s'\n", className ); … … 94 94 void ClassList::removeFromClassList(BaseObject* objectPointer) 95 95 { 96 for(unsigned int cl= 0; cl < ClassList::classList->size(); cl++) 97 { 98 if (objectPointer->isA((*ClassList::classList)[cl].classID)) 99 { 100 std::list<BaseObject*>::iterator bo = 101 std::find ((*ClassList::classList)[cl].objectList.begin(), 102 (*ClassList::classList)[cl].objectList.end(), 103 objectPointer); 104 if (bo != (*ClassList::classList)[cl].objectList.end()) 105 (*ClassList::classList)[cl].objectList.erase(bo); 96 list<ClassList>::iterator cl; 97 for(cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 98 { 99 if (objectPointer->isA((*cl).classID)) 100 { 101 std::list<BaseObject*>::iterator bo = std::find ((*cl).objectList.begin(), (*cl).objectList.end(), objectPointer); 102 if (bo != (*cl).objectList.end()) 103 (*cl).objectList.erase(bo); 106 104 } 107 105 } … … 121 119 ClassList::classNames.clear(); 122 120 123 for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++) 124 ClassList::classNames.push_back((*ClassList::classList)[cl].className); 121 list<ClassList>::const_iterator cl; 122 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 123 ClassList::classNames.push_back((*cl).className); 125 124 } 126 125 … … 178 177 * !!PRIVATE!! 179 178 * @param classID the ClassID to search for 180 * @returns the ClassList with classID as specif ier, or NULL if not179 * @returns the ClassList with classID as specifyer, or NULL if not 181 180 */ 182 181 ClassList* ClassList::getClassList(ClassID classID) 183 182 { 184 std::vector<ClassList>::iterator classIT = 185 std::find (ClassList::classList->begin(), ClassList::classList->end(), classID); 183 std::list<ClassList>::iterator classIT = find (ClassList::classList->begin(), ClassList::classList->end(), classID); 186 184 return (likely(classIT != classList->end()))? &(*classIT) : NULL; 187 185 } … … 191 189 * !!PRIVATE!! 192 190 * @param className the ClassName to search for 193 * @returns the ClassList with className as specif ier, or NULL if not191 * @returns the ClassList with className as specifyer, or NULL if not 194 192 */ 195 193 ClassList* ClassList::getClassList(const char* className) … … 197 195 if (className == NULL) 198 196 return NULL; 199 std:: vector<ClassList>::iterator classIT = find (ClassList::classList->begin(), ClassList::classList->end(), className);197 std::list<ClassList>::iterator classIT = find (classList->begin(), classList->end(), className); 200 198 return (likely(classIT != classList->end()))? &(*classIT) : NULL; 201 199 } … … 224 222 else 225 223 { 226 std::list<BaseObject*>::iterator bo; 227 for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++) 228 { 229 for (bo = (*ClassList::classList)[cl].objectList.begin(); bo != (*ClassList::classList)[cl].objectList.end(); bo++) 224 list<ClassList>::iterator cl; 225 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 226 { 227 std::list<BaseObject*>::iterator bo; 228 for (bo = (*cl).objectList.begin(); bo != (*cl).objectList.end(); bo++) 230 229 if ((*bo)->getName() != NULL && !strcmp((*bo)->getName(), objectName)) 231 230 return (*bo); … … 256 255 else 257 256 { 258 for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++) 259 { 260 std::list<BaseObject*>::const_iterator bo = 261 find ((*ClassList::classList)[cl].objectList.begin(), 262 (*ClassList::classList)[cl].objectList.end(), object); 263 if (bo != (*ClassList::classList)[cl].objectList.end()) 257 list<ClassList>::iterator cl; 258 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 259 { 260 std::list<BaseObject*>::const_iterator bo = find ((*cl).objectList.begin(), (*cl).objectList.end(), object); 261 if (bo != (*cl).objectList.end()) 264 262 return true; 265 263 } … … 274 272 void ClassList::whatIs(const BaseObject* object) 275 273 { 276 for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++) 277 if (object->isA((*ClassList::classList)[cl].classID)) 278 { 279 PRINT(0)("=%s::0x%.8X=-", 280 (*ClassList::classList)[cl].className, 281 (*ClassList::classList)[cl].classID); 274 list<ClassList>::iterator cl; 275 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 276 if (object->isA((*cl).classID)) 277 { 278 PRINT(0)("=%s::0x%.8X=-", (*cl).className, (*cl).classID); 282 279 } 283 280 } … … 336 333 unsigned int lenCount = 0; 337 334 338 for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++) 339 { 340 if ((debugLevel >= 1 || (*ClassList::classList)[cl].objectList.size() > 0 ) && 341 (classID == CL_NULL || unlikely (classID == (*ClassList::classList)[cl].classID))) 335 list<ClassList>::iterator cl; 336 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 337 { 338 if ((debugLevel >= 1 || (*cl).objectList.size() > 0 ) && 339 (classID == CL_NULL || unlikely (classID == (*cl).classID))) 342 340 { 343 341 lenCount = 1; 344 while (pow(10, lenCount) <= (* ClassList::classList)[cl].objectList.size())342 while (pow(10, lenCount) <= (*cl).objectList.size()) 345 343 ++lenCount; 346 for (int i=0; i < 30-strlen((* ClassList::classList)[cl].className) - lenCount; i++)344 for (int i=0; i < 30-strlen((*cl).className) - lenCount; i++) 347 345 (niceString[i]) = ' '; 348 niceString[30-strlen((*ClassList::classList)[cl].className) - lenCount] = '\0'; 349 350 PRINT(0)("| CLASS %s::%s %d\n", (*ClassList::classList)[cl].className, niceString, 351 (*ClassList::classList)[cl].objectList.size()); 352 353 if (debugLevel >=2 && (*ClassList::classList)[cl].objectList.size() > 0) 346 niceString[30-strlen((*cl).className) - lenCount] = '\0'; 347 348 PRINT(0)("| CLASS %s::%s %d\n", (*cl).className, niceString, (*cl).objectList.size()); 349 350 if (debugLevel >=2 && (*cl).objectList.size() > 0) 354 351 { 355 352 PRINT(0)("| Listing Instances:\n"); 356 353 list<BaseObject*>::const_iterator bo; 357 for (bo = (* ClassList::classList)[cl].objectList.begin(); bo != (*ClassList::classList)[cl].objectList.end(); bo++)354 for (bo = (*cl).objectList.begin(); bo != (*cl).objectList.end(); bo++) 358 355 { 359 356 PRINT(0)("| %s::%s::(0x%.8X->%p ", (*bo)->getClassName(), (*bo)->getName(), (*bo)->getClassID(), (*bo)); -
trunk/src/lib/lang/class_list.h
r7163 r7165 10 10 #include "class_id.h" 11 11 #include <list> 12 #include <vector>13 12 #ifndef NULL 14 13 #define NULL 0 //!< NULL … … 59 58 inline bool operator==(ClassID classID) { return (this->classID == classID); }; 60 59 bool operator==(const char* className); 61 bool operator<(ClassID classID) { return this->classID < classID; };62 63 60 inline ClassID getLeafClassID() const { return this->classID; }; 64 61 … … 76 73 77 74 // STATIC MEMBERS 78 static std:: vector<ClassList>* classList; //!< The list of ClassLists.75 static std::list<ClassList>* classList; //!< The first Class in the List 79 76 static std::list<const char*> classNames; //!< a List of all Names of all classes, that have registered so far. 80 77 };
Note: See TracChangeset
for help on using the changeset viewer.