MADARA
3.4.1
|
This template class provides transparent reference counting of its template parameter T. More...
#include <Refcounter.h>
Classes | |
struct | Shim |
A shim class that keeps track of the reference count and a pointer to the type T that's reference counted. More... | |
Public Member Functions | |
Refcounter (const Refcounter &rhs) | |
copy Ctor More... | |
Refcounter (T *ptr, bool increase_count=false) | |
Ctor with refcounting functionality. More... | |
Refcounter (void) | |
default Ctor More... | |
virtual | ~Refcounter (void) |
Dtor will delete pointer if refcount becomes 0. More... | |
T * | get (void) |
get the underlying pointer More... | |
const T * | get (void) const |
get the underlying pointer More... | |
T * | get_ptr (void) |
get the underlying pointer More... | |
const T * | get_ptr (void) const |
get the underlying pointer More... | |
T & | operator* (void) |
dereference operator More... | |
const T & | operator* (void) const |
dereference operator More... | |
T * | operator-> (void) |
mimic pointer dereferencing More... | |
const T * | operator-> (void) const |
mimic pointer dereferencing More... | |
void | operator= (const Refcounter &rhs) |
assignment operator More... | |
void | operator= (T *ptr) |
assignment operator for times when you don't want the reference increased for incoming ptr More... | |
Private Member Functions | |
void | decrement (void) |
implementation of the decrement operation More... | |
void | increment (void) |
implementation of the increment operation More... | |
Private Attributes | |
Shim * | ptr_ |
Pointer to the Shim. More... | |
This template class provides transparent reference counting of its template parameter T.
This differs from ScopedArray in the type of memory it is meant to manage. Refcounter manages single object instances. ScopedArray manages an array of instances,
This class can be used to automate the implementation of the Bridge pattern in C++.
Definition at line 21 of file Refcounter.h.
madara::utility::Refcounter< T >::Refcounter | ( | void | ) |
default Ctor
Definition at line 9 of file Refcounter.cpp.
madara::utility::Refcounter< T >::Refcounter | ( | T * | ptr, |
bool | increase_count = false |
||
) |
Ctor with refcounting functionality.
Definition at line 15 of file Refcounter.cpp.
madara::utility::Refcounter< T >::Refcounter | ( | const Refcounter< T > & | rhs | ) |
copy Ctor
Definition at line 24 of file Refcounter.cpp.
|
virtual |
Dtor will delete pointer if refcount becomes 0.
Definition at line 24 of file Refcounter.cpp.
|
inlineprivate |
implementation of the decrement operation
Definition at line 124 of file Refcounter.cpp.
T * madara::utility::Refcounter< T >::get | ( | void | ) |
get the underlying pointer
Definition at line 74 of file Refcounter.cpp.
const T * madara::utility::Refcounter< T >::get | ( | void | ) | const |
get the underlying pointer
Definition at line 81 of file Refcounter.cpp.
T * madara::utility::Refcounter< T >::get_ptr | ( | void | ) |
get the underlying pointer
Definition at line 60 of file Refcounter.cpp.
const T * madara::utility::Refcounter< T >::get_ptr | ( | void | ) | const |
get the underlying pointer
Definition at line 67 of file Refcounter.cpp.
|
inlineprivate |
implementation of the increment operation
Definition at line 116 of file Refcounter.cpp.
|
inline |
dereference operator
Definition at line 88 of file Refcounter.cpp.
|
inline |
dereference operator
Definition at line 95 of file Refcounter.cpp.
|
inline |
mimic pointer dereferencing
Definition at line 102 of file Refcounter.cpp.
|
inline |
mimic pointer dereferencing
Definition at line 109 of file Refcounter.cpp.
void madara::utility::Refcounter< T >::operator= | ( | const Refcounter< T > & | rhs | ) |
assignment operator
Definition at line 48 of file Refcounter.cpp.
void madara::utility::Refcounter< T >::operator= | ( | T * | ptr | ) |
assignment operator for times when you don't want the reference increased for incoming ptr
assignment operator for times when you don't want the reference increased for incoming ptr.
Definition at line 40 of file Refcounter.cpp.
|
private |
Pointer to the Shim.
Definition at line 92 of file Refcounter.h.