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

cmtk::SmartPointer< T > Class Template Reference
[cmtkSystem Library]

Smart pointer with reference counting. More...

#include <cmtkSmartPtr.h>

Inheritance diagram for cmtk::SmartPointer< T >:
Inheritance graph
[legend]
Collaboration diagram for cmtk::SmartPointer< T >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef SmartPointer< T > Self
 This class instance.
typedef SmartConstPointer< T > Superclass
 This class instance.
typedef T * PointerType
 The underlying raw pointer type.

Public Member Functions

 SmartPointer ()
 Default constructor.
 SmartPointer (T *const object)
 Construct from dumb pointer.
template<class T2 >
 SmartPointer (const SmartPointer< T2 > &ptr)
 Copy constructor template.
 SmartPointer (const Self &ptr)
 Copy constructor to prevent compiler-generated copy constructor.
T & operator* ()
 De-referencing operator (returns non-constant object).
T * operator-> ()
 De-referencing operator (returns non-constant object pointer).
T * GetPtr () const
 Explicit conversion to non-constant pointer.
T * ReleasePtr ()
 Release control of this pointer.

Static Public Member Functions

template<class T2 >
static Self DynamicCastFrom (const T2 &from_P)
 Dynamic cast between smart pointer types.

Static Public Attributes

static Self Null
 Null object.

Private Member Functions

 SmartPointer (T *const object, SafeCounter *const counter)
 Construct from dumb pointer and existing reference counter.

Friends

class SmartPointer
 Make all template instances friends for easy type casting.

Detailed Description

template<class T>
class cmtk::SmartPointer< T >

Smart pointer with reference counting.

Definition at line 57 of file cmtkSmartPtr.h.


Member Typedef Documentation

template<class T>
typedef T* cmtk::SmartPointer< T >::PointerType

The underlying raw pointer type.

Reimplemented from cmtk::SmartConstPointer< T >.

Definition at line 74 of file cmtkSmartPtr.h.

template<class T>
typedef SmartPointer<T> cmtk::SmartPointer< T >::Self

This class instance.

Reimplemented from cmtk::SmartConstPointer< T >.

Definition at line 63 of file cmtkSmartPtr.h.

template<class T>
typedef SmartConstPointer<T> cmtk::SmartPointer< T >::Superclass

This class instance.

Definition at line 66 of file cmtkSmartPtr.h.


Constructor & Destructor Documentation

template<class T>
cmtk::SmartPointer< T >::SmartPointer (  ) [inline]

Default constructor.

Definition at line 81 of file cmtkSmartPtr.h.

template<class T>
cmtk::SmartPointer< T >::SmartPointer ( T *const   object ) [inline, explicit]

Construct from dumb pointer.

Note that you MUST NEVER use this constructor more than once for each dumb pointer, other than NULL!

Definition at line 87 of file cmtkSmartPtr.h.

template<class T>
template<class T2 >
cmtk::SmartPointer< T >::SmartPointer ( const SmartPointer< T2 > &  ptr ) [inline]

Copy constructor template.

Definition at line 92 of file cmtkSmartPtr.h.

template<class T>
cmtk::SmartPointer< T >::SmartPointer ( const Self ptr ) [inline]

Copy constructor to prevent compiler-generated copy constructor.

Definition at line 96 of file cmtkSmartPtr.h.

template<class T>
cmtk::SmartPointer< T >::SmartPointer ( T *const   object,
SafeCounter *const   counter 
) [inline, private]

Construct from dumb pointer and existing reference counter.

The reference counter is increased in the process.

Definition at line 128 of file cmtkSmartPtr.h.


Member Function Documentation

template<class T>
template<class T2 >
static Self cmtk::SmartPointer< T >::DynamicCastFrom ( const T2 &  from_P ) [inline, static]

Dynamic cast between smart pointer types.

Reimplemented from cmtk::SmartConstPointer< T >.

Definition at line 119 of file cmtkSmartPtr.h.

template<class T>
T* cmtk::SmartPointer< T >::GetPtr (  ) const [inline]

Explicit conversion to non-constant pointer.

Definition at line 105 of file cmtkSmartPtr.h.

template<class T>
T& cmtk::SmartPointer< T >::operator* (  ) [inline]

De-referencing operator (returns non-constant object).

Definition at line 99 of file cmtkSmartPtr.h.

template<class T>
T* cmtk::SmartPointer< T >::operator-> (  ) [inline]

De-referencing operator (returns non-constant object pointer).

Definition at line 102 of file cmtkSmartPtr.h.

template<class T>
T* cmtk::SmartPointer< T >::ReleasePtr (  ) [inline]

Release control of this pointer.

Note:
This is a dangerous function. Be sure you know what you are doing!

Reimplemented from cmtk::SmartConstPointer< T >.

Definition at line 110 of file cmtkSmartPtr.h.


Friends And Related Function Documentation

template<class T>
friend class SmartPointer [friend]

Make all template instances friends for easy type casting.

Definition at line 131 of file cmtkSmartPtr.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines