Changeset 4301 in orxonox.OLD for orxonox/branches/physics/src/util/object_manager.cc
- Timestamp:
- May 26, 2005, 3:20:55 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/util/object_manager.cc
r4283 r4301 11 11 ### File Specific: 12 12 main-programmer: Patrick Boenzli 13 co-programmer: ...14 13 */ 15 14 … … 17 16 18 17 #include "object_manager.h" 18 #include "garbage_collector.h" 19 #include "list.h" 20 19 21 20 22 using namespace std; … … 26 28 ObjectManager::ObjectManager () 27 29 { 28 this->setClassName ("ObjectManager"); 30 this->setClassName ("ObjectManager"); 31 32 //this->managedObjectList = new BaseObject*[CL_NUMBER]; 33 this->managedObjectList = new tList<BaseObject>*[CL_NUMBER]; 29 34 35 this->garbageCollector = GarbageCollector::getInstance(); 30 36 } 31 37 … … 45 51 } 46 52 53 47 54 /** 48 55 \brief standard deconstructor … … 52 59 { 53 60 ObjectManager::singletonRef = NULL; 61 } 54 62 63 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 } 55 72 } 73 74 75 void ObjectManager::addToDeadList(classList index, BaseObject* object) 76 { 77 if( likely(this->managedObjectList[index] != NULL)) 78 this->managedObjectList[index]->add(object); 79 else 80 PRINTF(0)(" Error: unable to add object to the list nr. %i: no list initialized - ignoring\n", index); 81 } 82 83 84 BaseObject* ObjectManager::getFromDeadList(classList index, int number) 85 { 86 if( likely(this->managedObjectList[index] != NULL)) 87 { 88 BaseObject* obj = this->managedObjectList[index]->firstElement(); 89 this->managedObjectList[index]->remove(obj); 90 return obj; 91 } 92 else 93 PRINTF(0)(" Error: unable to get object from the list nr. %i: no elements initialized - ignoring\n", index); 94 } 95 96 97 void ObjectManager::debug() 98 { 99 PRINT(0)("\n==========================| ObjectManager::debug() |===\n"); 100 PRINT(0)("= Number of registerable classes: %i\n", CL_NUMBER ); 101 PRINT(0)("= Currently cached objects: \n"); 102 for(int i = 0; i < CL_NUMBER; ++i) 103 { 104 if(this->managedObjectList[i] != NULL) 105 PRINT(0)("= o Class Nr. %i has cached %i object(s)\n", i, this->managedObjectList[i]->getSize()); 106 else 107 PRINT(0)("= o Class Nr. %i has cached 0 object(s)\n", i); 108 } 109 PRINT(0)("=======================================================\n"); 110 }
Note: See TracChangeset
for help on using the changeset viewer.