dune-fem  2.4.1-rc
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Dune::Fem::ReferenceCounterDefault< RCT > Class Template Reference

default implementation of ReferenceCounterInterface More...

#include </local/tomalk/somewhere/tmp/dune-fem/dune/fem/storage/referencecounter.hh>

Inheritance diagram for Dune::Fem::ReferenceCounterDefault< RCT >:
Inheritance graph

Public Types

typedef BaseType::ReferenceCounterType ReferenceCounterType
 type of the implementation (Barton-Nackman) More...
 
typedef RCT Traits
 type of the traits 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

 ReferenceCounterDefault (unsigned int refcount=1)
 constructor initializing the reference counter More...
 
void addReference () const
 :: ReferenceCounterInterface :: addReference More...
 
void deleteObject ()
 :: ReferenceCounterInterface :: deleteObject More...
 
void removeReference () const
 :: ReferenceCounterInterface :: removeReference More...
 
unsigned int referenceCounter () const
 return current reference count More...
 
const ObjectTypegetObject () const
 access the real object (const version) More...
 
ObjectTypegetObject ()
 access the real object (non-const version) 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)
 

Protected Attributes

unsigned int refcount_
 

Detailed Description

template<class RCT>
class Dune::Fem::ReferenceCounterDefault< RCT >

default implementation of ReferenceCounterInterface

Reference counting usually uses a class variable to hold the number of references to the instance. To make reference counting simple to use, this mechanism is default implemented.

Note
The deleteObject method is used to delete the object when the reference counter reaches zero. To perform any action other than deleting the object, simply overwrite this method.

Member Typedef Documentation

template<class RCT>
typedef Traits::ObjectType Dune::Fem::ReferenceCounterInterface< RCT >::ObjectType
inherited

type of the object, this is a reference counter for

template<class RCT>
typedef ThisType Dune::Fem::ReferenceCounterInterface< RCT >::ReferenceCounterInterfaceType
inherited

type of the reference counter interface

template<class RCT>
typedef BaseType::ReferenceCounterType Dune::Fem::ReferenceCounterDefault< RCT >::ReferenceCounterType

type of the implementation (Barton-Nackman)

template<class RCT>
typedef RCT Dune::Fem::ReferenceCounterInterface< RCT >::Traits
inherited

type of the traits

Constructor & Destructor Documentation

template<class RCT>
Dune::Fem::ReferenceCounterDefault< RCT >::ReferenceCounterDefault ( unsigned int  refcount = 1)
inlineexplicit

constructor initializing the reference counter

Note
Since we want to be able to count referenced to stack objects, we initialize the reference counter to 1 by default. This means that after calling new we already have one reference to the object. In such cases, just call removeReference directly when the reference is no longer used (instead of simply deleting it).
Parameters
[in]refcountstart value for the reference counter; this value defalts to 1

Member Function Documentation

template<class RCT>
void Dune::Fem::ReferenceCounterDefault< RCT >::addReference ( ) const
inline

:: ReferenceCounterInterface :: addReference

:: ReferenceCounterInterface :: addReference

static const RCT::ReferenceCounterType & Dune::Fem::BartonNackmanInterface< ReferenceCounterInterface< RCT > , RCT::ReferenceCounterType >::asImp ( const ThisType other)
inlinestaticprotectedinherited
static RCT::ReferenceCounterType & Dune::Fem::BartonNackmanInterface< ReferenceCounterInterface< RCT > , RCT::ReferenceCounterType >::asImp ( ThisType other)
inlinestaticprotectedinherited
const RCT::ReferenceCounterType & Dune::Fem::BartonNackmanInterface< ReferenceCounterInterface< RCT > , RCT::ReferenceCounterType >::asImp ( ) const
inlineprotectedinherited
RCT::ReferenceCounterType & Dune::Fem::BartonNackmanInterface< ReferenceCounterInterface< RCT > , RCT::ReferenceCounterType >::asImp ( )
inlineprotectedinherited
template<class RCT>
void Dune::Fem::ReferenceCounterDefault< RCT >::deleteObject ( )
inline

:: ReferenceCounterInterface :: deleteObject

:: ReferenceCounterInterface :: deleteObject

template<class RCT>
const ObjectType& Dune::Fem::ReferenceCounterInterface< RCT >::getObject ( ) const
inlineinherited

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.

Returns
a constant reference to the real object

Referenced by Dune::Fem::ReferenceCounterInterface< ObjectStackEntryTraits< ObjectFactoryImp > >::getObject().

template<class RCT>
ObjectType& Dune::Fem::ReferenceCounterInterface< RCT >::getObject ( )
inlineinherited

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.

Returns
a reference to the real object
template<class RCT>
unsigned int Dune::Fem::ReferenceCounterDefault< RCT >::referenceCounter ( ) const
inline

return current reference count

template<class RCT>
void Dune::Fem::ReferenceCounterDefault< RCT >::removeReference ( ) const
inline

:: ReferenceCounterInterface :: removeReference

:: ReferenceCounterInterface :: removeReference

Member Data Documentation

template<class RCT>
unsigned int Dune::Fem::ReferenceCounterDefault< RCT >::refcount_
mutableprotected

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