Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/util/object_manager.h @ 4696

Last change on this file since 4696 was 4591, checked in by bensch, 19 years ago

orxonox/trunk: restructure class_list.h so it supports inheritance-diagram

File size: 2.2 KB
Line 
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    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
16*/
17
18
19#ifndef _OBJECT_MANAGER_H
20#define _OBJECT_MANAGER_H
21
22#include "base_object.h"
23#include "projectile.h"
24#include "list.h"
25
26#include "class_list.h"
27
28
29class WorldEntity;
30class GarbageCollector;
31
32
33//! This defines the "template" macro function for cache(...)
34#define mCache( Class ) \
35 cache(ClassID 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
45
46//! the object manager itself
47class ObjectManager : public BaseObject {
48
49 public:
50  virtual ~ObjectManager(void);
51  /** \returns a Pointer to the only object of this Class */
52  inline static ObjectManager* getInstance(void) { if (!singletonRef) singletonRef = new ObjectManager();  return singletonRef; };
53
54  /** a class handled by the objectManage */
55  void mCache(Projectile);
56  void addToDeadList(int index, BaseObject* object);
57  BaseObject* getFromDeadList(int index, int number = 1);
58
59  void debug(void) const;
60
61 private:
62  ObjectManager(void);
63
64 private:
65  static ObjectManager*      singletonRef;          //!< The singleton reference to the only reference of this class
66
67  tList<BaseObject>**        managedObjectList;     //!< A list of managed objects (handles different types and lists of them)
68  GarbageCollector*          garbageCollector;      //!< reference to the GrabageCollector
69};
70
71
72
73#endif /* _OBJECT_MANAGER_H */
Note: See TracBrowser for help on using the repository browser.