/*! \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" macro 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); /** a class handled by the objectManage */ void mCache(Projectile); void addToDeadList(int index, BaseObject* object); BaseObject* getFromDeadList(int index, int number = 1); void debug(void) const; private: ObjectManager(void); private: static ObjectManager* singletonRef; //!< The singleton reference to the only reference of this class tList** managedObjectList; //!< A list of managed objects (handles different types and lists of them) GarbageCollector* garbageCollector; //!< reference to the GrabageCollector }; #endif /* _OBJECT_MANAGER_H */