Smart pointer with reference counting. More...
#include <cmtkSmartConstPtr.h>
Public Types | |
typedef SmartConstPointer< T > | Self |
This class instance. | |
typedef const T * | PointerType |
The underlying raw pointer type. | |
Public Member Functions | |
unsigned int | GetReferenceCount () const |
Get current reference counter value: use with caution! | |
SmartConstPointer () | |
Default constructor. | |
SmartConstPointer (T *const object) | |
Construct from dumb pointer. | |
template<class T2 > | |
SmartConstPointer (const SmartConstPointer< T2 > &ptr) | |
Copy constructor template. | |
SmartConstPointer (const Self &ptr) | |
Copy constructor to prevent compiler-generated copy constructor. | |
~SmartConstPointer () | |
Destruct: decrease reference pointer and free dumb pointer if necessary. | |
const T & | operator* () const |
De-referencing operator (returns constant object). | |
const T * | operator-> () const |
De-referencing operator (returns constant object pointer). | |
operator const T * () const | |
Implicit conversion to constant pointer. | |
const T * | GetConstPtr () const |
Explicit conversion to constant pointer. | |
const T * | ReleasePtr () |
Release control of this pointer. | |
const Self & | operator= (const Self other) const |
Assignment operator. | |
bool | operator== (const Self &other) const |
Equality operator using pointer. | |
bool | operator!= (const Self &other) const |
Inequality operator. | |
bool | operator< (const Self &other) const |
"Smaller than" operator (necessay for storing objects in std::map). | |
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. | |
Protected Member Functions | |
SmartConstPointer (const T *const object, SafeCounter *const counter) | |
Construct from dumb pointer and existing reference counter. | |
Protected Attributes | |
SafeCounter * | m_ReferenceCount |
Pointer to detached reference counter for this object. | |
union { | |
const T * ptrConst | |
Pointer to const. | |
T * ptr | |
Pointer to non-const. | |
} | m_Object |
Friends | |
class | SmartConstPointer |
Make all template instances friends for easy type casting. |
Smart pointer with reference counting.
Definition at line 57 of file cmtkSmartConstPtr.h.
typedef const T* cmtk::SmartConstPointer< T >::PointerType |
The underlying raw pointer type.
Reimplemented in cmtk::SmartPointer< T >, cmtk::SmartPointer< Item >, cmtk::SmartPointer< Self >, cmtk::SmartPointer< EnumGroupBase >, cmtk::SmartPointer< DirectionSet >, cmtk::SmartPointer< matrix2D >, cmtk::SmartPointer< VM >, cmtk::SmartPointer< Landmark >, cmtk::SmartPointer< KeyToActionSingle >, and cmtk::SmartPointer< Study >.
Definition at line 64 of file cmtkSmartConstPtr.h.
typedef SmartConstPointer<T> cmtk::SmartConstPointer< T >::Self |
This class instance.
Reimplemented in cmtk::SmartPointer< T >, cmtk::SmartPointer< Item >, cmtk::SmartPointer< Self >, cmtk::SmartPointer< EnumGroupBase >, cmtk::SmartPointer< DirectionSet >, cmtk::SmartPointer< matrix2D >, cmtk::SmartPointer< VM >, cmtk::SmartPointer< Landmark >, cmtk::SmartPointer< KeyToActionSingle >, and cmtk::SmartPointer< Study >.
Definition at line 61 of file cmtkSmartConstPtr.h.
cmtk::SmartConstPointer< T >::SmartConstPointer | ( | ) | [inline] |
Default constructor.
This needs to be separate because the constructor that takes a dumb pointer must be explicit, but the default constructor should not be.
Definition at line 79 of file cmtkSmartConstPtr.h.
cmtk::SmartConstPointer< T >::SmartConstPointer | ( | 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 89 of file cmtkSmartConstPtr.h.
cmtk::SmartConstPointer< T >::SmartConstPointer | ( | const SmartConstPointer< T2 > & | ptr ) | [inline] |
Copy constructor template.
Increment reference counter in the process.
Definition at line 99 of file cmtkSmartConstPtr.h.
cmtk::SmartConstPointer< T >::SmartConstPointer | ( | const Self & | ptr ) | [inline] |
Copy constructor to prevent compiler-generated copy constructor.
Increment reference counter in the process.
Definition at line 109 of file cmtkSmartConstPtr.h.
cmtk::SmartConstPointer< T >::~SmartConstPointer | ( | ) | [inline] |
Destruct: decrease reference pointer and free dumb pointer if necessary.
Definition at line 117 of file cmtkSmartConstPtr.h.
cmtk::SmartConstPointer< T >::SmartConstPointer | ( | const T *const | object, |
SafeCounter *const | counter | ||
) | [inline, protected] |
Construct from dumb pointer and existing reference counter.
The reference counter is increased in the process.
Definition at line 220 of file cmtkSmartConstPtr.h.
static Self cmtk::SmartConstPointer< T >::DynamicCastFrom | ( | const T2 & | from_P ) | [inline, static] |
Dynamic cast between smart pointer types.
Reimplemented in cmtk::SmartPointer< T >, cmtk::SmartPointer< Item >, cmtk::SmartPointer< Self >, cmtk::SmartPointer< EnumGroupBase >, cmtk::SmartPointer< DirectionSet >, cmtk::SmartPointer< matrix2D >, cmtk::SmartPointer< VM >, cmtk::SmartPointer< Landmark >, cmtk::SmartPointer< KeyToActionSingle >, and cmtk::SmartPointer< Study >.
Definition at line 199 of file cmtkSmartConstPtr.h.
const T* cmtk::SmartConstPointer< T >::GetConstPtr | ( | ) | const [inline] |
Explicit conversion to constant pointer.
Definition at line 146 of file cmtkSmartConstPtr.h.
unsigned int cmtk::SmartConstPointer< T >::GetReferenceCount | ( | ) | const [inline] |
Get current reference counter value: use with caution!
Definition at line 70 of file cmtkSmartConstPtr.h.
cmtk::SmartConstPointer< T >::operator const T * | ( | ) | const [inline] |
Implicit conversion to constant pointer.
Definition at line 143 of file cmtkSmartConstPtr.h.
bool cmtk::SmartConstPointer< T >::operator!= | ( | const Self & | other ) | const [inline] |
Inequality operator.
Definition at line 185 of file cmtkSmartConstPtr.h.
const T& cmtk::SmartConstPointer< T >::operator* | ( | ) | const [inline] |
De-referencing operator (returns constant object).
Definition at line 137 of file cmtkSmartConstPtr.h.
const T* cmtk::SmartConstPointer< T >::operator-> | ( | ) | const [inline] |
De-referencing operator (returns constant object pointer).
Definition at line 140 of file cmtkSmartConstPtr.h.
bool cmtk::SmartConstPointer< T >::operator< | ( | const Self & | other ) | const [inline] |
"Smaller than" operator (necessay for storing objects in std::map).
Definition at line 192 of file cmtkSmartConstPtr.h.
const Self& cmtk::SmartConstPointer< T >::operator= | ( | const Self | other ) | const [inline] |
Assignment operator.
This is implemented using the std::swap function.
Definition at line 167 of file cmtkSmartConstPtr.h.
bool cmtk::SmartConstPointer< T >::operator== | ( | const Self & | other ) | const [inline] |
Equality operator using pointer.
Definition at line 178 of file cmtkSmartConstPtr.h.
const T* cmtk::SmartConstPointer< T >::ReleasePtr | ( | ) | [inline] |
Release control of this pointer.
Reimplemented in cmtk::SmartPointer< T >, cmtk::SmartPointer< Item >, cmtk::SmartPointer< Self >, cmtk::SmartPointer< EnumGroupBase >, cmtk::SmartPointer< DirectionSet >, cmtk::SmartPointer< matrix2D >, cmtk::SmartPointer< VM >, cmtk::SmartPointer< Landmark >, cmtk::SmartPointer< KeyToActionSingle >, and cmtk::SmartPointer< Study >.
Definition at line 151 of file cmtkSmartConstPtr.h.
friend class SmartConstPointer [friend] |
Make all template instances friends for easy type casting.
Definition at line 228 of file cmtkSmartConstPtr.h.
union { ... } cmtk::SmartConstPointer< T >::m_Object [protected] |
SafeCounter* cmtk::SmartConstPointer< T >::m_ReferenceCount [mutable, protected] |
Pointer to detached reference counter for this object.
Definition at line 206 of file cmtkSmartConstPtr.h.
Referenced by cmtk::SmartConstPointer< Study >::operator=().
T* cmtk::SmartConstPointer< T >::ptr |
Pointer to non-const.
Definition at line 214 of file cmtkSmartConstPtr.h.
const T* cmtk::SmartConstPointer< T >::ptrConst |
Pointer to const.
Definition at line 212 of file cmtkSmartConstPtr.h.
Referenced by cmtk::SmartConstPointer< Study >::operator!=(), cmtk::SmartConstPointer< Study >::operator<(), cmtk::SmartConstPointer< Study >::operator=(), cmtk::SmartConstPointer< Study >::operator==(), and cmtk::SmartConstPointer< Study >::SmartConstPointer().