|
Last change
on this file since 5161 was
4979,
checked in by bensch, 20 years ago
|
|
orxonox/trunk: Objects now get cleanly ereased.
This is a fix in the Weapon-class, that kills the Resurected Projectiles created for information-gathering
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | /*! |
|---|
| 2 | * @file garbage_collector.h |
|---|
| 3 | */ |
|---|
| 4 | |
|---|
| 5 | #ifndef _GARBAGE_COLLECTOR_H |
|---|
| 6 | #define _GARBAGE_COLLECTOR_H |
|---|
| 7 | |
|---|
| 8 | #include "base_object.h" |
|---|
| 9 | |
|---|
| 10 | #include "fast_factory.h" |
|---|
| 11 | |
|---|
| 12 | //! this class maintains the garbage collection. |
|---|
| 13 | /** |
|---|
| 14 | * you can pass everything to this class that you want to be collected |
|---|
| 15 | * just use GarbageCollector->collect(POINTER); to pass a collectable to the GarbageCollector |
|---|
| 16 | * it will then be handled acording to the class |
|---|
| 17 | */ |
|---|
| 18 | class GarbageCollector : public BaseObject { |
|---|
| 19 | |
|---|
| 20 | public: |
|---|
| 21 | virtual ~GarbageCollector(); |
|---|
| 22 | /** @returns a Pointer to the only object of this Class */ |
|---|
| 23 | inline static GarbageCollector* getInstance() { if (!singletonRef) singletonRef = new GarbageCollector(); return singletonRef; }; |
|---|
| 24 | |
|---|
| 25 | void setCollectionDelay(float delay); |
|---|
| 26 | |
|---|
| 27 | void forceCollection(); |
|---|
| 28 | |
|---|
| 29 | void collect(BaseObject* object); |
|---|
| 30 | |
|---|
| 31 | void tick(float time); |
|---|
| 32 | void update(); |
|---|
| 33 | |
|---|
| 34 | private: |
|---|
| 35 | GarbageCollector(); |
|---|
| 36 | |
|---|
| 37 | private: |
|---|
| 38 | static GarbageCollector* singletonRef; //!< The reference to this class (singleton) |
|---|
| 39 | |
|---|
| 40 | FastObjectMember* collectedObjects; //!< A list of recently collected Objects, that want to be deleted. |
|---|
| 41 | FastObjectMember* unusedContainers; //!< A list of unused containers. |
|---|
| 42 | float delay; //!< this is the delay to wait until collection. |
|---|
| 43 | float time; //!< the current time |
|---|
| 44 | |
|---|
| 45 | }; |
|---|
| 46 | |
|---|
| 47 | #endif /* _GARBAGE_COLLECTOR_H */ |
|---|
Note: See
TracBrowser
for help on using the repository browser.