blocxx
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends

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

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


Member Typedef Documentation

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

Definition at line 57 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:
ptrThe pointer that will be owned by this COWReference.

Definition at line 170 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:
argThe object to copy the object pointer from.

Definition at line 176 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:
argThe object to copy the object pointer from.

Definition at line 183 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 189 of file COWReference.hpp.


Member Function Documentation

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

Reimplemented from BLOCXX_NAMESPACE::COWReferenceBase.

Definition at line 202 of file COWReference.hpp.

References BLOCXX_NAMESPACE::COWReferenceBase::decRef().

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.

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

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

Definition at line 307 of file COWReference.hpp.

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.

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.

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.

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.

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 BLOCXX_NAMESPACE::swap().

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 BLOCXX_NAMESPACE::swap().

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

Friends And Related Function Documentation

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

Definition at line 155 of file COWReference.hpp.


Member Data Documentation

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

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