Changeset 7162 in orxonox.OLD for trunk/src/lib/lang
- Timestamp:
- Feb 18, 2006, 3:58:03 PM (19 years ago)
- Location:
- trunk/src/lib/lang
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/lang/class_list.cc
r7125 r7162 53 53 54 54 //! a List of all known Classes. 55 std:: list<ClassList>* ClassList::classList = NULL;55 std::vector<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 list<ClassList>();72 ClassList::classList = new std::vector<ClassList>(); 73 73 74 74 PRINTF(5)("subscribe a '%s'\n", className ); … … 94 94 void ClassList::removeFromClassList(BaseObject* objectPointer) 95 95 { 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); 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); 104 106 } 105 107 } … … 119 121 ClassList::classNames.clear(); 120 122 121 list<ClassList>::const_iterator cl; 122 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 123 ClassList::classNames.push_back((*cl).className); 123 for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++) 124 ClassList::classNames.push_back((*ClassList::classList)[cl].className); 124 125 } 125 126 … … 181 182 ClassList* ClassList::getClassList(ClassID classID) 182 183 { 183 std:: list<ClassList>::iterator classIT = find (ClassList::classList->begin(), ClassList::classList->end(), classID);184 std::vector<ClassList>::iterator classIT = find (ClassList::classList->begin(), ClassList::classList->end(), classID); 184 185 return (likely(classIT != classList->end()))? &(*classIT) : NULL; 185 186 } … … 195 196 if (className == NULL) 196 197 return NULL; 197 std:: list<ClassList>::iterator classIT = find (classList->begin(), classList->end(), className);198 std::vector<ClassList>::iterator classIT = find (classList->begin(), classList->end(), className); 198 199 return (likely(classIT != classList->end()))? &(*classIT) : NULL; 199 200 } … … 222 223 else 223 224 { 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++) 225 std::list<BaseObject*>::iterator bo; 226 for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++) 227 { 228 for (bo = (*ClassList::classList)[cl].objectList.begin(); bo != (*ClassList::classList)[cl].objectList.end(); bo++) 229 229 if ((*bo)->getName() != NULL && !strcmp((*bo)->getName(), objectName)) 230 230 return (*bo); … … 255 255 else 256 256 { 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()) 257 for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++) 258 { 259 std::list<BaseObject*>::const_iterator bo = 260 find ((*ClassList::classList)[cl].objectList.begin(), 261 (*ClassList::classList)[cl].objectList.end(), object); 262 if (bo != (*ClassList::classList)[cl].objectList.end()) 262 263 return true; 263 264 } … … 272 273 void ClassList::whatIs(const BaseObject* object) 273 274 { 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); 275 for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++) 276 if (object->isA((*ClassList::classList)[cl].classID)) 277 { 278 PRINT(0)("=%s::0x%.8X=-", 279 (*ClassList::classList)[cl].className, 280 (*ClassList::classList)[cl].classID); 279 281 } 280 282 } … … 333 335 unsigned int lenCount = 0; 334 336 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))) 337 for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++) 338 { 339 if ((debugLevel >= 1 || (*ClassList::classList)[cl].objectList.size() > 0 ) && 340 (classID == CL_NULL || unlikely (classID == (*ClassList::classList)[cl].classID))) 340 341 { 341 342 lenCount = 1; 342 while (pow(10, lenCount) <= (* cl).objectList.size())343 while (pow(10, lenCount) <= (*ClassList::classList)[cl].objectList.size()) 343 344 ++lenCount; 344 for (int i=0; i < 30-strlen((* cl).className) - lenCount; i++)345 for (int i=0; i < 30-strlen((*ClassList::classList)[cl].className) - lenCount; i++) 345 346 (niceString[i]) = ' '; 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) 347 niceString[30-strlen((*ClassList::classList)[cl].className) - lenCount] = '\0'; 348 349 PRINT(0)("| CLASS %s::%s %d\n", (*ClassList::classList)[cl].className, niceString, 350 (*ClassList::classList)[cl].objectList.size()); 351 352 if (debugLevel >=2 && (*ClassList::classList)[cl].objectList.size() > 0) 351 353 { 352 354 PRINT(0)("| Listing Instances:\n"); 353 355 list<BaseObject*>::const_iterator bo; 354 for (bo = (* cl).objectList.begin(); bo != (*cl).objectList.end(); bo++)356 for (bo = (*ClassList::classList)[cl].objectList.begin(); bo != (*ClassList::classList)[cl].objectList.end(); bo++) 355 357 { 356 358 PRINT(0)("| %s::%s::(0x%.8X->%p ", (*bo)->getClassName(), (*bo)->getName(), (*bo)->getClassID(), (*bo)); -
trunk/src/lib/lang/class_list.h
r6280 r7162 10 10 #include "class_id.h" 11 11 #include <list> 12 #include <vector> 12 13 #ifndef NULL 13 14 #define NULL 0 //!< NULL … … 73 74 74 75 // STATIC MEMBERS 75 static std:: list<ClassList>* classList; //!< The first Class in the List76 static std::vector<ClassList>* classList; //!< The list of ClassLists. 76 77 static std::list<const char*> classNames; //!< a List of all Names of all classes, that have registered so far. 77 78 };
Note: See TracChangeset
for help on using the changeset viewer.