Orxonox
0.0.5 Codename: Arcturus
|
Classes must inherit from this class if they should be used with StrongPtr or WeakPtr. More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/object/Destroyable.h>
Public Member Functions | |
Destroyable () | |
Constructor: Sets the default values. More... | |
virtual | ~Destroyable () |
Destructor: Notifies all DestructionListener (for example weak pointers) that this object is being deleted. More... | |
void | destroy () |
Deletes the object if no strong pointers point to this object. More... | |
void | destroyLater () |
Works like destroy() but doesn't destroy the object until the current tick has ended. More... | |
unsigned int | getReferenceCount () const |
Returns the number of strong pointers that point to this object. More... | |
Protected Member Functions | |
virtual void | preDestroy () |
This virtual function is called if destroy() is called and no StrongPtr points to this object. More... | |
Private Member Functions | |
void | decrementReferenceCount () |
Decrements the reference counter (for strong pointers). More... | |
void | incrementReferenceCount () |
Increments the reference counter (for strong pointers). More... | |
void | registerDestructionListener (DestructionListener *pointer) |
Register a destruction listener (for example a weak pointer which points to this object). More... | |
void | unregisterDestructionListener (DestructionListener *pointer) |
Unegister a destruction listener (for example a weak pointer which pointed to this object before). More... | |
Private Attributes | |
std::set< DestructionListener * > | destructionListeners_ |
All destruction listeners (for example weak pointers which point to this object and like to get notified if it dies) More... | |
int | referenceCount_ |
Counts the references from strong pointers to this object. More... | |
bool | requestedDestruction_ |
Becomes true after someone called delete on this object. More... | |
Friends | |
class | DestructionListener |
template<class T > | |
class | StrongPtr |
orxonox::Destroyable::Destroyable | ( | ) |
Constructor: Sets the default values.
|
virtual |
Destructor: Notifies all DestructionListener (for example weak pointers) that this object is being deleted.
|
inlineprivate |
Decrements the reference counter (for strong pointers).
Deletes the object if no strong pointers point to this object.
Otherwise schedules the object to be deleted as soon as possible. Always call destroy() instead of using 'delete' directly, otherwise strong pointers won't work.
void orxonox::Destroyable::destroyLater | ( | ) |
Works like destroy() but doesn't destroy the object until the current tick has ended.
|
inline |
Returns the number of strong pointers that point to this object.
|
inlineprivate |
Increments the reference counter (for strong pointers).
This virtual function is called if destroy() is called and no StrongPtr points to this object.
Used in some cases to create a new StrongPtr to prevent destruction. Don't call this function directly - use destroy() instead.
Reimplemented in orxonox::Pawn, orxonox::ControllableEntity, orxonox::Pickupable, orxonox::NotificationManager, orxonox::PickupCarrier, and orxonox::AmbientSound.
|
inlineprivate |
Register a destruction listener (for example a weak pointer which points to this object).
|
inlineprivate |
Unegister a destruction listener (for example a weak pointer which pointed to this object before).
|
friend |
|
friend |
|
private |
All destruction listeners (for example weak pointers which point to this object and like to get notified if it dies)
|
private |
Counts the references from strong pointers to this object.
|
private |
Becomes true after someone called delete on this object.