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 List of all members.

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
 operator safe_bool () const
bool operator! () const
 Negation operator.
template<class U>
COWReference< U > cast_to () const
template<class U>
void useRefCountOf (const COWReference< U > &)

Private Member Functions

void decRef ()
void getWriteLock ()

Private Attributes

T *volatile m_pObj

Friends

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 51 of file COWReference.hpp.


Member Typedef Documentation

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

Definition at line 54 of file COWReference.hpp.

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

Definition at line 141 of file COWReference.hpp.


Constructor & Destructor Documentation

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

Default constructor The underlying object pointer will be NULL.

template<class T>
BLOCXX_NAMESPACE::COWReference< T >::COWReference T *  ptr  )  [inline, explicit]
 

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

Parameters:
ptr The pointer that will be owned by this COWReference.

Definition at line 181 of file COWReference.hpp.

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:
arg The object to copy the object pointer from.

Definition at line 187 of file COWReference.hpp.

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:
arg The object to copy the object pointer from.

Definition at line 194 of file COWReference.hpp.

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 200 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReference< T >::decRef().


Member Function Documentation

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

Definition at line 320 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReference< T >::m_pObj, and BLOCXX_NAMESPACE::COWReference< T >::useRefCountOf().

template<class T>
void BLOCXX_NAMESPACE::COWReference< T >::decRef  )  [inline, private]
 

Reimplemented from BLOCXX_NAMESPACE::COWReferenceBase.

Definition at line 213 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReferenceBase::decRef(), and BLOCXX_NAMESPACE::COWReference< T >::m_pObj.

Referenced by BLOCXX_NAMESPACE::COWReference< T >::~COWReference().

template<class T>
const T * BLOCXX_NAMESPACE::COWReference< T >::getPtr  )  const [inline]
 

Returns:
A read only pointer to the underlying object.

Definition at line 312 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReference< T >::m_pObj.

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

template<class T>
void BLOCXX_NAMESPACE::COWReference< T >::getWriteLock  )  [inline, private]
 

Reimplemented from BLOCXX_NAMESPACE::COWReferenceBase.

Definition at line 225 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReferenceClone(), BLOCXX_NAMESPACE::COWReferenceBase::getWriteLock(), BLOCXX_NAMESPACE::COWReference< T >::m_pObj, and BLOCXX_NAMESPACE::COWReferenceBase::refCountGreaterThanOne().

Referenced by BLOCXX_NAMESPACE::COWReference< T >::operator *(), and BLOCXX_NAMESPACE::COWReference< T >::operator->().

template<class T>
const T & BLOCXX_NAMESPACE::COWReference< T >::operator *  )  const [inline]
 

Returns:
A read only reference to the underlying object.

Definition at line 301 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReferenceBase::checkNull(), and BLOCXX_NAMESPACE::COWReference< T >::m_pObj.

template<class T>
T & BLOCXX_NAMESPACE::COWReference< T >::operator *  )  [inline]
 

Returns:
A read/write reference to the underlying object.

Definition at line 278 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReferenceBase::checkNull(), BLOCXX_NAMESPACE::COWReference< T >::getWriteLock(), and BLOCXX_NAMESPACE::COWReference< T >::m_pObj.

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

Definition at line 142 of file COWReference.hpp.

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

Negation operator.

Returns:
true if the underlying object pointer for this COWReference object is NULL. Othewise false.

Definition at line 152 of file COWReference.hpp.

template<class T>
const T * BLOCXX_NAMESPACE::COWReference< T >::operator->  )  const [inline]
 

Returns:
A read only pointer to the underlying object.

Definition at line 290 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReferenceBase::checkNull(), and BLOCXX_NAMESPACE::COWReference< T >::m_pObj.

template<class T>
T * BLOCXX_NAMESPACE::COWReference< T >::operator->  )  [inline]
 

Returns:
A read/write pointer to the underlying object.

Definition at line 266 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReferenceBase::checkNull(), BLOCXX_NAMESPACE::COWReference< T >::getWriteLock(), and BLOCXX_NAMESPACE::COWReference< T >::m_pObj.

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:
newObj The 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 252 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReference< T >::swap().

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:
arg The COWReference object that contains the object pointer that will be assigned to this on.
Returns:
A reference to this COWReference object.

Definition at line 245 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReference< T >::swap().

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

Definition at line 259 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWRefSwap(), BLOCXX_NAMESPACE::COWReference< T >::m_pObj, and BLOCXX_NAMESPACE::swap().

Referenced by BLOCXX_NAMESPACE::COWReference< T >::operator=(), BLOCXX_NAMESPACE::SortedVectorSet< String >::swap(), BLOCXX_NAMESPACE::Map< Key, T, Compare >::swap(), BLOCXX_NAMESPACE::List< T >::swap(), and BLOCXX_NAMESPACE::Array< T >::swap().

template<class T>
template<class U>
void BLOCXX_NAMESPACE::COWReference< T >::useRefCountOf const COWReference< U > &   )  [inline]
 

Definition at line 334 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReferenceBase::useRefCountOf().

Referenced by BLOCXX_NAMESPACE::COWReference< T >::cast_to().


Friends And Related Function Documentation

template<class T>
BLOCXX_NAMESPACE::COWReference< T >::COWReference [friend]
 

Definition at line 165 of file COWReference.hpp.


Member Data Documentation

template<class T>
T* volatile BLOCXX_NAMESPACE::COWReference< T >::m_pObj [private]
 

Definition at line 168 of file COWReference.hpp.

Referenced by BLOCXX_NAMESPACE::COWReference< T >::cast_to(), BLOCXX_NAMESPACE::COWReference< T >::decRef(), BLOCXX_NAMESPACE::COWReference< T >::getPtr(), BLOCXX_NAMESPACE::COWReference< T >::getWriteLock(), BLOCXX_NAMESPACE::COWReference< T >::operator *(), BLOCXX_NAMESPACE::COWReference< M >::operator safe_bool(), BLOCXX_NAMESPACE::COWReference< M >::operator!(), BLOCXX_NAMESPACE::COWReference< T >::operator->(), and BLOCXX_NAMESPACE::COWReference< T >::swap().


The documentation for this class was generated from the following file:
Generated on Fri Jun 16 15:39:10 2006 for blocxx by  doxygen 1.4.6