mbo::RefCntRep< _Ty, _THREAD_MODEL > Struct Template Reference

Reference counted pointer representation. More...

#include <MboRefCntPtr.h>

Collaboration diagram for mbo::RefCntRep< _Ty, _THREAD_MODEL >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef RefCntRep< _Ty,
_THREAD_MODEL > 
Rep
typedef IncDecVal refcount_type

Public Member Functions

 RefCntRep (_Ty *p=NULL)
RefCntRepAddRef ()
bool Release ()

Static Public Member Functions

static RepAlloc (_Ty *p)
static void Dealloc (Rep *&pRep)

Public Attributes

refcount_type refCnt
_Ty * pData


Detailed Description

template<class _Ty, class _THREAD_MODEL = ThreadModel>
struct mbo::RefCntRep< _Ty, _THREAD_MODEL >

Reference counted pointer representation.

Warning:
this should only be used by RefCntPtr
Parameters:
_Ty type to use for target pointer
_THREAD_MODEL either SingleThreadedModel, MultiThreadedModel or the automatically selected ThreadModel.
Note:
This class is distributed under the following license GNU Lesser General Public License, version 2.1.

Definition at line 68 of file MboRefCntPtr.h.


Member Typedef Documentation

template<class _Ty, class _THREAD_MODEL = ThreadModel>
typedef RefCntRep<_Ty, _THREAD_MODEL> mbo::RefCntRep< _Ty, _THREAD_MODEL >::Rep

Shortname fot this instanciated this type in instanciated class types.

Definition at line 73 of file MboRefCntPtr.h.

template<class _Ty, class _THREAD_MODEL = ThreadModel>
typedef IncDecVal mbo::RefCntRep< _Ty, _THREAD_MODEL >::refcount_type

Type used for reference counting

Definition at line 77 of file MboRefCntPtr.h.


Constructor & Destructor Documentation

template<class _Ty, class _THREAD_MODEL = ThreadModel>
mbo::RefCntRep< _Ty, _THREAD_MODEL >::RefCntRep ( _Ty *  p = NULL  )  [inline]

constructor

Parameters:
p target pointer to use.

Definition at line 91 of file MboRefCntPtr.h.

00092         : refCnt(p ? 1 : 0)
00093         , pData(p) 
00094     {
00095     }


Member Function Documentation

template<class _Ty, class _THREAD_MODEL = ThreadModel>
RefCntRep& mbo::RefCntRep< _Ty, _THREAD_MODEL >::AddRef (  )  [inline]

Increase number of references

Definition at line 99 of file MboRefCntPtr.h.

References mbo::RefCntRep< _Ty, _THREAD_MODEL >::refCnt.

Referenced by mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator=(), and mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::RefCntPtr().

00100     { 
00101         _THREAD_MODEL::Increment(&refCnt); 
00102         return *this;
00103     }

template<class _Ty, class _THREAD_MODEL = ThreadModel>
bool mbo::RefCntRep< _Ty, _THREAD_MODEL >::Release (  )  [inline]

Decrease number of references and return true if reference count is zero. That is no more references are legal so that the instance itself (pData) can be deleted.

Returns:
whether reference count is zero and hence the pointer should be NULL.

Definition at line 112 of file MboRefCntPtr.h.

References mbo::RefCntRep< _Ty, _THREAD_MODEL >::refCnt.

Referenced by mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__release().

00113     { 
00114         return !_THREAD_MODEL::Decrement(&refCnt); 
00115     }

template<class _Ty, class _THREAD_MODEL = ThreadModel>
static Rep* mbo::RefCntRep< _Ty, _THREAD_MODEL >::Alloc ( _Ty *  p  )  [inline, static]

Allocate a new RefCntRep

Parameters:
p target pointer to use
Returns:
newly created RefCntRep

Definition at line 122 of file MboRefCntPtr.h.

Referenced by mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__assign(), and mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator=().

00123     { 
00124         return new Rep(p); 
00125     }

template<class _Ty, class _THREAD_MODEL = ThreadModel>
static void mbo::RefCntRep< _Ty, _THREAD_MODEL >::Dealloc ( Rep *&  pRep  )  [inline, static]

Deallocate (free/delete) an already allocated RefCntRep

Parameters:
pRep pointer to free

Definition at line 131 of file MboRefCntPtr.h.

Referenced by mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__release().

00132     { 
00133         if (pRep)
00134         {
00135             if (pRep->pData)
00136             {
00137                 delete pRep->pData;
00138             }
00139             delete pRep; 
00140             pRep = 0;
00141         }
00142     }


Member Data Documentation

template<class _Ty, class _THREAD_MODEL = ThreadModel>
refcount_type mbo::RefCntRep< _Ty, _THREAD_MODEL >::refCnt [mutable]

reference count

Definition at line 81 of file MboRefCntPtr.h.

Referenced by mbo::RefCntRep< _Ty, _THREAD_MODEL >::AddRef(), and mbo::RefCntRep< _Ty, _THREAD_MODEL >::Release().

template<class _Ty, class _THREAD_MODEL = ThreadModel>
_Ty* mbo::RefCntRep< _Ty, _THREAD_MODEL >::pData

target pointer

Definition at line 85 of file MboRefCntPtr.h.

Referenced by mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__assign(), mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__clone(), mbo::RefCntConstPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator unspecified_bool_type(), mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator unspecified_bool_type(), and mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator=().


The documentation for this struct was generated from the following file:
  Hosted on code.google.com  
© Marcus Börger
Generated on Fri Jan 18 21:21:12 2008 for MBO-lib by doxygen 1.5.4