Smart pointer with reference counting. More...
#include <cmtkSmartPtr.h>
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. |
Smart pointer with reference counting.
Definition at line 57 of file cmtkSmartPtr.h.
typedef T* cmtk::SmartPointer< T >::PointerType |
The underlying raw pointer type.
Reimplemented from cmtk::SmartConstPointer< T >.
Definition at line 74 of file cmtkSmartPtr.h.
typedef SmartPointer<T> cmtk::SmartPointer< T >::Self |
This class instance.
Reimplemented from cmtk::SmartConstPointer< T >.
Definition at line 63 of file cmtkSmartPtr.h.
typedef SmartConstPointer<T> cmtk::SmartPointer< T >::Superclass |
This class instance.
Definition at line 66 of file cmtkSmartPtr.h.
cmtk::SmartPointer< T >::SmartPointer | ( | ) | [inline] |
Default constructor.
Definition at line 81 of file cmtkSmartPtr.h.
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.
cmtk::SmartPointer< T >::SmartPointer | ( | const SmartPointer< T2 > & | ptr ) | [inline] |
Copy constructor template.
Definition at line 92 of file cmtkSmartPtr.h.
cmtk::SmartPointer< T >::SmartPointer | ( | const Self & | ptr ) | [inline] |
Copy constructor to prevent compiler-generated copy constructor.
Definition at line 96 of file cmtkSmartPtr.h.
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.
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.
T* cmtk::SmartPointer< T >::GetPtr | ( | ) | const [inline] |
Explicit conversion to non-constant pointer.
Definition at line 105 of file cmtkSmartPtr.h.
T& cmtk::SmartPointer< T >::operator* | ( | ) | [inline] |
De-referencing operator (returns non-constant object).
Definition at line 99 of file cmtkSmartPtr.h.
T* cmtk::SmartPointer< T >::operator-> | ( | ) | [inline] |
De-referencing operator (returns non-constant object pointer).
Definition at line 102 of file cmtkSmartPtr.h.
T* cmtk::SmartPointer< T >::ReleasePtr | ( | ) | [inline] |
Release control of this pointer.
Reimplemented from cmtk::SmartConstPointer< T >.
Definition at line 110 of file cmtkSmartPtr.h.
friend class SmartPointer [friend] |
Make all template instances friends for easy type casting.
Definition at line 131 of file cmtkSmartPtr.h.