mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR > Class Template Reference

Reference counted pointer. More...

#include <MboRefCntPtr.h>

Inheritance diagram for mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >:

Inheritance graph
{mbo::RefCntConstPtr\< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR \>\n||+ operator unspecified_bool_type()\l+ __getRep()\l+ RefCntConstPtr()\l+ RefCntConstPtr()\l+ RefCntConstPtr()\l+ RefCntConstPtr()\l+ operator=()\l+ operator=()\l+ operator *()\l+ operator-\>()\l}{mbo::AutoFastLock\< _THREAD_MODEL, _THREAD_MODEL_PTR \>\n||}{mbo::AutoFastLock\< ThreadModel1, ThreadModel2 \>\n||}
[legend]
Collaboration diagram for mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >:

Collaboration graph
{mbo::AutoFastLock\< _THREAD_MODEL, _THREAD_MODEL_PTR \>\n||}{mbo::AutoFastLock\< ThreadModel1, ThreadModel2 \>\n||}{mbo::CCriticalSectionFake\n||+ Enter()\l+ Leave()\l+ GetLock()\l+ GetLevel()\l}{mbo::ICriticalSection\n||+ ~ICriticalSection()\l+ Enter()\l+ Leave()\l+ GetLock()\l+ GetLevel()\l}{mbo::RefCntRep\< _Ty, _THREAD_MODEL \>\n|+ refCnt\l+ pData\l|+ RefCntRep()\l+ AddRef()\l+ Release()\l+ Alloc()\l+ Dealloc()\l}
[legend]

List of all members.

Public Types

typedef _THREAD_MODEL ThreadModel
typedef _THREAD_MODEL_PTR ThreadModelPtr
typedef _Ty Type
typedef RefCntRep< _Ty,
ThreadModel
RepType
typedef RepType::refcount_type refcount_type
typedef NullPointer< _Ty > NullPtr
typedef ThreadModel::Lock ExtLock
typedef
ThreadModel::CriticalSection 
CriticalSection
typedef RefCntConstPtr< Type,
ThreadModel, ThreadModelPtr
ConstPtr
typedef const RepType *const
RefCntPtr::* 
unspecified_bool_type

Public Member Functions

 RefCntPtr (_Ty *p=0)
template<class _Tx>
 RefCntPtr (const _Tx &x)
 RefCntPtr (const RefCntPtr &oth)
 ~RefCntPtr ()
RefCntPtroperator= (_Ty *p)
RefCntPtr__assign (const _Ty &ref)
_Ty & __clone (_Ty &ref) const
RefCntPtroperator= (const RefCntPtr &oth)
 operator unspecified_bool_type () const
refcount_type __referenceCount () const
ExtLock __getLock () const
RepType__getRep ()
const RepType__getRep () const
_Ty & operator * ()
const _Ty & operator * () const
_Ty * operator-> ()
const _Ty * operator-> () const

Protected Member Functions

void __release ()

Protected Attributes

RepTypepRep
CriticalSection mx

Related Functions

(Note that these are not member functions.)

template<class _Ty, class _THM, class _THM_PTR>
bool operator< (const RefCntPtr< _Ty, _THM, _THM_PTR > &lhs, const RefCntPtr< _Ty, _THM, _THM_PTR > &rhs)
 LT: value base comparison of two reference count pointers.
template<class _Ty, class _THM, class _THM_PTR>
bool operator== (const RefCntPtr< _Ty, _THM, _THM_PTR > &lhs, const RefCntPtr< _Ty, _THM, _THM_PTR > &rhs)
 EQ: value base comparison of two reference count pointers.
template<class _Ty, class _THM, class _THM_PTR>
bool operator!= (const RefCntPtr< _Ty, _THM, _THM_PTR > &lhs, const RefCntPtr< _Ty, _THM, _THM_PTR > &rhs)
 NE: negated value base comparison of two reference count pointers.


Detailed Description

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
class mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >

Reference counted pointer.

