KaRL
3.0.0
|
This template class provides transparent reference counting of its template parameter T. More...
#include <ThreadSafeRefcounter.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 | |
ThreadSafeRefcounter (void) | |
default Ctor More... | |
ThreadSafeRefcounter (T *ptr, bool increase_count=false, bool manage=true) | |
Ctor with refcounting functionality. More... | |
ThreadSafeRefcounter (const ThreadSafeRefcounter &rhs) | |
copy Ctor More... | |
virtual | ~ThreadSafeRefcounter (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... | |
bool | is_valid (void) const |
checks to see if the underlying pointer is valid 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= (T *ptr) |
assignment operator for times when you don't want the reference increased for incoming ptr More... | |
void | operator= (const ThreadSafeRefcounter &rhs) |
assignment operator 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. ThreadSafeRefcounter 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 25 of file ThreadSafeRefcounter.h.
madara::utility::ThreadSafeRefcounter< T >::ThreadSafeRefcounter | ( | void | ) |
default Ctor
Definition at line 9 of file ThreadSafeRefcounter.cpp.
madara::utility::ThreadSafeRefcounter< T >::ThreadSafeRefcounter | ( | T * | ptr, |
bool | increase_count = false , |
||
bool | manage = true |
||
) |
Ctor with refcounting functionality.
Definition at line 16 of file ThreadSafeRefcounter.cpp.
madara::utility::ThreadSafeRefcounter< T >::ThreadSafeRefcounter | ( | const ThreadSafeRefcounter< T > & | rhs | ) |
copy Ctor
Definition at line 26 of file ThreadSafeRefcounter.cpp.
|
virtual |
Dtor will delete pointer if refcount becomes 0.
Definition at line 35 of file ThreadSafeRefcounter.cpp.
|
inlineprivate |
implementation of the decrement operation
Definition at line 193 of file ThreadSafeRefcounter.cpp.
T * madara::utility::ThreadSafeRefcounter< T >::get | ( | void | ) |
get the underlying pointer
Definition at line 104 of file ThreadSafeRefcounter.cpp.
const T * madara::utility::ThreadSafeRefcounter< T >::get | ( | void | ) | const |
get the underlying pointer
Definition at line 119 of file ThreadSafeRefcounter.cpp.
T * madara::utility::ThreadSafeRefcounter< T >::get_ptr | ( | void | ) |
get the underlying pointer
Definition at line 66 of file ThreadSafeRefcounter.cpp.
const T * madara::utility::ThreadSafeRefcounter< T >::get_ptr | ( | void | ) | const |
get the underlying pointer
Definition at line 81 of file ThreadSafeRefcounter.cpp.
|
inlineprivate |
implementation of the increment operation
Definition at line 181 of file ThreadSafeRefcounter.cpp.
bool madara::utility::ThreadSafeRefcounter< T >::is_valid | ( | void | ) | const |
checks to see if the underlying pointer is valid
get the underlying pointer
Definition at line 96 of file ThreadSafeRefcounter.cpp.
|
inline |
dereference operator
Definition at line 134 of file ThreadSafeRefcounter.cpp.
|
inline |
dereference operator
Definition at line 143 of file ThreadSafeRefcounter.cpp.
|
inline |
mimic pointer dereferencing
Definition at line 151 of file ThreadSafeRefcounter.cpp.
|
inline |
mimic pointer dereferencing
Definition at line 166 of file ThreadSafeRefcounter.cpp.
void madara::utility::ThreadSafeRefcounter< 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 44 of file ThreadSafeRefcounter.cpp.
void madara::utility::ThreadSafeRefcounter< T >::operator= | ( | const ThreadSafeRefcounter< T > & | rhs | ) |
assignment operator
Definition at line 53 of file ThreadSafeRefcounter.cpp.
|
private |
Pointer to the Shim.
Definition at line 108 of file ThreadSafeRefcounter.h.