1 | /*! |
---|
2 | * @file garbage_collector.h |
---|
3 | * Definition of the proto class template, used quickly start work |
---|
4 | * @todo Example: this shows how to use simply add a Marker that here has to be done something. |
---|
5 | * |
---|
6 | * The Protoclass exists, to help you quikly getting the run for how to develop in orxonox. |
---|
7 | * It is an example for the CODING-CONVENTION, and a starting-point for every class. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef _GARBAGE_COLLECTOR_H |
---|
11 | #define _GARBAGE_COLLECTOR_H |
---|
12 | |
---|
13 | #include "base_object.h" |
---|
14 | |
---|
15 | #include "fast_factory.h" |
---|
16 | |
---|
17 | //! this class maintains the garbage collection. |
---|
18 | /** |
---|
19 | the class is been ticked by the world.cc and goes through the |
---|
20 | world_entity list to clean out all unused entities. |
---|
21 | */ |
---|
22 | class GarbageCollector : public BaseObject { |
---|
23 | |
---|
24 | public: |
---|
25 | virtual ~GarbageCollector(); |
---|
26 | /** @returns a Pointer to the only object of this Class */ |
---|
27 | inline static GarbageCollector* getInstance() { if (!singletonRef) singletonRef = new GarbageCollector(); return singletonRef; }; |
---|
28 | |
---|
29 | void setCollectionDelay(float delay); |
---|
30 | |
---|
31 | void forceCollection(); |
---|
32 | |
---|
33 | void collect(BaseObject* object); |
---|
34 | |
---|
35 | void tick(float time); |
---|
36 | void update(); |
---|
37 | |
---|
38 | private: |
---|
39 | GarbageCollector(); |
---|
40 | |
---|
41 | private: |
---|
42 | static GarbageCollector* singletonRef; //!< The reference to this class (singleton) |
---|
43 | |
---|
44 | FastObjectMember* collectedObjects; //!< A list of recently collected Objects, that want to be deleted. |
---|
45 | FastObjectMember* unusedContainers; //!< A list of unused containers. |
---|
46 | float delay; //!< this is the delay to wait until collection. |
---|
47 | float time; //!< the current time |
---|
48 | |
---|
49 | }; |
---|
50 | |
---|
51 | #endif /* _GARBAGE_COLLECTOR_H */ |
---|