1 | /*! |
---|
2 | \file object_manager.h |
---|
3 | \brief this manager will ceep track of the objects in the world |
---|
4 | |
---|
5 | This is specially designed to: |
---|
6 | - Give an interface to the world data |
---|
7 | - separate the world data from the world build,update,draw process |
---|
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 | - control the garbage collector |
---|
10 | */ |
---|
11 | |
---|
12 | |
---|
13 | #ifndef _OBJECT_MANAGER_H |
---|
14 | #define _OBJECT_MANAGER_H |
---|
15 | |
---|
16 | #include "base_object.h" |
---|
17 | |
---|
18 | #define OM_ |
---|
19 | |
---|
20 | |
---|
21 | //! list of all classes to be loadable in via the ObjectManager |
---|
22 | typedef enum classList |
---|
23 | { |
---|
24 | CL_PROJECTILE, |
---|
25 | CL_TEST_BULLET, |
---|
26 | |
---|
27 | CL_NUMBER |
---|
28 | }; |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | class WorldEntity; |
---|
35 | class GarbageCollector; |
---|
36 | class Projectile; |
---|
37 | |
---|
38 | template<class T> class tList; |
---|
39 | template<class T> class ManagedObject; |
---|
40 | |
---|
41 | #define mCache( Class ) \ |
---|
42 | cache(classList index, int number, Class * copyObject) |
---|
43 | |
---|
44 | |
---|
45 | |
---|
46 | //! the object manager itself |
---|
47 | class ObjectManager : public BaseObject { |
---|
48 | |
---|
49 | public: |
---|
50 | static ObjectManager* getInstance(void); |
---|
51 | virtual ~ObjectManager(void); |
---|
52 | |
---|
53 | |
---|
54 | void mCache(Projectile); |
---|
55 | |
---|
56 | void addToDeadList(classList index, BaseObject* object); |
---|
57 | BaseObject* getFromDeadList(classList index, int number = 1); |
---|
58 | |
---|
59 | |
---|
60 | |
---|
61 | void debug(); |
---|
62 | |
---|
63 | private: |
---|
64 | ObjectManager(void); |
---|
65 | //void cache(classList index, int number, Projectile* copyObject); |
---|
66 | |
---|
67 | static ObjectManager* singletonRef; |
---|
68 | |
---|
69 | //BaseObject** managedObjectList; |
---|
70 | tList<BaseObject>** managedObjectList; |
---|
71 | GarbageCollector* garbageCollector; |
---|
72 | }; |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | #endif /* _OBJECT_MANAGER_H */ |
---|