MADARA  3.1.8
madara::utility::ScopedArray< T > Class Template Reference

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

#include <ScopedArray.h>

Collaboration diagram for madara::utility::ScopedArray< T >:

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

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.

Constructor & Destructor Documentation

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

default Ctor

Definition at line 9 of file ScopedArray.inl.

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

Ctor with refcounting functionality.

Definition at line 16 of file ScopedArray.inl.

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

copy Ctor

Definition at line 25 of file ScopedArray.inl.

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

Dtor will delete pointer if refcount becomes 0.

Definition at line 33 of file ScopedArray.inl.

Member Function Documentation

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

implementation of the decrement operation

Definition at line 110 of file ScopedArray.inl.

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

get the underlying pointer

Definition at line 84 of file ScopedArray.inl.

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

get the underlying pointer

Definition at line 92 of file ScopedArray.inl.

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

get the underlying pointer

Definition at line 68 of file ScopedArray.inl.

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

get the underlying pointer

Definition at line 76 of file ScopedArray.inl.

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

implementation of the increment operation

Definition at line 101 of file ScopedArray.inl.

template<typename T>
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 42 of file ScopedArray.inl.

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

assignment operator

Definition at line 55 of file ScopedArray.inl.

Member Data Documentation

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

Pointer to the Shim.

Definition at line 81 of file ScopedArray.h.


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