Go to the documentation of this file.
30 #ifndef __NMV_SAFE_PTR_H__
31 #define __NMV_SAFE_PTR_H__
51 free (
const_cast<void *
> (a_ptr));
56 template <
class Po
interType>
67 template<
class PointerType,
78 explicit SafePtr (
const PointerType *a_pointer,
bool a_do_ref=
false) :
79 m_pointer (const_cast<PointerType*> (a_pointer))
92 UnreferenceFunctor> &a_safe_ptr) :
107 UnreferenceFunctor> &a_safe_ptr)
111 UnreferenceFunctor> temp (a_safe_ptr);
140 UnreferenceFunctor> &a_safe_ptr)
const
142 return m_pointer == a_safe_ptr.m_pointer;
157 operator bool ()
const
172 UnreferenceFunctor> &a_safe_ptr)
184 reset (
const PointerType *a_pointer,
bool a_do_ref=
false)
188 m_pointer =
const_cast<PointerType*
> (a_pointer);
204 const_cast<SafePtr<PointerType,
206 UnreferenceFunctor
>* > (
this)->
reference ();
214 T *pointer =
dynamic_cast<T*
> (
m_pointer);
233 UnreferenceFunctor> &a_safe_ptr)
237 a_safe_ptr.m_pointer = tmp;
244 ReferenceFunctor do_ref;
253 UnreferenceFunctor do_unref;
262 #endif //__NMV_SAFR_PTR_H__
SafePtr(const PointerType *a_pointer, bool a_do_ref=false)
Definition: nmv-safe-ptr.h:78
~SafePtr()
Definition: nmv-safe-ptr.h:98
SafePtr< PointerType, ReferenceFunctor, UnreferenceFunctor > & operator=(const SafePtr< PointerType, ReferenceFunctor, UnreferenceFunctor > &a_safe_ptr)
Definition: nmv-safe-ptr.h:105
Definition: nmv-address.h:31
bool operator!=(const PointerType *a_pointer)
Definition: nmv-safe-ptr.h:165
void operator()(const void *)
Definition: nmv-safe-ptr.h:41
void unreference()
Definition: nmv-safe-ptr.h:250
SafePtr(const SafePtr< PointerType, ReferenceFunctor, UnreferenceFunctor > &a_safe_ptr)
Definition: nmv-safe-ptr.h:90
PointerType * m_pointer
Definition: nmv-safe-ptr.h:74
bool operator==(const SafePtr< PointerType, ReferenceFunctor, UnreferenceFunctor > &a_safe_ptr) const
Definition: nmv-safe-ptr.h:138
void swap(SafePtr< PointerType, ReferenceFunctor, UnreferenceFunctor > &a_safe_ptr)
Definition: nmv-safe-ptr.h:231
void reset(const PointerType *a_pointer, bool a_do_ref=false)
Definition: nmv-safe-ptr.h:184
void reset()
Definition: nmv-safe-ptr.h:178
PointerType * release()
Definition: nmv-safe-ptr.h:223
PointerType * ref_and_get() const
Definition: nmv-safe-ptr.h:202
Definition: nmv-safe-ptr.h:38
void operator()(const void *a_ptr)
Definition: nmv-safe-ptr.h:48
Definition: nmv-safe-ptr.h:57
void reference()
Definition: nmv-safe-ptr.h:241
PointerType * get() const
Definition: nmv-safe-ptr.h:196
PointerType & operator*() const
Definition: nmv-safe-ptr.h:126
SafePtr()
Definition: nmv-safe-ptr.h:86
bool operator!() const
Definition: nmv-safe-ptr.h:150
Definition: nmv-safe-ptr.h:71
SafePtr< T, ReferenceFunctor, UnreferenceFunctor > do_dynamic_cast()
Definition: nmv-safe-ptr.h:212
Definition: nmv-safe-ptr.h:45
PointerType * operator->() const
Definition: nmv-safe-ptr.h:132
void operator()(const PointerType *a_ptr)
Definition: nmv-safe-ptr.h:60
Definition: nmv-proc-list-dialog.h:32