Changeset 4332 in orxonox.OLD for orxonox/branches/physics/src/util/object_manager.cc
- Timestamp:
- May 27, 2005, 7:14:55 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/util/object_manager.cc
r4301 r4332 28 28 ObjectManager::ObjectManager () 29 29 { 30 this->setClass Name ("ObjectManager");30 this->setClassID(CL_OBJECT_MANAGER, "ObjectManager"); 31 31 32 //this->managedObjectList = new BaseObject*[CL_NUMBER];33 32 this->managedObjectList = new tList<BaseObject>*[CL_NUMBER]; 33 for(int i = 0; i < CL_NUMBER; ++i) 34 { 35 this->managedObjectList[i] = NULL; 36 } 34 37 35 38 this->garbageCollector = GarbageCollector::getInstance(); 36 39 } 40 37 41 38 42 /** … … 62 66 63 67 64 void ObjectManager::cache(classList index, int number, const BaseObject ©Object) 65 { 66 //this->managedObjectList[index] = new BaseObject[number]; 67 this->managedObjectList[index] = new tList<BaseObject>(); 68 for(int i = 0; i < number; ++i) 69 { 70 this->managedObjectList[index]->add(new BaseObject(copyObject)); 71 } 72 } 73 74 75 void ObjectManager::addToDeadList(classList index, BaseObject* object) 68 void ObjectManager::addToDeadList(int index, BaseObject* object) 76 69 { 77 70 if( likely(this->managedObjectList[index] != NULL)) 78 71 this->managedObjectList[index]->add(object); 79 72 else 80 PRINTF(0)(" Error: unable to add object to the list nr. %i: no list initialized - ignoring\n", index);73 PRINTF(0)(" Critical: unable to add object to the list nr. %i: no list initialized - ignoring\n", index); 81 74 } 82 75 83 76 84 BaseObject* ObjectManager::getFromDeadList( classList index, int number)77 BaseObject* ObjectManager::getFromDeadList(int index, int number) 85 78 { 86 79 if( likely(this->managedObjectList[index] != NULL)) … … 88 81 BaseObject* obj = this->managedObjectList[index]->firstElement(); 89 82 this->managedObjectList[index]->remove(obj); 83 if( unlikely(obj == NULL)) 84 { 85 PRINTF(0)("Critical: there was no object anymore in the dead list! This could result in Segfaults\n"); 86 } 90 87 return obj; 91 88 } 92 89 else 93 PRINTF(0)(" Error: unable to get object from the list nr. %i: no elements initialized - ignoring\n", index); 90 PRINTF(0)(" Critical: unable to get object from the list nr. %i: no elements initialized - ignoring\n", index); 91 return NULL; 94 92 } 95 93 … … 102 100 for(int i = 0; i < CL_NUMBER; ++i) 103 101 { 104 if( this->managedObjectList[i] != NULL)102 if( this->managedObjectList[i] != NULL) 105 103 PRINT(0)("= o Class Nr. %i has cached %i object(s)\n", i, this->managedObjectList[i]->getSize()); 106 104 else
Note: See TracChangeset
for help on using the changeset viewer.