Changeset 4747 in orxonox.OLD for orxonox/trunk/src/lib/lang/class_list.cc
- Timestamp:
- Jul 1, 2005, 4:10:44 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/lang/class_list.cc
r4744 r4747 17 17 18 18 #include "class_list.h" 19 #include "base_object.h" 20 21 #include "compiler.h" 22 #include "debug.h" 19 23 20 24 using namespace std; … … 25 29 \todo this constructor is not jet implemented - do it 26 30 */ 27 ClassList::ClassList ()31 ClassList::ClassList(const long& classID, const char* className) 28 32 { 29 /* If you make a new class, what is most probably the case when you write this file 30 don't forget to: 31 1. Add the new file new_class.cc to the ./src/Makefile.am 32 2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS 33 34 Advanced Topics: 35 - if you want to let your object be managed via the ObjectManager make sure to read 36 the object_manager.h header comments. You will use this most certanly only if you 37 make many objects of your class, like a weapon bullet. 38 */ 33 this->objectCount = 0; 34 this->next = NULL; 35 this->className = className; 36 this->classID = classID; 39 37 } 40 38 … … 48 46 // delete what has to be deleted here 49 47 } 48 49 ClassList* ClassList::first = NULL; 50 unsigned int ClassList::classCount = 0; 51 52 53 54 void ClassList::addToClassList(BaseObject* objectPointer, const long& classID, const char* className) 55 { 56 ClassList* regClass; 57 58 if(ClassList::first == NULL) 59 ClassList::first = regClass = new ClassList(classID, className); 60 else 61 { 62 ClassList* tmp = ClassList::first; 63 while (likely(tmp != NULL)) 64 { 65 if (tmp->classID == classID) 66 { 67 regClass = tmp; 68 break; 69 } 70 71 if (tmp->next == NULL) 72 tmp->next = regClass = new ClassList(classID, className); 73 tmp = tmp->next; 74 } 75 } 76 77 ++regClass->objectCount; 78 } 79 80 void ClassList::removeFromClassList(BaseObject* objectPointer) 81 { 82 ClassList* tmp = ClassList::first; 83 while (likely(tmp != NULL)) 84 { 85 if (objectPointer->isA(tmp->classID)) 86 { 87 --tmp->objectCount; 88 } 89 90 tmp = tmp->next; 91 } 92 } 93 94 95 void ClassList::debug() 96 { 97 PRINT(0)("=================\n"); 98 PRINT(0)("= CLASS_LIST =\n"); 99 PRINT(0)("=================\n"); 100 ClassList* tmp = ClassList::first; 101 while (likely(tmp != NULL)) 102 { 103 PRINT(0)("CLASS %s has %d instances\n", tmp->className, tmp->objectCount); 104 105 tmp = tmp->next; 106 } 107 PRINT(0)("==============CL=\n"); 108 109 }
Note: See TracChangeset
for help on using the changeset viewer.