17 #ifndef __BERRY_WEAK_POINTER_H__
18 #define __BERRY_WEAK_POINTER_H__
39 template<
class TObjectType>
57 m_Pointer(dynamic_cast<ObjectType*>(sptr.GetPointer()))
62 &WeakPointer::ObjectDestroyed));
69 m_Pointer(dynamic_cast<ObjectType*>(p.m_Pointer))
73 &WeakPointer::ObjectDestroyed));
78 m_Pointer(p.m_Pointer)
82 &WeakPointer::ObjectDestroyed));
90 &WeakPointer::ObjectDestroyed));
92 m_Pointer =
const_cast<ObjectType*
>(r.
GetPointer());
95 &WeakPointer::ObjectDestroyed));
104 &WeakPointer::ObjectDestroyed));
106 this->m_Pointer = other.m_Pointer;
109 &WeakPointer::ObjectDestroyed));
114 template<
class Other>
119 &WeakPointer::ObjectDestroyed));
121 this->m_Pointer =
const_cast<ObjectType*
>(other.m_Pointer);
124 &WeakPointer::ObjectDestroyed));
133 return (m_Pointer ==
nullptr ? o ==
nullptr : (o && m_Pointer->operator==(o)));
139 const R* o = r.m_Pointer;
140 return (m_Pointer ==
nullptr ? o ==
nullptr : (o && m_Pointer->operator==(o)));
146 return (
void*) m_Pointer < (
void*) r.m_Pointer;
160 &WeakPointer::ObjectDestroyed));
167 return m_Pointer ==
nullptr;
175 &WeakPointer::ObjectDestroyed));
183 ObjectType *m_Pointer;
185 void ObjectDestroyed()
194 #endif // __BERRY_WEAK_POINTER_H__
WeakPointer(const WeakPointer &p)
WeakPointer(const WeakPointer< Other > &p)
WeakPointer & operator=(const WeakPointer &other)
bool operator<(const WeakPointer &r) const
Implements transparent reference counting.
implements a WeakPointer class to deal with circular reference problems.
WeakPointer(berry::SmartPointer< Other > sptr)
ObjectType * GetPointer() const
WeakPointer & operator=(const WeakPointer< Other > &other)
bool operator==(const R *o) const
SmartPointer< ObjectType > Lock() const
WeakPointer & operator=(const SmartPointer< Other > &r)