MADARA  3.2.3
madara::utility::Refcounter< T > Class Template Reference

This template class provides transparent reference counting of its template parameter T. More...

#include <IteratorImpl.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 (void)
 default Ctor More...
 
 Refcounter (T *ptr, bool increase_count=false)
 Ctor with refcounting functionality. More...
 
 Refcounter (const Refcounter &rhs)
 copy 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= (T *ptr)
 assignment operator for times when you don't want the reference increased for incoming ptr More...
 
void operator= (const Refcounter &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

Shimptr_
 Pointer to the Shim. More...
 

Detailed Description

template<typename T>
class madara::utility::Refcounter< T >

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 17 of file IteratorImpl.h.

Constructor & Destructor Documentation

template<typename T >
madara::utility::Refcounter< T >::Refcounter ( void  )

default Ctor

Definition at line 9 of file Refcounter.cpp.

template<typename T>
madara::utility::Refcounter< T >::Refcounter ( T *  ptr,
bool  increase_count = false 
)

Ctor with refcounting functionality.

Definition at line 16 of file Refcounter.cpp.

template<typename T>
madara::utility::Refcounter< T >::Refcounter ( const Refcounter< T > &  rhs)

copy Ctor

Definition at line 25 of file Refcounter.cpp.

template<typename T >
madara::utility::Refcounter< T >::~Refcounter ( void  )
virtual

Dtor will delete pointer if refcount becomes 0.

Definition at line 33 of file Refcounter.cpp.

Member Function Documentation

template<typename T >
void madara::utility::Refcounter< T >::decrement ( void  )
inlineprivate

implementation of the decrement operation

Definition at line 139 of file Refcounter.cpp.

template<typename T >
T * madara::utility::Refcounter< T >::get ( void  )

get the underlying pointer

Definition at line 80 of file Refcounter.cpp.

template<typename T >
const T * madara::utility::Refcounter< T >::get ( void  ) const

get the underlying pointer

Definition at line 88 of file Refcounter.cpp.

template<typename T >
T * madara::utility::Refcounter< T >::get_ptr ( void  )

get the underlying pointer

Definition at line 64 of file Refcounter.cpp.

template<typename T >
const T * madara::utility::Refcounter< T >::get_ptr ( void  ) const

get the underlying pointer

Definition at line 72 of file Refcounter.cpp.

template<typename T >
void madara::utility::Refcounter< T >::increment ( void  )
inlineprivate

implementation of the increment operation

Definition at line 130 of file Refcounter.cpp.

template<typename T >
T & madara::utility::Refcounter< T >::operator* ( void  )
inline

dereference operator

Definition at line 97 of file Refcounter.cpp.

template<typename T >
const T & madara::utility::Refcounter< T >::operator* ( void  ) const
inline

dereference operator

Definition at line 106 of file Refcounter.cpp.

template<typename T >
T * madara::utility::Refcounter< T >::operator-> ( void  )
inline

mimic pointer dereferencing

Definition at line 114 of file Refcounter.cpp.

template<typename T >
const T * madara::utility::Refcounter< T >::operator-> ( void  ) const
inline

mimic pointer dereferencing

Definition at line 122 of file Refcounter.cpp.

template<typename T>
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 42 of file Refcounter.cpp.

template<typename T>
void madara::utility::Refcounter< T >::operator= ( const Refcounter< T > &  rhs)

assignment operator

Definition at line 51 of file Refcounter.cpp.

Member Data Documentation

template<typename T>
Shim* madara::utility::Refcounter< T >::ptr_
private

Pointer to the Shim.

Definition at line 92 of file Refcounter.h.


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