dune-fem
2.4.1-rc
|
interface for objects capable of reference counting More...
#include </local/tomalk/somewhere/tmp/dune-fem/dune/fem/storage/referencecounter.hh>
Public Types | |
typedef RCT | Traits |
type of the traits More... | |
typedef Traits::ReferenceCounterType | ReferenceCounterType |
type of the implementation (Barton-Nackman) More... | |
typedef ThisType | ReferenceCounterInterfaceType |
type of the reference counter interface More... | |
typedef Traits::ObjectType | ObjectType |
type of the object, this is a reference counter for More... | |
Public Member Functions | |
void | addReference () const |
add a reference to this object More... | |
void | deleteObject () |
delete to object More... | |
const ObjectType & | getObject () const |
access the real object (const version) More... | |
ObjectType & | getObject () |
access the real object (non-const version) More... | |
void | removeReference () const |
remove a reference to this object More... | |
Protected Member Functions | |
const RCT::ReferenceCounterType & | asImp () const |
RCT::ReferenceCounterType & | asImp () |
Static Protected Member Functions | |
static const RCT::ReferenceCounterType & | asImp (const ThisType &other) |
static RCT::ReferenceCounterType & | asImp (ThisType &other) |
interface for objects capable of reference counting
In many situations it has to be decided, whether an object is still required or must be freed. A simple approach to this decision is to count all references to an object. When the last reference is released, the object is freed.
The ReferenceCounterInterface provides methods, an object needs to support reference counting. Classes implementing this interface can be used with ObjectReference and ObjectPointer. Both will implicitly call addReference when they start pointing to an object and removeReference when they stop pointing to it.
typedef Traits::ObjectType Dune::Fem::ReferenceCounterInterface< RCT >::ObjectType |
type of the object, this is a reference counter for
typedef ThisType Dune::Fem::ReferenceCounterInterface< RCT >::ReferenceCounterInterfaceType |
type of the reference counter interface
typedef Traits::ReferenceCounterType Dune::Fem::ReferenceCounterInterface< RCT >::ReferenceCounterType |
type of the implementation (Barton-Nackman)
typedef RCT Dune::Fem::ReferenceCounterInterface< RCT >::Traits |
type of the traits
|
inline |
add a reference to this object
This method should be called whenever a permanent reference to this object is established (a pointer counts as a reference, too)
Referenced by Dune::Fem::ReferenceCounterInterface< ObjectStackEntryTraits< ObjectFactoryImp > >::addReference().
|
inlinestaticprotectedinherited |
|
inlinestaticprotectedinherited |
|
inlineprotectedinherited |
Referenced by Dune::Fem::ReferenceCounterInterface< ObjectStackEntryTraits< ObjectFactoryImp > >::addReference(), Dune::Fem::ReferenceCounterInterface< ObjectStackEntryTraits< ObjectFactoryImp > >::deleteObject(), Dune::Fem::ReferenceCounterInterface< ObjectStackEntryTraits< ObjectFactoryImp > >::getObject(), Dune::Fem::ReferenceCounterInterface< ObjectStackEntryTraits< ObjectFactoryImp > >::removeReference(), and Dune::Fem::ReferenceCounterDefault< ObjectStackEntryTraits< ObjectFactoryImp > >::removeReference().
|
inlineprotectedinherited |
|
inline |
delete to object
This method is used by the default implementation to free the object when the reference counter becomes zero.
Referenced by Dune::Fem::ReferenceCounterInterface< ObjectStackEntryTraits< ObjectFactoryImp > >::deleteObject(), and Dune::Fem::ReferenceCounterDefault< ObjectStackEntryTraits< ObjectFactoryImp > >::removeReference().
|
inline |
access the real object (const version)
Sometimes the reference counter just wraps the object for which it counts references. In such cases, this method returns the wrapped object. Otherwise, the object itself may be returned.
Referenced by Dune::Fem::ReferenceCounterInterface< ObjectStackEntryTraits< ObjectFactoryImp > >::getObject().
|
inline |
access the real object (non-const version)
Sometimes the reference counter just wraps the object for which it counts references. In such cases, this method returns the wrapped object. Otherwise, the object itself may be returned.
|
inline |
remove a reference to this object
This method should be called whenever a previously added reference to this object is released.
Referenced by Dune::Fem::ReferenceCounterInterface< ObjectStackEntryTraits< ObjectFactoryImp > >::removeReference().