Changeset 4332 in orxonox.OLD for orxonox/branches/physics/src/util
- Timestamp:
- May 27, 2005, 7:14:55 PM (20 years ago)
- Location:
- orxonox/branches/physics/src/util
- Files:
-
- 9 edited
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/util/animation/animation_player.cc
r3953 r4332 28 28 AnimationPlayer::AnimationPlayer () 29 29 { 30 this->setClass Name ("AnimationPlayer");30 this->setClassID(CL_ANIMATION_PLAYER, "AnimationPlayer"); 31 31 32 32 this->animationList = new tList<Animation>(); -
orxonox/branches/physics/src/util/garbage_collector.cc
r4301 r4332 38 38 GarbageCollector::GarbageCollector () 39 39 { 40 this->setClass Name ("GarbageCollection");40 this->setClassID(CL_GARBAGE_COLLECTOR, "GarbageCollector"); 41 41 this->time = 0; 42 42 this->delay = 1.5f; /* clean up all 5.0 seconds */ … … 139 139 /* then finaly delete reference */ 140 140 //delete entity; 141 ObjectManager::getInstance()->addToDeadList(CL_TEST_BULLET, entity); 142 ObjectManager::getInstance()->debug(); 141 ObjectManager::getInstance()->addToDeadList(entity->getClassID(), entity); 143 142 } 144 143 entity = iterator->nextElement(); … … 148 147 PRINTF(3)("=============================\n"); 149 148 149 ObjectManager::getInstance()->debug(); 150 150 151 /* reset time to count again up to this->delay */ 151 152 this->time = 0; -
orxonox/branches/physics/src/util/loading/game_loader.cc
r4283 r4332 82 82 delete campaignName; 83 83 } 84 World* world0 = new World(DEBUG_WORLD_0); 85 world0->setNextStoryID(WORLD_ID_GAMEEND); 86 this->currentCampaign->addEntity(world0, WORLD_ID_2); 84 87 } 85 88 -
orxonox/branches/physics/src/util/loading/load_param.h
r4301 r4332 180 180 static LoadClassDescription* addClass(const char* className); 181 181 LoadParamDescription* addParam(const char* paramName); 182 182 183 183 184 static void printAll(const char* fileName = NULL); -
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 -
orxonox/branches/physics/src/util/object_manager.h
r4301 r4332 8 8 - recycle deleted objects: specific for Projectils since there is a lot of world entity creation/deletion (and this needs a lot of time) 9 9 - control the garbage collector 10 11 TO ADD SUPPORT FOR A CLASS do the following steps: 12 1. include the hader file : #include "class_header.h" 13 2. add the class to the type enum classList {}; in class_list.h 14 3. define a function void mCache( ClassName ) in class ObjectManager 15 10 16 */ 11 17 … … 15 21 16 22 #include "base_object.h" 17 18 # define OM_23 #include "projectile.h" 24 #include "list.h" 19 25 20 26 #include "class_list.h" 21 27 22 28 23 29 class WorldEntity; … … 25 31 26 32 27 template<class T> class tList; 28 template<class T> class ManagedObject; 33 //! This defines the "template" makro function for cache(...) 34 #define mCache( Class ) \ 35 cache(classList index, int number, Class * copyObject) \ 36 { \ 37 this->managedObjectList[index] = new tList<BaseObject>(); \ 38 for(int i = 0; i < number; ++i)\ 39 {\ 40 this->managedObjectList[index]->add(new Class (*copyObject));\ 41 }\ 42 } 43 44 29 45 30 46 //! the object manager itself … … 35 51 virtual ~ObjectManager(void); 36 52 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);53 void mCache(Projectile); 54 void addToDeadList(int index, BaseObject* object); 55 BaseObject* getFromDeadList(int index, int number = 1); 40 56 41 57 void debug(); … … 43 59 private: 44 60 ObjectManager(void); 61 45 62 static ObjectManager* singletonRef; 46 63 47 //BaseObject** managedObjectList;48 64 tList<BaseObject>** managedObjectList; 49 65 GarbageCollector* garbageCollector; -
orxonox/branches/physics/src/util/resource_manager.cc
r4295 r4332 38 38 ResourceManager::ResourceManager () 39 39 { 40 this->setClass Name ("ResourceManager");40 this->setClassID(CL_RESOURCE_MANAGER, "ResourceManager"); 41 41 this->dataDir = NULL; 42 42 this->setDataDir("./"); -
orxonox/branches/physics/src/util/track/track_manager.cc
r4283 r4332 370 370 TrackManager::TrackManager(void) 371 371 { 372 this->setClass Name("TrackManager");372 this->setClassID(CL_TRACK_MANAGER, "TrackManager"); 373 373 374 374 TrackManager::singletonRef = this; // do this because otherwise the TrackNode cannot get The instance of the TrackManager -
orxonox/branches/physics/src/util/track/track_node.cc
r4283 r4332 32 32 TrackNode::TrackNode () 33 33 { 34 this->setClass Name("TrackNode");34 this->setClassID(CL_TRACK_NODE, "TrackNode"); 35 35 this->setName("TrackNode"); /* absolete but still used... */ 36 36
Note: See TracChangeset
for help on using the changeset viewer.