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>
12 #include <lib/base/elock.h>
19 /* we don't allow the default operator here, as it would break the refcount. */
20 void operator=(const iObject &);
22 virtual ~iObject() { }
24 virtual void AddRef()=0;
25 virtual void Release()=0;
32 oRefCount(): ref(0) { }
33 operator int&() { return ref; }
36 if (ref) eDebug("OBJECT_DEBUG FATAL: %p has %d references!", this, ref); else eDebug("OBJECT_DEBUG refcount ok! (%p)", this);
43 #define DECLARE_REF(x) \
44 private: oRefCount ref; \
45 public: void AddRef(); \
47 #define DEFINE_REF(c) \
51 __asm__ __volatile__( \
60 : "=&r" (temp), "=m" ((int)ref) \
67 __asm__ __volatile__( \
76 : "=&r" (temp), "=m" ((int)ref) \
83 #define DECLARE_REF(x) \
84 private:oRefCount ref; \
85 eSingleLock ref_lock; \
86 public: void AddRef(); \
89 extern int object_total_remaining;
90 #define DEFINE_REF(c) \
93 eSingleLocker l(ref_lock); \
94 ++object_total_remaining; \
96 eDebug("OBJECT_DEBUG " #c "+%p now %d", this, (int)ref); \
101 eSingleLocker l(ref_lock); \
102 --object_total_remaining; \
104 eDebug("OBJECT_DEBUG " #c "-%p now %d", this, ref); \
109 #error fix locking for debug
111 #define DEFINE_REF(c) \
114 eSingleLocker l(ref_lock); \
120 eSingleLocker l(ref_lock); \
129 #define DECLARE_REF(x) \