The class RefCntPtr<_Ty> describes an object that stores a pointer to an allocated instance of type _Ty, and keeps that object's reference count. Each time RefCntPtr<_Ty> instance is copied (through copy constructor or assignment operator), it's reference count is incremented. The stored pointer to object of type _Ty * is passed to constructor of RefCntPtr<_Ty> and must either be null or designate an object allocated by a new expression. The destructor for RefCntPtr<_Ty> deletes the allocated object if reference count falls to zero. Hence, an object of class RefCntPtr<_Ty> ensures that a pointer to an instance of type _Ty is automatically deleted. Valid values for the templates _THREAD_MODEL are SingleThreadedModel (for single threaded model) and MultiThreadedModel (for multi threaded model).

Parameters:
_Ty type to use for target pointer
_THREAD_MODEL either SingleThreadedModel, MultiThreadedModel or the automatically selected ThreadModel.
_THREAD_MODEL_PTR same as _THREAD_MODEL but for the instance itself. This defaults to SingleThreadedModel regardless of the current ThreadModel default. The only thinkable need for MultiThreadedModel would be a situation where more than one thread accesses the same RefCntPtr.
Example:
 {
   RefCntPtr<int> p;     // equivalent of NULL pointer (no target)
   RefCntPtr<int> p1(5); // reference count of p1 is 1 (target
   RefCntPtr<int> p2(7); // reference count of p2 is 1	

   printf("p1=%d", *p2); // this will print "p1=5".
   printf("p2=%d", *p2); // this will print "p2=7".

   p2 = p1;              // reference count of p2 falls to zero, deallocation
                         // occurs, and then reference count of p1 will be
                         // incremented to 2 because p2 now uses the same
                         // target. Therefore also reference count of p2 is 2.

   printf("p2=%d", *p2); // this will print "p2=5".

  } // deallocation is performed now becouse destructor of p1 decrements 
    // reference count to 1, and then destructor of p2 decrements reference 
    // count to 0. 
 

Note:
This class has its destructor defined non virtual, hence you may not derive this class and provide an overloaded (especially not virtual) destructor.

The is a derived class RefCntConstPtr that stores a const pointer.

The size of this class is > 4 Bytes so use call by reference where approriate. The class itself will handle reference counting in assignments. But you may not store instances passed by refernce by memory operations of any kind since that would ignore reference counting.

The shortcut ConstPtr denotes a const version of this type that does not allow to modify the inner pointer, however it can free the inner pointer.

For debugging purpose under Microsoft Visual Studio you might want to edit the debug helper file 'autoexp.dat' and add the following lines:

This class is distributed under the following license GNU Lesser General Public License, version 2.1.

Definition at line 305 of file MboRefCntPtr.h.


Member Typedef Documentation

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
typedef _THREAD_MODEL mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::ThreadModel

thread model for Rep member access

Definition at line 308 of file MboRefCntPtr.h.

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
typedef _THREAD_MODEL_PTR mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::ThreadModelPtr

thread model for accessing this

Definition at line 309 of file MboRefCntPtr.h.

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
typedef _Ty mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::Type

type abbrevation for target pointer type

Definition at line 310 of file MboRefCntPtr.h.

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
typedef RefCntRep<_Ty, ThreadModel> mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::RepType

type abbrevation for target pointer representation

Definition at line 311 of file MboRefCntPtr.h.

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
typedef RepType::refcount_type mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::refcount_type

type used for refcounting

Definition at line 312 of file MboRefCntPtr.h.

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
typedef NullPointer<_Ty> mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::NullPtr

type abbrevation for a null pointer that throws nullptr_access upon access

Definition at line 313 of file MboRefCntPtr.h.

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
typedef ThreadModel::Lock mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::ExtLock

type abbreviation for thread model dependent Lock

Definition at line 314 of file MboRefCntPtr.h.

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
typedef ThreadModel::CriticalSection mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::CriticalSection

type abbreviation for thread model dependent ctitical section

Definition at line 315 of file MboRefCntPtr.h.

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
typedef RefCntConstPtr<Type, ThreadModel, ThreadModelPtr> mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::ConstPtr

const pointer shortcut

Definition at line 316 of file MboRefCntPtr.h.

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
typedef const RepType* const RefCntPtr::* mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::unspecified_bool_type

Definition at line 493 of file MboRefCntPtr.h.


