fix return value
[enigma2.git] / lib / base / object.h
1 #ifndef __base_object_h
2 #define __base_object_h
3
4 #include <assert.h>
5
6 // #define OBJECT_DEBUG
7
8 #include <lib/base/smartptr.h>
9 #ifdef OBJECT_DEBUG
10 #include <lib/base/eerror.h>
11 #endif
12
13 typedef int RESULT;
14
15 class iObject
16 {
17 public:
18         virtual void AddRef()=0;
19         virtual void Release()=0;
20 };
21
22 #define DECLARE_REF private: int ref; public: void AddRef(); void Release();
23 #ifdef OBJECT_DEBUG
24 extern int object_total_remaining;
25 #define DEFINE_REF(c) void c::AddRef() { ++object_total_remaining; ++ref; eDebug("OBJECT_DEBUG " #c "+%p now %d", this, ref); } void c::Release() { --object_total_remaining; eDebug("OBJECT_DEBUG " #c "-%p now %d", this, ref-1); if (!--ref) delete this; }
26 #else
27 #define DEFINE_REF(c) void c::AddRef() { ++ref; } void c::Release() { if (!--ref) delete this; }
28 #endif
29
30 #endif