7 #ifndef CAFU_SMART_POINTER_HPP_INCLUDED
8 #define CAFU_SMART_POINTER_HPP_INCLUDED
17 unsigned int GetRefCount()
const {
return m_RefCount; }
32 mutable unsigned int m_RefCount;
51 if (m_Ptr) m_Ptr->m_RefCount++;
58 if (m_Ptr) m_Ptr->m_RefCount++;
65 if (m_Ptr) m_Ptr->m_RefCount++;
74 if (m_Ptr->m_RefCount == 0)
delete m_Ptr;
87 if (m_Ptr) m_Ptr->m_RefCount++;
92 if (Old->m_RefCount == 0)
delete Old;
99 T*
get()
const {
return m_Ptr; }
112 template<
class U>
bool operator == (U* b)
const {
return m_Ptr == b; }
116 template<
class U>
bool operator != (U* b)
const {
return m_Ptr != b; }
122 bool IsNull()
const {
return m_Ptr == 0; }
133 return static_cast<T*
>(IP.
get());
139 return dynamic_cast<T*
>(IP.
get());
T * operator->() const
The structure dereference operator.
Definition: Pointer.hpp:102
This class implements smart (reference-counted) pointers.
Definition: Pointer.hpp:43
IntrusivePtrT(const IntrusivePtrT< Y > &IP)
The copy constructor (for Y classes that are derived from T).
Definition: Pointer.hpp:62
bool operator==(const IntrusivePtrT &IP) const
The equality operator.
Definition: Pointer.hpp:111
IntrusivePtrT(T *Ptr=0)
The constructor.
Definition: Pointer.hpp:48
~IntrusivePtrT()
The destructor.
Definition: Pointer.hpp:69
T & operator*()
The dereference operator.
Definition: Pointer.hpp:105
bool IsNull() const
A safe alternative for the bool conversion operator.
Definition: Pointer.hpp:122
IntrusivePtrT(const IntrusivePtrT &IP)
The copy constructor.
Definition: Pointer.hpp:55
bool operator!=(const IntrusivePtrT &IP) const
The inequality operator.
Definition: Pointer.hpp:115
T * get() const
Returns the stored pointer.
Definition: Pointer.hpp:99
IntrusivePtrT & operator=(const IntrusivePtrT &IP)
The assignment operator.
Definition: Pointer.hpp:79
A base class for objects that are reference-counted with IntrusivePtrTs.
Definition: Pointer.hpp:13