Constructor & Destructor Documentation

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::RefCntPtr ( _Ty *  p = 0  )  [inline]

Default constructor

The standard constructor takes a pointer of the member pointer type.

Parameters:
p target pointer to be stored in the RefCntPtr.
Note:
This is an automatic conversion.

Definition at line 346 of file MboRefCntPtr.h.

00347         : pRep(p ? RepType::Alloc(p) : 0) 
00348     {
00349     }

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
template<class _Tx>
mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::RefCntPtr ( const _Tx &  x  )  [inline]

Clone constructor with automatic type conversion

This copy constructor is very handy when two types are involved in the creation of a RefCntPtr instance. The first type is the type of the internally stored pointer which may be an abstract class. The second type may be any derived type. This way you can create a copy from a derived reference and store the resulting pointer with the abstract type in the RefCntPrt.

Class _Tx is the type of param x which must be equal or derived from class type _Ty.

Parameters:
x An instance to clone (by calling its copy constructor)

Definition at line 366 of file MboRefCntPtr.h.

00367         : pRep(RepType::Alloc(new _Tx(x)))
00368     {
00369     }

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::RefCntPtr ( const RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR > &  oth  )  [inline]

Copy constructor that takes a reference

Parameters:
oth RefCntPtr to copy from

Definition at line 375 of file MboRefCntPtr.h.

References mbo::RefCntRep< _Ty, _THREAD_MODEL >::AddRef(), and mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::pRep.

00376         : pRep(0) 
00377     {   
00378         FastLock lock(&oth.mx);
00379 
00380         pRep = oth.pRep;
00381         if (pRep)
00382         {
00383             pRep->AddRef(); 
00384         }
00385     }

Here is the call graph for this function:

mbo::RefCntRep::AddRef

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::~RefCntPtr (  )  [inline]

destructor

The destructor releases the resources. That means it decrements the reference count to the stored pointer and frees is if the result is zero.

Note:
Since the destructor is declared non virtual you may not derive this class.

Definition at line 395 of file MboRefCntPtr.h.

References mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__release(), and mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::mx.

00396     { 
00397         FastLock lock(&mx);
00398 
00399         __release();
00400     }                                              

Here is the call graph for this function:

mbo::RefCntPtr::__releasembo::RefCntRep::Deallocmbo::RefCntRep::Release


Member Function Documentation

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
void mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__release (  )  [inline, protected]

Free/release the internal pointer

Definition at line 329 of file MboRefCntPtr.h.

References mbo::RefCntRep< _Ty, _THREAD_MODEL >::Dealloc(), mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::pRep, and mbo::RefCntRep< _Ty, _THREAD_MODEL >::Release().

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

00330     {
00331         if (pRep && pRep->Release())
00332         {
00333             RepType::Dealloc(pRep); 
00334         }
00335     }

Here is the call graph for this function:

mbo::RefCntRep::Deallocmbo::RefCntRep::Release

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
RefCntPtr& mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator= ( _Ty *  p  )  [inline]

Assignment operator

Parameters:
p new target pointer
Returns:
modified self

Definition at line 407 of file MboRefCntPtr.h.

References mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__release(), mbo::RefCntRep< _Ty, _THREAD_MODEL >::Alloc(), mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::mx, mbo::RefCntRep< _Ty, _THREAD_MODEL >::pData, and mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::pRep.

00408     {
00409         FastLock lock(&mx);
00410 
00411         if (!pRep || pRep->pData != p)
00412         {
00413             __release();
00414             pRep = p ? RepType::Alloc(p) : 0;
00415         }
00416         return *this;
00417     }

Here is the call graph for this function:

mbo::RefCntPtr::__releasembo::RefCntRep::Allocmbo::RefCntRep::Deallocmbo::RefCntRep::Release

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
RefCntPtr& mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__assign ( const _Ty &  ref  )  [inline]

Assignment by reference

Unlike other assignment solutions this one is completely captured by the lock and opens/closes the lock only once.

Using *ptr = ref; would require the pointer to be valid before and the assignment happens outside the lock.

Using ptr = ref; would open/lock twice.

Parameters:
ref reference to target
Returns:
modified self

