FX::FXRefedObject< intType, lastUsed, referrersPolicy > Class Template Reference

#include <FXRefedObject.h>

Inheritance diagram for FX::FXRefedObject< intType, lastUsed, referrersPolicy >:

FX::FXRefedObjectImpl::countHolder< intType > List of all members.

Detailed Description

template<typename intType, class lastUsed = Pol::None0, class referrersPolicy = Pol::unknownReferrers>
class FX::FXRefedObject< intType, lastUsed, referrersPolicy >

The parent class of something which is reference counted.

Parameters:
intType The type of the container maintaining the reference count. Usually int or FX::FXAtomicInt
lastUsed Can be FX::Pol::hasLastUsed
referrersPolicy Either FX::Pol::unknownReferrers or FX::Pol::knowReferrers
This is the base class for something which is reference counted - when the count reaches zero, the virtual method noMoreReferrers() is called which by default calls delete this. You of course should override this with anything you like. noMoreReferrers() will never be called more than once and once it has been called, even if the object is not deleted all attempts to open a new reference upon it will return a null reference. If you don't want this, specialise FX::FXRefedObjectImpl::countHolder (see the header file).

You can temporarily disable the reference counting mechanism by instantiating a FX::FXRefedObject_DisableCount. This is useful during refed object initialisation where it may end up temporarily opening a reference on itself, thus causing deletion of itself during construction as no other reference exists yet.

A specialisation exists for FX::FXAtomicInt which implements an atomic reference count (despite not actually using FX::FXAtomicInt directly to do it).

See also:
FX::FXRefingObject

Definition at line 257 of file FXRefedObject.h.

Public Member Functions

 FXRefedObject ()
virtual ~FXRefedObject ()
 FXRefedObject (const FXRefedObject &o)
const intType & refCount () const throw ()
void resetDying () throw ()

Protected Member Functions

virtual void noMoreReferrers ()
bool int_increfcount ()
bool int_decrefcount ()

Friends

class FXRefingObjectImpl::refedObject
struct FXRefingObjectImpl::dataHolderI
class FXRefedObject_DisableCount


The documentation for this class was generated from the following file:
(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:35:54 2009 for TnFOX by doxygen v1.4.7