Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
orxonox::Destroyable Class Reference

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>

Inheritance diagram for orxonox::Destroyable:
orxonox::Identifier orxonox::OrxonoxClass orxonox::OrxonoxInterface orxonox::PluginReference orxonox::ClassIdentifier< T > orxonox::BaseObject orxonox::BasicProjectile orxonox::GametypeMessageListener orxonox::GSLevelMemento orxonox::LevelInfoItem orxonox::MoodListener orxonox::NotificationListener orxonox::Pickupable orxonox::PickupCarrier orxonox::PickupListener orxonox::PlayerTrigger orxonox::RadarListener orxonox::RadarViewable orxonox::Rewardable orxonox::Synchronisable orxonox::TeamColourable orxonox::Tickable

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
 

Detailed Description

Classes must inherit from this class if they should be used with StrongPtr or WeakPtr.

Constructor & Destructor Documentation

orxonox::Destroyable::Destroyable ( )

Constructor: Sets the default values.

orxonox::Destroyable::~Destroyable ( )
virtual

Destructor: Notifies all DestructionListener (for example weak pointers) that this object is being deleted.

Member Function Documentation

void orxonox::Destroyable::decrementReferenceCount ( )
inlineprivate

Decrements the reference counter (for strong pointers).

void orxonox::Destroyable::destroy ( void  )

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.

unsigned int orxonox::Destroyable::getReferenceCount ( ) const
inline

Returns the number of strong pointers that point to this object.

void orxonox::Destroyable::incrementReferenceCount ( )
inlineprivate

Increments the reference counter (for strong pointers).

virtual void orxonox::Destroyable::preDestroy ( void  )
inlineprotectedvirtual

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.

void orxonox::Destroyable::registerDestructionListener ( DestructionListener pointer)
inlineprivate

Register a destruction listener (for example a weak pointer which points to this object).

void orxonox::Destroyable::unregisterDestructionListener ( DestructionListener pointer)
inlineprivate

Unegister a destruction listener (for example a weak pointer which pointed to this object before).

Friends And Related Function Documentation

friend class DestructionListener
friend
template<class T >
friend class StrongPtr
friend

Member Data Documentation

std::set<DestructionListener*> orxonox::Destroyable::destructionListeners_
private

All destruction listeners (for example weak pointers which point to this object and like to get notified if it dies)

int orxonox::Destroyable::referenceCount_
private

Counts the references from strong pointers to this object.

bool orxonox::Destroyable::requestedDestruction_
private

Becomes true after someone called delete on this object.


The documentation for this class was generated from the following files: