Changeset 4301 in orxonox.OLD for orxonox/branches/physics/src/util
- Timestamp:
- May 26, 2005, 3:20:55 PM (20 years ago)
- Location:
- orxonox/branches/physics/src/util
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/util/garbage_collector.cc
r4283 r4301 25 25 26 26 #include "list.h" 27 #include "object_manager.h" 27 28 28 29 using namespace std; … … 137 138 entity->remove(); 138 139 /* then finaly delete reference */ 139 delete entity; 140 //delete entity; 141 ObjectManager::getInstance()->addToDeadList(CL_TEST_BULLET, entity); 142 ObjectManager::getInstance()->debug(); 140 143 } 141 144 entity = iterator->nextElement(); -
orxonox/branches/physics/src/util/loading/load_param.cc
r4283 r4301 10 10 11 11 ### File Specific: 12 main-programmer: Christian Meyer12 main-programmer: Benjamin Grauer 13 13 co-programmer: ... 14 14 */ … … 27 27 \param ... the parameter information 28 28 */ 29 BaseLoadParam::BaseLoadParam(BaseObject* object, const char* paramName, int paramCount, ...) 30 { 29 BaseLoadParam::BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, ...) 30 { 31 this->loadString = grabParameter(root, paramName); 32 31 33 this->paramDesc = NULL; 32 34 if (LoadClassDescription::parametersDescription) … … 47 49 strcpy(this->paramDesc->types[i], tmpTypeName); 48 50 } 49 va_end(types); 51 va_end(types); 50 52 51 53 int argCount = 0; -
orxonox/branches/physics/src/util/loading/load_param.h
r4283 r4301 65 65 #define LoadParam1(type1) \ 66 66 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE)) \ 67 : BaseLoadParam(pt2Object, paramName, 1, type1##_NAME) \ 68 { \ 69 const char* loadString = grabParameter(root, paramName); \ 67 : BaseLoadParam(root, pt2Object, paramName, 1, type1##_NAME) \ 68 { \ 70 69 if (loadString != NULL && root != NULL) \ 71 70 (*pt2Object.*function)(type1##_FUNC(loadString)); \ … … 78 77 #define LoadParam2(type1, type2) \ 79 78 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE)) \ 80 : BaseLoadParam(pt2Object, paramName, 2, type1##_NAME, type2##_NAME) \ 81 { \ 82 const char* loadString = grabParameter(root, paramName); \ 79 : BaseLoadParam(root, pt2Object, paramName, 2, type1##_NAME, type2##_NAME) \ 80 { \ 83 81 if (loadString != NULL && root != NULL) \ 84 82 { \ … … 98 96 #define LoadParam3(type1, type2, type3) \ 99 97 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE))\ 100 : BaseLoadParam(pt2Object, paramName, 3, type1##_NAME, type2##_NAME, type3##_NAME) \ 101 { \ 102 const char* loadString = grabParameter(root, paramName); \ 98 : BaseLoadParam(root, pt2Object, paramName, 3, type1##_NAME, type2##_NAME, type3##_NAME) \ 99 { \ 103 100 if (loadString != NULL && root != NULL) \ 104 101 { \ … … 118 115 #define LoadParam4(type1, type2, type3, type4) \ 119 116 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE)) \ 120 : BaseLoadParam(pt2Object, paramName, 4, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME) \ 121 { \ 122 const char* loadString = grabParameter(root, paramName); \ 117 : BaseLoadParam(root, pt2Object, paramName, 4, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME) \ 118 { \ 123 119 if (loadString != NULL && root != NULL) \ 124 120 { \ … … 138 134 #define LoadParam5(type1, type2, type3, type4, type5) \ 139 135 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE, type5##_TYPE)) \ 140 : BaseLoadParam(pt2Object, paramName, 5, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME, type5##_NAME) \ 141 { \ 142 const char* loadString = grabParameter(root, paramName); \ 136 : BaseLoadParam(root, pt2Object, paramName, 5, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME, type5##_NAME) \ 137 { \ 143 138 if (loadString != NULL && root != NULL) \ 144 139 { \ … … 202 197 203 198 protected: 204 BaseLoadParam( BaseObject* object, const char* paramName, int paramCount, ...);199 BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, ...); 205 200 206 201 protected: 207 202 LoadClassDescription* classDesc; //!< The LoadClassDescription of this LoadParameter 208 203 LoadParamDescription* paramDesc; //!< The LoadParameterDescription of this LoadParameter 204 const char* loadString; //!< The string loaded by this LoadParam 209 205 }; 210 206 -
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 } -
orxonox/branches/physics/src/util/object_manager.h
r4283 r4301 18 18 #define OM_ 19 19 20 #include "class_list.h" 21 22 20 23 class WorldEntity; 24 class GarbageCollector; 21 25 22 26 23 27 template<class T> class tList; 28 template<class T> class ManagedObject; 24 29 25 30 //! the object manager itself … … 29 34 static ObjectManager* getInstance(void); 30 35 virtual ~ObjectManager(void); 36 37 void cache(classList index, int number, const BaseObject ©Object); 38 void addToDeadList(classList index, BaseObject* object); 39 BaseObject* getFromDeadList(classList index, int number = 1); 31 40 32 void preLoad();41 void debug(); 33 42 34 43 private: … … 36 45 static ObjectManager* singletonRef; 37 46 38 tList<WorldEntity>* projectileBuffer; //!< a list of projectiles that is generated at the beginning to make orx faster 47 //BaseObject** managedObjectList; 48 tList<BaseObject>** managedObjectList; 49 GarbageCollector* garbageCollector; 50 }; 39 51 40 52 41 };42 53 43 54 #endif /* _OBJECT_MANAGER_H */
Note: See TracChangeset
for help on using the changeset viewer.