/*! \file object_manager.h \brief this manager will ceep track of the objects in the world This is specially designed to: - Give an interface to the world data - separate the world data from the world build,update,draw process - recycle deleted objects: specific for Projectils since there is a lot of world entity creation/deletion (and this needs a lot of time) - control the garbage collector TO ADD SUPPORT FOR A CLASS do the following steps: 1. include the hader file : #include "class_header.h" 2. add the class to the type enum classList {}; in class_list.h 3. define a function void mCache( ClassName ) in class ObjectManager */ #ifndef _OBJECT_MANAGER_H #define _OBJECT_MANAGER_H #include "base_object.h" #include "projectile.h" #include "list.h" #include "class_list.h" class WorldEntity; class GarbageCollector; //! This defines the "template" makro function for cache(...) #define mCache( Class ) \ cache(classList index, int number, Class * copyObject) \ { \ this->managedObjectList[index] = new tList(); \ for(int i = 0; i < number; ++i)\ {\ this->managedObjectList[index]->add(new Class (*copyObject));\ }\ } //! the object manager itself class ObjectManager : public BaseObject { public: static ObjectManager* getInstance(void); virtual ~ObjectManager(void); void mCache(Projectile); void addToDeadList(classList index, BaseObject* object); BaseObject* getFromDeadList(classList index, int number = 1); void debug(); private: ObjectManager(void); static ObjectManager* singletonRef; tList** managedObjectList; GarbageCollector* garbageCollector; }; #endif /* _OBJECT_MANAGER_H */