32 #ifndef __igtlSmartPointer_h
33 #define __igtlSmartPointer_h
57 template <
class TObjectType>
69 m_Pointer(p.m_Pointer)
86 ObjectType *operator -> ()
const
90 operator ObjectType * ()
const
94 bool IsNotNull()
const
95 {
return m_Pointer != 0; }
97 {
return m_Pointer == 0; }
101 template <
typename R>
102 bool operator == ( R r )
const
103 {
return (m_Pointer == static_cast<const ObjectType*>(r) ); }
105 template <
typename R>
106 bool operator != ( R r )
const
107 {
return (m_Pointer != static_cast<const ObjectType*>(r) ); }
110 ObjectType *GetPointer ()
const
111 {
return m_Pointer; }
115 {
return (
void*)m_Pointer < (
void*) r.m_Pointer; }
119 {
return (
void*)m_Pointer > (
void*) r.m_Pointer; }
123 {
return (
void*)m_Pointer <= (
void*) r.m_Pointer; }
127 {
return (
void*)m_Pointer >= (
void*) r.m_Pointer; }
138 ObjectType* tmp = m_Pointer;
141 if ( tmp ) { tmp->UnRegister(); }
148 ObjectType *Print (std::ostream& os)
const
151 (*m_Pointer).Print(os);
158 ObjectType* m_Pointer;
162 if(m_Pointer) { m_Pointer->Register(); }
167 if(m_Pointer) { m_Pointer->UnRegister(); }
172 template <
typename T>
173 std::ostream& operator<< (std::ostream& os, SmartPointer<T> p)