|
dune-fem 2.12-git
|
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) |
Detailed Description
class Dune::Fem::ReferenceCounterInterface< RCT >
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.
- Note
- Reference counting is not a good mehtod for garbage collection, since it does not detect cycles. So be careful when using reference counters!
Member Typedef Documentation
◆ ObjectType
| typedef Traits::ObjectType Dune::Fem::ReferenceCounterInterface< RCT >::ObjectType |
type of the object, this is a reference counter for
◆ ReferenceCounterInterfaceType
| typedef ThisType Dune::Fem::ReferenceCounterInterface< RCT >::ReferenceCounterInterfaceType |
type of the reference counter interface
◆ ReferenceCounterType
| typedef Traits::ReferenceCounterType Dune::Fem::ReferenceCounterInterface< RCT >::ReferenceCounterType |
type of the implementation (Barton-Nackman)
◆ Traits
| typedef RCT Dune::Fem::ReferenceCounterInterface< RCT >::Traits |
type of the traits
Member Function Documentation
◆ addReference()
|
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)
- Note
- This method is declared const, since we want to be able to add references to const objects, too. Hence, the reference coutner must be declared mutable.
◆ asImp() [1/6]
|
inlineprotected |
◆ asImp() [2/6]
|
inlineprotected |
◆ asImp() [3/6]
|
inlinestaticprotectedinherited |
◆ asImp() [4/6]
|
inlinestaticprotected |
◆ asImp() [5/6]
|
inlinestaticprotectedinherited |
◆ asImp() [6/6]
|
inlinestaticprotected |
◆ deleteObject()
|
inline |
delete to object
This method is used by the default implementation to free the object when the reference counter becomes zero.
- Note
- For the implementor's convenience, this method is not declared const. The caller (usually the default implementation's removeReference method) is responsible for performing a necessary const_cast.
◆ getObject() [1/2]
|
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.
- Returns
- a reference to the real object
◆ getObject() [2/2]
|
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.
- Returns
- a constant reference to the real object
◆ removeReference()
|
inline |
remove a reference to this object
This method should be called whenever a previously added reference to this object is released.
- Note
- This method is declared const, since we want to be able to remove references to const objects, too. Hence, the reference coutner must be declared mutable.
The documentation for this class was generated from the following file:
Legal Statements / Impressum | Hosted by TU Dresden & Uni Heidelberg | Generated by
1.9.8