Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

OW32::CAutoRefCountedPtr< T > Class Template Reference

A class for wrapping pointers to objects derived from #CRefCount, and automatically managing their lifetime. More...

#include <RefCounted.h>

List of all members.

Public Member Functions

 CAutoRefCountedPtr ()
 Default c'tor for an empty pointer.
 CAutoRefCountedPtr (T *pObj, bool fAddRef=true)
 C'tor taking ownership of an existing object.
 CAutoRefCountedPtr (const CAutoRefCountedPtr &other)
 C'tor coping one pointer to another.
 ~CAutoRefCountedPtr ()
 D'tor which releases the encapsulated object, if any.
CAutoRefCountedPtroperator= (const CAutoRefCountedPtr &other)
 Assignment operator for copying the object from another pointer.
T * release ()
 Function to detach the encapsulated object without changing its reference count.
void reset (T *pObj, bool fAddRef=true)
 Reset the encapsulated object to the given pointer.
T * get () const
 Return the encapsulated object.
T * operator-> () const
 Extractor for the encapsulated pointer.
T & operator * () const
 Extractor for the encapsulated pointer.
 operator T * () const
 Extractor for the encapsulated pointer.
bool operator! () const
 Test for encapsulated object == 0.
bool operator< (const CAutoRefCountedPtr< T > &rhs) const
bool operator> (const CAutoRefCountedPtr< T > &rhs) const


Detailed Description

template<class T>
class OW32::CAutoRefCountedPtr< T >

A class for wrapping pointers to objects derived from #CRefCount, and automatically managing their lifetime.


Constructor & Destructor Documentation

template<class T>
OW32::CAutoRefCountedPtr< T >::CAutoRefCountedPtr T *  pObj,
bool  fAddRef = true
[inline]
 

C'tor taking ownership of an existing object.

Parameters:
pObj The object to own.
fAddRef Defaults to true, if set will add a reference to the object at construction time.

template<class T>
OW32::CAutoRefCountedPtr< T >::CAutoRefCountedPtr const CAutoRefCountedPtr< T > &  other  )  [inline]
 

C'tor coping one pointer to another.

Parameters:
other The pointer to copy
Always #AddRef's the copied object


Member Function Documentation

template<class T>
T* OW32::CAutoRefCountedPtr< T >::get  )  const [inline]
 

Return the encapsulated object.

Returns:
The encapsulated object, without adding a reference count.

template<class T>
CAutoRefCountedPtr& OW32::CAutoRefCountedPtr< T >::operator= const CAutoRefCountedPtr< T > &  other  )  [inline]
 

Assignment operator for copying the object from another pointer.

Parameters:
other The pointer to copy.
Returns:
A reference to this object.
Note: #AddRef's the copied object.

template<class T>
T* OW32::CAutoRefCountedPtr< T >::release  )  [inline]
 

Function to detach the encapsulated object without changing its reference count.

Returns:
The encapsulated object.
Useful if the application needs to transfer ownership of the encapsulated object for some reason.

template<class T>
void OW32::CAutoRefCountedPtr< T >::reset T *  pObj,
bool  fAddRef = true
[inline]
 

Reset the encapsulated object to the given pointer.

Parameters:
pObj The object to point to.
fAddRef Set to true to AddRef the object, false not to.


The documentation for this class was generated from the following file:
Generated on Sun Jun 5 01:29:26 2005 for OW32 by  doxygen 1.3.9.1