Medical Imaging Interaction Toolkit
2023.12.00
Medical Imaging Interaction Toolkit
|
Go to the documentation of this file.
13 #ifndef BERRYSMARTPOINTER_H_
14 #define BERRYSMARTPOINTER_H_
23 #include <Poco/Bugcheck.h>
25 #if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
44 template<
class TObjectType>
55 #if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
56 DebugInitSmartPointer();
68 #if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
69 DebugInitSmartPointer();
75 m_Pointer(p.m_Pointer)
79 #if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
80 DebugInitSmartPointer();
86 m_Pointer(const_cast<Other*> (ptr.
GetPointer()))
91 #if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
92 DebugInitSmartPointer();
102 #if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
103 if (m_Pointer) DebugRemoveSmartPointer();
110 template<
class Other>
113 Other* pOther =
dynamic_cast<Other*
> (m_Pointer);
131 poco_assert( m_Pointer !=
nullptr );
138 return m_Pointer !=
nullptr;
142 return m_Pointer ==
nullptr;
149 return m_Pointer ==
nullptr ?
nullptr: &Self::m_Pointer;
156 return (m_Pointer ==
nullptr ? o ==
nullptr : (o && m_Pointer->operator==(o)));
163 return (m_Pointer ==
nullptr ? o ==
nullptr : (o && m_Pointer->operator==(o)));
169 return m_Pointer ==
nullptr;
171 throw std::invalid_argument(
"Can only compare to 0");
189 return m_Pointer !=
nullptr;
191 throw std::invalid_argument(
"Can only compare to 0");
219 return m_Pointer ==
nullptr ? o == nullptr : o && m_Pointer->operator<(o);
227 return m_Pointer == 0 ? o == 0 : o && m_Pointer->operator>(o);
262 #if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
263 DebugAssignSmartPointer(r, m_Pointer);
277 QDebug
Print(QDebug os)
const;
288 m_Pointer->Register();
296 m_Pointer->UnRegister();
300 #if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
305 void DebugInitSmartPointer();
307 void DebugRemoveSmartPointer();
322 os << p->ToString().toStdString();
331 return sp->HashCode();
342 return sp->HashCode();
351 template<
class Other>
356 this->m_Pointer = wp.m_Pointer;
359 #if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
360 DebugInitSmartPointer();
365 throw BadWeakPointerException(
"Weak pointer is nullptr");
374 (*m_Pointer).Print(os);
380 #if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
387 void SmartPointer<T>::DebugInitSmartPointer()
390 QMutexLocker lock(&m_Mutex);
405 void SmartPointer<T>::DebugRemoveSmartPointer()
407 QMutexLocker lock(&m_Mutex);
412 void SmartPointer<T>::DebugAssignSmartPointer(
const ObjectType* newObject,
const ObjectType* oldObject)
414 QMutexLocker lock(&m_Mutex);
430 int SmartPointer<T>::GetId()
bool operator>=(const SmartPointer< R > &r) const
ObjectType * operator->() const
SmartPointer(const SmartPointer< ObjectType > &p)
SmartPointer(ObjectType *p)
SmartPointer & operator=(const SmartPointer &r)
static void RegisterSmartPointer(unsigned int smartPointerId, const Object *objectPointer, bool recordStack=false)
Implements transparent reference counting.
SmartPointer< ObjectType > Lock() const
QDebug Print(QDebug os) const
ObjectType * GetPointer() const
bool operator<(const SmartPointer< R > &r) const
bool operator==(const R *o) const
bool operator>(const SmartPointer< R > &r) const
static unsigned int & GetSmartPointerCounter()
static void UnregisterSmartPointer(unsigned int smartPointerId, const Object *objectPointer)
bool operator<=(const SmartPointer< R > &r) const
ObjectType & operator*() const
uint qHash(const berry::SmartPointer< T > &sp)
bool operator!=(const R *r) const
org_blueberry_core_runtime_EXPORT QDebug operator<<(QDebug os, const berry::Indent &o)
SmartPointer(const SmartPointer< Other > &ptr)
SmartPointer< Other > Cast() const
implements a WeakPointer class to deal with circular reference problems.
ObjectType *Self::* unspecified_bool_type