Changeset 4932 in orxonox.OLD for orxonox/trunk/src/util/object_manager.cc
- Timestamp:
- Jul 22, 2005, 12:08:51 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/object_manager.cc
r4931 r4932 24 24 25 25 26 27 28 /** 29 * constructor, sets everything to zero and define factoryName 30 */ 31 FastFactory::FastFactory (const char* fastFactoryName, ClassID classID) 32 { 33 this->setClassID(CL_FAST_FACTORY, "FastFactory"); 34 this->setName(fastFactoryName); 35 36 this->storedClassID = classID; 37 this->next = NULL; 38 39 FastFactory::registerFastFactory(this); 40 } 41 42 /** a reference to the First FastFactory */ 43 FastFactory* FastFactory::first = NULL; 44 45 /** 46 * destructor 47 * clear the Q 48 */ 49 FastFactory::~FastFactory () 50 { 51 if (this == first) 52 this->first = NULL; 53 54 if (this->next) 55 delete this->next; 56 } 57 58 /** 59 * add a FastFactory to the FastFactory Queue 60 * @param factory a FastFactory to be registered 61 */ 62 void FastFactory::registerFastFactory( FastFactory* factory) 63 { 64 PRINTF(3)("Registered FastFactory for '%s'\n", factory->getName()); 65 66 if( FastFactory::first == NULL) 67 FastFactory::first = factory; 68 else 69 { 70 FastFactory* tmpFac = FastFactory::first; 71 while( tmpFac->next != NULL) 72 { 73 tmpFac = tmpFac->next; 74 } 75 tmpFac->setNext(factory); 76 } 77 } 78 79 80 81 82 83 84 85 86 87 88 89 90 26 91 /** 27 92 * standard constructor … … 32 97 this->setName("ObjectManager"); 33 98 34 this->managedObjectList = new tList<BaseObject>*[CL_NUMBER];35 for(int i = 0; i < CL_NUMBER; ++i)36 {37 this->managedObjectList[i] = NULL;38 }39 99 } 40 100 … … 54 114 55 115 /** 56 * adds an element to the list of dead objects57 * @param index: The type of object to add58 * @param object: pointer to the object at hand59 */60 void ObjectManager::addToDeadList(int index, BaseObject* object)61 {62 if( likely(this->managedObjectList[index] != NULL))63 this->managedObjectList[index]->add(object);64 else65 PRINTF(0)(" Critical: unable to add object to the list nr. %i: no list initialized - ignoring\n", index);66 }67 68 /**69 * resurects an object70 * @param index: the type of resource to load71 * @param number: how many of them72 73 @todo if it is unable to get an object from the deadList, it should create it74 */75 BaseObject* ObjectManager::getFromDeadList(int index, int number)76 {77 if( likely(this->managedObjectList[index] != NULL))78 {79 BaseObject* obj = this->managedObjectList[index]->firstElement();80 this->managedObjectList[index]->remove(obj);81 if( unlikely(obj == NULL))82 {83 PRINTF(0)("Critical: there was no object anymore in the dead list! This could result in Segfaults\n");84 }85 return obj;86 }87 else88 PRINTF(0)(" Critical: unable to get object from the list nr. %i: no elements initialized - ignoring\n", index);89 return NULL;90 }91 92 /**93 116 * outputs some simple debug information about the ObjectManage 94 117 */ … … 96 119 { 97 120 PRINT(0)("\n==========================| ObjectManager::debug() |===\n"); 98 99 100 101 121 /* PRINT(0)("= Number of registerable classes: %i\n", CL_NUMBER ); 122 PRINT(0)("= Currently cached objects: \n"); 123 for(int i = 0; i < CL_NUMBER; ++i) 124 { 102 125 if( this->managedObjectList[i] != NULL) 103 126 PRINT(0)("= o Class Nr. %i has cached %i object(s)\n", i, this->managedObjectList[i]->getSize()); 104 127 else 105 128 PRINT(0)("= o Class Nr. %i has cached 0 object(s)\n", i); 106 } 129 }*/ 107 130 PRINT(0)("=======================================================\n"); 108 131 } 109 132 110 133 111 112 /**113 * constructor114 115 set everything to zero and define factoryName116 */117 FastObject::FastObject (const char* fastObjectName, ClassID classID)118 {119 this->setClassID(CL_FACTORY, "FastObject");120 this->setName(fastObjectName);121 122 this->storedClassID = classID;123 this->next = NULL;124 125 FastObject::registerFastObject(this);126 }127 128 /** a reference to the First FastObject */129 FastObject* FastObject::first = NULL;130 131 /**132 * destructor133 134 clear the Q135 */136 FastObject::~FastObject ()137 {138 // printf("%s\n", this->factoryName);139 // FastObject* tmpDel = this->next;140 // this->next = NULL;141 if (this->next)142 delete this->next;143 }144 145 /**146 * add a FastObject to the FastObject Queue147 * @param factory a FastObject to be registered148 */149 void FastObject::registerFastObject( FastObject* factory)150 {151 PRINTF(4)("Registered FastObject for '%s'\n", factory->getName());152 153 if( FastObject::first == NULL)154 FastObject::first = factory;155 else156 {157 FastObject* tmpFac = FastObject::first;158 while( tmpFac->next != NULL)159 {160 tmpFac = tmpFac->next;161 }162 tmpFac->setNext(factory);163 }164 }
Note: See TracChangeset
for help on using the changeset viewer.