dune-fem 2.8.0
|
interface for objects capable of reference counting More...
#include <dune/fem/storage/referencecounter.hh>
Public Types | |
typedef RCT | Traits |
type of the traits | |
typedef Traits::ReferenceCounterType | ReferenceCounterType |
type of the implementation (Barton-Nackman) | |
typedef ThisType | ReferenceCounterInterfaceType |
type of the reference counter interface | |
typedef Traits::ObjectType | ObjectType |
type of the object, this is a reference counter for | |
Public Member Functions | |
void | addReference () const |
add a reference to this object | |
void | deleteObject () |
delete to object | |
const ObjectType & | getObject () const |
access the real object (const version) | |
ObjectType & | getObject () |
access the real object (non-const version) | |
void | removeReference () const |
remove a reference to this object | |
Protected Member Functions | |
const Implementation & | asImp () const |
Implementation & | asImp () |
Static Protected Member Functions | |
static const Implementation & | asImp (const ThisType &other) |
static Implementation & | asImp (ThisType &other) |
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)
|
inlineprotected |
|
inlineprotected |
|
inlinestaticprotectedinherited |
|
inlinestaticprotected |
|
inlinestaticprotectedinherited |
|
inlinestaticprotected |
|
inline |
delete to object
This method is used by the default implementation to free the object when the reference counter becomes zero.
|
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 |
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.
|
inline |
remove a reference to this object
This method should be called whenever a previously added reference to this object is released.