MADARA
3.4.1
|
This template class provides transparent reference counting of its template parameter T. More...
#include <ScopedArray.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 | |
ScopedArray (const ScopedArray &rhs) | |
copy Ctor More... | |
ScopedArray (T *ptr, bool increase_count=false) | |
Ctor with refcounting functionality. More... | |
ScopedArray (void) | |
default Ctor More... | |
virtual | ~ScopedArray (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... | |
void | operator= (const ScopedArray &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 Refcounter in the members available and the deletion of memory. Refcounter deletes a single T memory location when the last instance of the pointer goes out of scope. ScopedArray deletes an array of T objects when the pointer goes out of scope.
This class can be used to automate the implementation of the Bridge pattern in C++.
Definition at line 22 of file ScopedArray.h.
madara::utility::ScopedArray< T >::ScopedArray | ( | void | ) |
default Ctor
Definition at line 9 of file ScopedArray.inl.
madara::utility::ScopedArray< T >::ScopedArray | ( | T * | ptr, |
bool | increase_count = false |
||
) |
Ctor with refcounting functionality.
Definition at line 15 of file ScopedArray.inl.
madara::utility::ScopedArray< T >::ScopedArray | ( | const ScopedArray< T > & | rhs | ) |
copy Ctor
Definition at line 24 of file ScopedArray.inl.
|
virtual |
Dtor will delete pointer if refcount becomes 0.
Definition at line 24 of file ScopedArray.inl.
|
inlineprivate |
implementation of the decrement operation
Definition at line 100 of file ScopedArray.inl.
T * madara::utility::ScopedArray< T >::get | ( | void | ) |
get the underlying pointer
Definition at line 78 of file ScopedArray.inl.
const T * madara::utility::ScopedArray< T >::get | ( | void | ) | const |
get the underlying pointer
Definition at line 85 of file ScopedArray.inl.
T * madara::utility::ScopedArray< T >::get_ptr | ( | void | ) |
get the underlying pointer
Definition at line 64 of file ScopedArray.inl.
const T * madara::utility::ScopedArray< T >::get_ptr | ( | void | ) | const |
get the underlying pointer
Definition at line 71 of file ScopedArray.inl.
|
inlineprivate |
implementation of the increment operation
Definition at line 92 of file ScopedArray.inl.
void madara::utility::ScopedArray< T >::operator= | ( | const ScopedArray< T > & | rhs | ) |
assignment operator
Definition at line 52 of file ScopedArray.inl.
void madara::utility::ScopedArray< 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 ScopedArray.inl.
|
private |
Pointer to the Shim.
Definition at line 81 of file ScopedArray.h.