/*! * @file garbage_collector.h */ #ifndef _GARBAGE_COLLECTOR_H #define _GARBAGE_COLLECTOR_H #include "base_object.h" #include "fast_factory.h" //! this class maintains the garbage collection. /** * you can pass everything to this class that you want to be collected * just use GarbageCollector->collect(POINTER); to pass a collectable to the GarbageCollector * it will then be handled acording to the class */ class GarbageCollector : public BaseObject { public: virtual ~GarbageCollector(); /** @returns a Pointer to the only object of this Class */ inline static GarbageCollector* getInstance() { if (!singletonRef) singletonRef = new GarbageCollector(); return singletonRef; }; void setCollectionDelay(float delay); void forceCollection(); void collect(BaseObject* object); void tick(float time); void update(); private: GarbageCollector(); private: static GarbageCollector* singletonRef; //!< The reference to this class (singleton) FastObjectMember* collectedObjects; //!< A list of recently collected Objects, that want to be deleted. FastObjectMember* unusedContainers; //!< A list of unused containers. float delay; //!< this is the delay to wait until collection. float time; //!< the current time }; #endif /* _GARBAGE_COLLECTOR_H */