Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4480 was 4322, checked in by patrick, 20 years ago

now the objectmanagment works smoothly with the garbage collection: shoots (projectiles) are now precached (100 pieces) used from this pool and recyled :)

File size: 1.8 KB
RevLine 
[4245]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
[4313]10
11    TO ADD SUPPORT FOR A CLASS do the following steps:
12    1. include the hader file : #include "class_header.h"
[4315]13    2. add the class to the type enum classList {}; in class_list.h
[4313]14    3. define a function void mCache( ClassName ) in class ObjectManager
15
[4245]16*/
17
18
19#ifndef _OBJECT_MANAGER_H
20#define _OBJECT_MANAGER_H
21
22#include "base_object.h"
[4312]23#include "projectile.h"
24#include "list.h"
[4245]25
[4315]26#include "class_list.h"
[4311]27 
28
[4288]29class WorldEntity;
30class GarbageCollector;
[4285]31
[4312]32
[4313]33//! This defines the "template" makro function for cache(...)
[4311]34#define mCache( Class ) \
[4312]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}
[4311]43
44
45
[4245]46//! the object manager itself
47class ObjectManager : public BaseObject {
48
49 public:
50  static ObjectManager* getInstance(void);
51  virtual ~ObjectManager(void);
[4285]52 
[4311]53  void mCache(Projectile);
[4322]54  void addToDeadList(int index, BaseObject* object);
55  BaseObject* getFromDeadList(int index, int number = 1);
[4245]56
[4287]57  void debug();
58
[4245]59 private:
60  ObjectManager(void);
[4311]61
[4245]62  static ObjectManager* singletonRef;
63
[4286]64  tList<BaseObject>** managedObjectList;
[4288]65  GarbageCollector* garbageCollector;
[4285]66};
[4245]67
68
69
70#endif /* _OBJECT_MANAGER_H */
Note: See TracBrowser for help on using the repository browser.