1 #ifndef __base_object_h
2 #define __base_object_h
6 // #define OBJECT_DEBUG
8 #include <lib/base/smartptr.h>
10 #include <lib/base/eerror.h>
18 virtual void AddRef()=0;
19 virtual void Release()=0;
26 oRefCount(): ref(0) { }
27 operator int&() { return ref; }
30 #define DECLARE_REF private: oRefCount ref; public: void AddRef(); void Release();
32 extern int object_total_remaining;
33 #define DEFINE_REF(c) void c::AddRef() { ++object_total_remaining; ++ref; eDebug("OBJECT_DEBUG " #c "+%p now %d", this, (int)ref); } void c::Release() { --object_total_remaining; eDebug("OBJECT_DEBUG " #c "-%p now %d", this, ref-1); if (!--ref) delete this; }
35 #define DEFINE_REF(c) void c::AddRef() { ++ref; } void c::Release() { if (!--ref) delete this; }