blocxx
BLOCXX_NAMESPACE::COWReference< T > Class Template Reference

COWReference A smart pointer that uses non-intrusive reference counting. More...

#include <COWReference.hpp>

Inheritance diagram for BLOCXX_NAMESPACE::COWReference< T >:
BLOCXX_NAMESPACE::COWReferenceBase

Public Types

typedef T element_type
 
typedef T *volatile COWReference::* safe_bool
 

Public Member Functions

 COWReference ()
 Default constructor The underlying object pointer will be NULL.
 
 COWReference (T *ptr)
 Construct a COWReference that will take ownership of a given pointer.
 
 COWReference (const COWReference< T > &arg)
 Copy constructor.
 
template<class U>
 COWReference (const COWReference< U > &arg)
 Copy constructor.
 
 ~COWReference ()
 Destroy this COWReference.
 
COWReference< T > & operator= (const COWReference< T > &arg)
 Assignment operator.
 
COWReference< T > & operator= (T *newObj)
 Assignment operator.
 
void swap (COWReference< T > &arg)
 
T * operator-> ()
 
const T * operator-> () const
 
T & operator* ()
 
const T & operator* () const
 
const T * getPtr () const
 
bool isNull () const BLOCXX_DEPRECATED
 
 operator safe_bool () const
 
bool operator! () const
 
template<class U>
COWReference< U > cast_to () const
 
template<class U>
void useRefCountOf (const COWReference< U > &)
 

Private Member Functions

void decRef ()
 
void getWriteLock ()
 
- Private Member Functions inherited from BLOCXX_NAMESPACE::COWReferenceBase
 COWReferenceBase ()
 
 COWReferenceBase (const COWReferenceBase &arg)
 
void incRef ()
 
bool decRef ()
 
bool refCountGreaterThanOne () const
 
bool getWriteLock ()
 
void swap (COWReferenceBase &arg)
 
void useRefCountOf (const COWReferenceBase &arg)
 

Private Attributes

T *volatile m_pObj
 
- Private Attributes inherited from BLOCXX_NAMESPACE::COWReferenceBase
RefCount *volatile m_pRefCount
 

Friends

template<class U>
class COWReference
 

Detailed Description

template<class T>
class BLOCXX_NAMESPACE::COWReference< T >

COWReference A smart pointer that uses non-intrusive reference counting.

It supports 'copy on write' functionality.

Definition at line 54 of file COWReference.hpp.

Member Typedef Documentation

◆ element_type

template<class T>
typedef T BLOCXX_NAMESPACE::COWReference< T >::element_type

Definition at line 57 of file COWReference.hpp.

◆ safe_bool

template<class T>
typedef T* volatile COWReference::* BLOCXX_NAMESPACE::COWReference< T >::safe_bool

Definition at line 145 of file COWReference.hpp.

Constructor & Destructor Documentation

◆ COWReference() [1/4]

template<class T>
BLOCXX_NAMESPACE::COWReference< T >::COWReference ( )
inline

Default constructor The underlying object pointer will be NULL.

Definition at line 164 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReferenceBase::COWReferenceBase(), and m_pObj.

◆ COWReference() [2/4]

template<class T>
BLOCXX_NAMESPACE::COWReference< T >::COWReference ( T * ptr)
inlineexplicit

Construct a COWReference that will take ownership of a given pointer.

Parameters
ptrThe pointer that will be owned by this COWReference.

Definition at line 170 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReferenceBase::COWReferenceBase(), and m_pObj.

◆ COWReference() [3/4]

template<class T>
BLOCXX_NAMESPACE::COWReference< T >::COWReference ( const COWReference< T > & arg)
inline

Copy constructor.

This constructor will cause this COWReference object to share the same underlying object pointer with another. This will cause the reference count to get incremented the underlying object.

Parameters
argThe object to copy the object pointer from.

Definition at line 176 of file COWReference.hpp.

References COWReference, BLOCXX_NAMESPACE::COWReferenceBase::COWReferenceBase(), and m_pObj.

◆ COWReference() [4/4]

template<class T>
template<class U>
BLOCXX_NAMESPACE::COWReference< T >::COWReference ( const COWReference< U > & arg)
inline

Copy constructor.

This takes a COWReference of a type derived from T This constructor will cause this COWReference object to share the same underlying object pointer with another. This will cause the reference count to get incremented on the underlying object.

Parameters
argThe object to copy the object pointer from.

Definition at line 183 of file COWReference.hpp.

References COWReference, BLOCXX_NAMESPACE::COWReferenceBase::COWReferenceBase(), and m_pObj.

◆ ~COWReference()