Definition at line 432 of file MboRefCntPtr.h.

References mbo::RefCntRep< _Ty, _THREAD_MODEL >::Alloc(), mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::mx, mbo::RefCntRep< _Ty, _THREAD_MODEL >::pData, and mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::pRep.

00433     {
00434         FastLock lock(&mx);
00435 
00436         if (pRep) 
00437         {
00438             if (pRep->pData)
00439             {
00440                 *pRep->pData = ref;
00441             }
00442             else
00443             {
00444                 pRep->pData = new _Ty(ref);
00445             }
00446         }
00447         else
00448         {
00449             pRep = RepType::Alloc(new _Ty(ref));
00450         }
00451         return *this;
00452     }

Here is the call graph for this function:

mbo::RefCntRep::Alloc

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
_Ty& mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__clone ( _Ty &  ref  )  const [inline]

Derefence cloning

Unlike other data methods this one is completly captured by the lock. Hence it ensures the data is completley cloned while protected.

Return values:
ref Reference to data which will hold the copy (work as a clone)
Returns:
reference to input data and therefore the copied data.

Definition at line 462 of file MboRefCntPtr.h.

References mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::mx, mbo::RefCntRep< _Ty, _THREAD_MODEL >::pData, and mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::pRep.

00463     {
00464         FastLock lock(&mx);
00465 
00466         ref = pRep && pRep->pData ? *pRep->pData : *NullPtr();
00467 
00468         return ref;
00469     }

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
RefCntPtr& mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator= ( const RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR > &  oth  )  [inline]

Assignment operator

Parameters:
oth RefCntPtr to copy from
Returns:
modified self

Definition at line 476 of file MboRefCntPtr.h.

References mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__release(), mbo::RefCntRep< _Ty, _THREAD_MODEL >::AddRef(), mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::mx, and mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::pRep.

00477     {
00478         FastLock lock(&mx);
00479 
00480         if (pRep != oth.pRep) 
00481         {
00482             __release();
00483             pRep = oth.pRep; 
00484             if (pRep)
00485             {
00486                 pRep->AddRef();
00487             }
00488         }
00489         return *this;
00490     }

Here is the call graph for this function:

mbo::RefCntPtr::__releasembo::RefCntRep::AddRefmbo::RefCntRep::Deallocmbo::RefCntRep::Release

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator unspecified_bool_type (  )  const [inline]

Check if assigned/set

Note:
This may overwrite some behavior you expect from working with the other pointer types. However that shouldn't be the case in well designed source code.
Returns:
Whether or not target pointer is assigned (not NULL)

Reimplemented in mbo::RefCntConstPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >.

Definition at line 503 of file MboRefCntPtr.h.

References mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::mx, mbo::RefCntRep< _Ty, _THREAD_MODEL >::pData, and mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::pRep.

00504     {
00505         FastLock lock(&mx);
00506 
00507         return (pRep != 0 && pRep->pData != 0) ? &RefCntPtr::pRep : 0;
00508     }

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
refcount_type mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__referenceCount (  )  const [inline]

Retrieve number of references

Returns:
reference count

Definition at line 521 of file MboRefCntPtr.h.

