dune-fem 2.8.0
Loading...
Searching...
No Matches
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 <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)
 
typedef RCT Traits
 type of the traits
 
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

 ReferenceCounterDefault (unsigned int refcount=1)
 constructor initializing the reference counter
 
 ReferenceCounterDefault (const ThisType &)=delete
 
ThisTypeoperator= (const ThisType &)=delete
 
void addReference () const
 :: ReferenceCounterInterface :: addReference
 
void deleteObject ()
 :: ReferenceCounterInterface :: deleteObject
 
void removeReference () const
 :: ReferenceCounterInterface :: removeReference
 
unsigned int referenceCounter () const
 return current reference count
 
const ObjectTypegetObject () const
 access the real object (const version)
 
ObjectTypegetObject ()
 access the real object (non-const version)
 

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 Implementation & asImp (const ThisType &other)
 
static Implementation & asImp (ThisType &other)
 
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

◆ ObjectType

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

type of the object, this is a reference counter for

◆ ReferenceCounterInterfaceType

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

type of the reference counter interface

◆ ReferenceCounterType

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

type of the implementation (Barton-Nackman)

◆ Traits

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

type of the traits

Constructor & Destructor Documentation

◆ ReferenceCounterDefault() [1/2]

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

◆ ReferenceCounterDefault() [2/2]

template<class RCT >
Dune::Fem::ReferenceCounterDefault< RCT >::ReferenceCounterDefault ( const ThisType )
delete

Member Function Documentation

◆ addReference()

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

:: ReferenceCounterInterface :: addReference

:: ReferenceCounterInterface :: addReference

◆ asImp() [1/8]

template<class RCT >
Implementation & Dune::Fem::BartonNackmanInterface< Interface, Implementation >::asImp ( )
inlineprotected

◆ asImp() [2/8]

template<class RCT >
const Implementation & Dune::Fem::BartonNackmanInterface< Interface, Implementation >::asImp ( ) const
inlineprotected

◆ asImp() [3/8]

static const RCT::ReferenceCounterType & Dune::Fem::BartonNackmanInterface< ReferenceCounterInterface< RCT > , RCT::ReferenceCounterType >::asImp ( const ThisType other)
inlinestaticprotectedinherited

◆ asImp() [4/8]

template<class RCT >
static const Implementation & Dune::Fem::BartonNackmanInterface< Interface, Implementation >::asImp ( const ThisType other)
inlinestaticprotectedinherited

◆ asImp() [5/8]

template<class RCT >
static const Implementation & Dune::Fem::BartonNackmanInterface< Interface, Implementation >::asImp ( const ThisType other)
inlinestaticprotected

◆ asImp() [6/8]

static RCT::ReferenceCounterType & Dune::Fem::BartonNackmanInterface< ReferenceCounterInterface< RCT > , RCT::ReferenceCounterType >::asImp ( ThisType other)
inlinestaticprotectedinherited

◆ asImp() [7/8]

template<class RCT >
static Implementation & Dune::Fem::BartonNackmanInterface< Interface, Implementation >::asImp ( ThisType other)
inlinestaticprotectedinherited

◆ asImp() [8/8]

template<class RCT >
static Implementation & Dune::Fem::BartonNackmanInterface< Interface, Implementation >::asImp ( ThisType other)
inlinestaticprotected

◆ deleteObject()

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

:: ReferenceCounterInterface :: deleteObject

:: ReferenceCounterInterface :: deleteObject

◆ getObject() [1/2]

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

◆ getObject() [2/2]

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

◆ operator=()

template<class RCT >
ThisType & Dune::Fem::ReferenceCounterDefault< RCT >::operator= ( const ThisType )
delete

◆ referenceCounter()

template<class RCT >
unsigned int Dune::Fem::ReferenceCounterDefault< RCT >::referenceCounter ( ) const
inline

return current reference count

◆ removeReference()

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

:: ReferenceCounterInterface :: removeReference

:: ReferenceCounterInterface :: removeReference

Member Data Documentation

◆ refcount_

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

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