template<class T>
BLOCXX_NAMESPACE::COWReference< T >::~COWReference ( )
inline

Destroy this COWReference.

If the reference count to the underlying object is zero after it is decremented in this method it will be deleted.

Definition at line 189 of file COWReference.hpp.

References decRef().

Member Function Documentation

◆ cast_to()

template<class T>
template<class U>
COWReference< U > BLOCXX_NAMESPACE::COWReference< T >::cast_to ( ) const
inline

Definition at line 315 of file COWReference.hpp.

References COWReference, m_pObj, and useRefCountOf().

◆ decRef()

template<class T>
void BLOCXX_NAMESPACE::COWReference< T >::decRef ( )
inlineprivate

Definition at line 202 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReferenceBase::decRef(), and m_pObj.

Referenced by ~COWReference().

◆ getPtr()

template<class T>
const T * BLOCXX_NAMESPACE::COWReference< T >::getPtr ( ) const
inline
Returns
A read only pointer to the underlying object.

Definition at line 301 of file COWReference.hpp.

References m_pObj.

Referenced by BLOCXX_NAMESPACE::operator!=(), BLOCXX_NAMESPACE::operator<(), and BLOCXX_NAMESPACE::operator==().

◆ getWriteLock()

◆ isNull()

template<class T>
bool BLOCXX_NAMESPACE::COWReference< T >::isNull ( ) const
inline

Definition at line 307 of file COWReference.hpp.

References m_pObj.

◆ operator safe_bool()

template<class T>
BLOCXX_NAMESPACE::COWReference< T >::operator safe_bool ( ) const
inline

Definition at line 145 of file COWReference.hpp.

References BLOCXX_SAFE_BOOL_IMPL, COWReference, and m_pObj.

◆ operator!()

template<class T>
bool BLOCXX_NAMESPACE::COWReference< T >::operator! ( ) const
inline

Definition at line 145 of file COWReference.hpp.

◆ operator*() [1/2]

template<class T>
T & BLOCXX_NAMESPACE::COWReference< T >::operator* ( )
inline
Returns
A read/write reference to the underlying object.

Definition at line 267 of file COWReference.hpp.

References getWriteLock(), and m_pObj.

◆ operator*() [2/2]

template<class T>
const T & BLOCXX_NAMESPACE::COWReference< T >::operator* ( ) const
inline
Returns
A read only reference to the underlying object.

Definition at line 290 of file COWReference.hpp.

References m_pObj.

◆ operator->() [1/2]

template<class T>
T * BLOCXX_NAMESPACE::COWReference< T >::operator-> ( )
inline
Returns
A read/write pointer to the underlying object.

Definition at line 255 of file COWReference.hpp.

References getWriteLock(), and m_pObj.

◆ operator->() [2/2]

template<class T>
const T * BLOCXX_NAMESPACE::COWReference< T >::operator-> ( ) const
inline
Returns
A read only pointer to the underlying object.

Definition at line 279 of file COWReference.hpp.

References m_pObj.

◆ operator=() [1/2]

template<class T>
COWReference< T > & BLOCXX_NAMESPACE::COWReference< T >::operator= ( const COWReference< T > & arg)
inline

Assignment operator.

This changes the underlying object pointer to the one contained by the COWReference object passed as the argument.

Parameters
argThe COWReference object that contains the object pointer that will be assigned to this on.
Returns
A reference to this COWReference object.

Definition at line 234 of file COWReference.hpp.

References COWReference.

◆ operator=() [2/2]

template<class T>
COWReference< T > & BLOCXX_NAMESPACE::COWReference< T >::operator= ( T * newObj)
inline

Assignment operator.

This will cause thise COWReference to release ownership of it's existing object pointer and assume ownership of another.

Parameters
newObjThe new object pointer this COWReference will assume ownership of.
Returns
A reference to thei COWReference object after the assignment as taken place.

Definition at line 241 of file COWReference.hpp.

References COWReference.

◆ swap()

template<class T>
void BLOCXX_NAMESPACE::COWReference< T >::swap ( COWReference< T > & arg)
inline

◆ useRefCountOf()

template<class T>
template<class U>
void BLOCXX_NAMESPACE::COWReference< T >::useRefCountOf ( const COWReference< U > & arg)
inline

Definition at line 329 of file COWReference.hpp.

References COWReference, and BLOCXX_NAMESPACE::COWReferenceBase::useRefCountOf().

Referenced by cast_to().

Friends And Related Symbol Documentation

◆ COWReference

template<class T>
template<class U>
friend class COWReference
friend

Member Data Documentation

◆ m_pObj


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