00523     { 
00524         FastLock lock(&mx);
00525 
00526         return pRep ? pRep->refCnt : 0;

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
ExtLock mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__getLock (  )  const [inline]

Returns:
lock for pointer itself

Definition at line 530 of file MboRefCntPtr.h.

00532     {
00533         return ExtLock(&mx);

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
RepType* mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__getRep (  )  [inline]

Definition at line 535 of file MboRefCntPtr.h.

References mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::pRep.

00537     {
00538         return pRep;

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
const RepType* mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__getRep (  )  const [inline]

Reimplemented in mbo::RefCntConstPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >.

Definition at line 540 of file MboRefCntPtr.h.

References mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::pRep.

00542     {
00543         return pRep;

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
_Ty& mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator * (  )  [inline]

Dereference operator

Note:
Do use this with caution because you may access a null pointer here. There is no special check
Returns:
target dereferenced

Definition at line 552 of file MboRefCntPtr.h.

00554     {
00555         FastLock lock(&mx);
00556 
00557         return pRep && pRep->pData ? *pRep->pData : *NullPtr();

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
const _Ty& mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator * (  )  const [inline]

Dereference operator (const)

Note:
Do use this with caution because you may access a null pointer here. There is no special check
Returns:
target dereferenced as const

Reimplemented in mbo::RefCntConstPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >.

Definition at line 566 of file MboRefCntPtr.h.

00568     { 
00569         FastLock lock(&mx);
00570 
00571         return pRep && pRep->pData ? *pRep->pData : *NullPtr();

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
_Ty* mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator-> (  )  [inline]

Dereference operator

Returns:
target pointer not dereferenced

Definition at line 577 of file MboRefCntPtr.h.

00579     { 
00580         FastLock lock(&mx);
00581 
00582         return pRep ? pRep->pData : 0;

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
const _Ty* mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator-> (  )  const [inline]

Dereference operator (const)

Returns:
target pointer not dereferenced as const

Reimplemented in mbo::RefCntConstPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >.

Definition at line 588 of file MboRefCntPtr.h.

00590     { 
00591         FastLock lock(&mx);
00592 
00593         return pRep ? pRep->pData : 0;


Friends And Related Function Documentation

template<class _Ty, class _THM, class _THM_PTR>
bool operator< ( const RefCntPtr< _Ty, _THM, _THM_PTR > &  lhs,
const RefCntPtr< _Ty, _THM, _THM_PTR > &  rhs 
) [related]

LT: value base comparison of two reference count pointers.

Parameters:
lhs left hand side operand
rhs right hand side operand
Returns:
Whether or not both pointers have a value and the first value is less than the second by calling the operator <.
Note:
This is different from standard pointers where you compare the addresses and not the values. However there should be really no need to compare "the addresses of two reference counted pointers". If you feel this need for any strange reason you should reconsider if reference counted pointers are what you need.

Definition at line 820 of file MboRefCntPtr.h.

00824 {

template<class _Ty, class _THM, class _THM_PTR>
bool operator== ( const RefCntPtr< _Ty, _THM, _THM_PTR > &  lhs,
const RefCntPtr< _Ty, _THM, _THM_PTR > &  rhs 
) [related]

EQ: value base comparison of two reference count pointers.

Parameters:
lhs left hand side operand
rhs right hand side operand
Returns:
Whether or not both pointers have a value and those values are equal by their operator ==.
Note:
This is different from standard pointers where you compare the addresses and not the values. However there should be really no need to compare "the addresses of two reference counted pointers". If you feel this need for any strange reason you should reconsider if reference counted pointers are what you need.

Definition at line 841 of file MboRefCntPtr.h.

00845 {

template<class _Ty, class _THM, class _THM_PTR>
bool operator!= ( const RefCntPtr< _Ty, _THM, _THM_PTR > &  lhs,
const RefCntPtr< _Ty, _THM, _THM_PTR > &  rhs 
) [related]

NE: negated value base comparison of two reference count pointers.

Parameters:
lhs left hand side operand
rhs right hand side operand
Returns:
Whether or not one pointer has no value or the two values differ based on calling their operator !=.
Note:
This is different from standard pointers where you compare the addresses and not the values. However there should be really no need to compare "the addresses of two reference counted pointers". If you feel this need for any strange reason you should reconsider if reference counted pointers are what you need.

Definition at line 862 of file MboRefCntPtr.h.

00866 {


Member Data Documentation

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
RepType* mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::pRep [protected]

connection to RefCntRep that holds the target pointer

Definition at line 321 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 >::__getRep(), mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__getRep(), mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::__release(), mbo::RefCntConstPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator unspecified_bool_type(), mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator unspecified_bool_type(), mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator=(), and mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::RefCntPtr().

template<class _Ty, class _THREAD_MODEL = ThreadModel, class _THREAD_MODEL_PTR = SingleThreadedModel>
CriticalSection mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::mx [mutable, protected]

internal access mutex

Definition at line 325 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(), mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::operator=(), and mbo::RefCntPtr< _Ty, _THREAD_MODEL, _THREAD_MODEL_PTR >::~RefCntPtr().


The documentation for this class 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