25 #define __A2DONLYFILE__(fname) (strchr(fname,'\\') ? strrchr(fname,'\\')+1 : fname)
26 #define __A2DFILE__ __A2DONLYFILE__(__FILE__)
29 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
37 A2DGENERALDLLEXP_DATA (
extern wxObject* ) CurrentSmartPointerOwner;
39 struct A2DGENERALDLLEXP a2dInitCurrentSmartPointerOwner
42 a2dInitCurrentSmartPointerOwner( wxObject*
object )
44 CurrentSmartPointerOwner = object;
63 template<
class T>
static void OwnRef( T* pRefObject ) {
if( pRefObject ) pRefObject->SmrtPtrOwn(); }
64 template<
class T>
static void ReleaseRef( T* pRefObject ) {
if( pRefObject ) pRefObject->SmrtPtrRelease(); }
146 RmvFromPointerList();
153 Clss* ptrold = m_ptr;
154 RmvFromPointerList();
158 ReleaseRef( ptrold );
161 void operator=( Clss* objc )
163 Clss* ptrold = m_ptr;
164 RmvFromPointerList();
168 ReleaseRef( ptrold );
173 return a.m_ptr == b.m_ptr;
178 return a.m_ptr != b.m_ptr;
183 friend inline bool operator==(
const a2dSmrtPtr& a,
const Clss* b )
188 friend inline bool operator!=(
const a2dSmrtPtr& a,
const Clss* b )
193 friend inline bool operator==(
const Clss* a,
const a2dSmrtPtr& b )
198 friend inline bool operator!=(
const Clss* a,
const a2dSmrtPtr& b )
203 friend inline bool operator==(
const a2dSmrtPtr& a, Clss* b )
208 friend inline bool operator!=(
const a2dSmrtPtr& a, Clss* b )
213 friend inline bool operator==( Clss* a,
const a2dSmrtPtr& b )
218 friend inline bool operator!=( Clss* a,
const a2dSmrtPtr& b )
223 inline operator Clss* ()
const {
return m_ptr; }
225 inline Clss* Get()
const
230 inline Clss* operator->()
const {
return m_ptr; }
232 inline Clss& operator*()
const {
return *m_ptr; }
239 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
240 a2dSmrtPtr(
const wxChar* filename,
int linenum )
244 m_filename = filename;
247 a2dSmrtPtr(
const wxChar* filename,
int linenum, Clss* objc )
250 m_filename = filename;
259 m_filename = filename;
271 const wxChar* m_filename;
277 owner_smartpointerlist
280 void PointerListInit()
289 if( (
char* )
this - (
char* )CurrentSmartPointerOwner < 1024 )
291 m_owner = CurrentSmartPointerOwner;
292 m_ownertype = owner_wxobject;
297 m_ownertype = owner_none;
301 void AddToPointerList()
306 m_next->m_prvs =
this;
308 m_ptr->m_ownerlist = (
typename Clss::TOwnerListClass* )
this;
311 void RmvFromPointerList()
315 m_prvs->m_next = m_next;
317 m_ptr->m_ownerlist = (
typename Clss::TOwnerListClass* ) m_next;
319 m_next->m_prvs = m_prvs;
322 void PointerListInit() {}
323 void AddToPointerList() {}
324 void RmvFromPointerList() {}
328 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
329 #define a2dDECLARE_GLOBAL_VAR(type, var) type var(__FILE__,__LINE__)
330 #define a2dDECLARE_GLOBAL_ITEM(type, var, item) type var(__FILE__,__LINE__,item)
331 #define a2dDECLARE_LOCAL_ITEM(type, var, item) CurrentSmartPointerOwner = this;\
332 type var(__FILE__,__LINE__,item)
334 #define a2dDECLARE_GLOBAL_VAR(type, var) type var
335 #define a2dDECLARE_GLOBAL_ITEM(type, var, item) type var(item)
336 #define a2dDECLARE_LOCAL_ITEM(type, var, item) type var(item)
374 RmvFromPointerList();
382 for( crnt =
this; crnt; crnt = next )
393 RmvFromPointerList();
398 void operator=( Clss* objc )
400 RmvFromPointerList();
407 return a.m_ptr == b.m_ptr;
412 return a.m_ptr != b.m_ptr;
417 friend inline bool operator==(
const a2dAutoZeroPtr& a,
const Clss* b )
422 friend inline bool operator!=(
const a2dAutoZeroPtr& a,
const Clss* b )
427 friend inline bool operator==(
const Clss* a,
const a2dAutoZeroPtr& b )
432 friend inline bool operator!=(
const Clss* a,
const a2dAutoZeroPtr& b )
457 inline operator Clss* ()
const {
return m_ptr; }
459 inline Clss* Get()
const
464 inline Clss* operator->()
const {
return m_ptr; }
466 inline Clss& operator*()
const {
return *m_ptr; }
470 void PointerListInit()
477 void AddToPointerList()
483 m_next->m_prvs =
this;
488 void RmvFromPointerList()
493 m_prvs->m_next = m_next;
501 m_next->m_prvs = m_prvs;
545 return a.m_ptr == b.m_ptr;
550 return a.m_ptr != b.m_ptr;
555 friend inline bool operator==(
const a2dDumbPtr& a,
const Clss* b )
560 friend inline bool operator!=(
const a2dDumbPtr& a,
const Clss* b )
565 friend inline bool operator==(
const Clss* a,
const a2dDumbPtr& b )
570 friend inline bool operator!=(
const Clss* a,
const a2dDumbPtr& b )
575 friend inline bool operator==(
const a2dDumbPtr& a, Clss* b )
580 friend inline bool operator!=(
const a2dDumbPtr& a, Clss* b )
585 friend inline bool operator==( Clss* a,
const a2dDumbPtr& b )
590 friend inline bool operator!=( Clss* a,
const a2dDumbPtr& b )
595 inline operator Clss* ()
const {
return m_ptr; }
601 inline Clss* Get()
const
606 inline Clss* operator->()
const {
return m_ptr; }
608 inline Clss& operator*()
const {
return *m_ptr; }
632 itSmart
Find( T*
object );
635 const_itSmart
Find( T*
object )
const;
638 int IndexOf( T*
object )
const;
662 itSmart
Find( T*
object );
665 const_itSmart
Find( T*
object )
const;
668 int IndexOf( T*
object )
const;
675 #if defined(WXDOCVIEW_USINGDLL)
679 #endif // __SMRTPTR_H__
A trivial base class for a2dSmrtPtr. Non-template class, so that it can.
int IndexOf(T *object) const
Find the index of a specific object.
itSmart Find(T *object)
Find a specific object.
A pointer class, that is automatically set to 0 if the target is deleted.
A list class for reference counted objects.
basic list class based on STL containers.
bool RemoveObject(T *object)
release a certain object from the list
bool ReleaseObject(T *object)
release a certain object from the list
void TargetDestructing()
This is called from the targets destructor.
A pointer class, that does not call SmrtPtrOwn/SmrtPtrRelease, but initializes to 0...
A list class for reference counted objects.
itSmart Find(T *object)
Find a specific object.
A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease.
int IndexOf(T *object) const
Find the index of a specific object.