send answerEnq
[enigma2.git] / lib / base / object.h
index ddb4512c2dea94c2b775c015768fbfc23ccccda5..edd68a86e88bb28bf9ba5018024f407bd4501b27 100644 (file)
@@ -14,6 +14,11 @@ typedef int RESULT;
 
 class iObject
 {
 
 class iObject
 {
+private:
+               /* we don't allow the default operator here, as it would break the refcount. */
+       void operator=(const iObject &);
+protected:
+       virtual ~iObject() { }
 public:
        virtual void AddRef()=0;
        virtual void Release()=0;
 public:
        virtual void AddRef()=0;
        virtual void Release()=0;
@@ -25,14 +30,29 @@ class oRefCount
 public:
        oRefCount(): ref(0) { }
        operator int&() { return ref; }
 public:
        oRefCount(): ref(0) { }
        operator int&() { return ref; }
+       ~oRefCount() { 
+#ifdef OBJECT_DEBUG
+               if (ref) eDebug("OBJECT_DEBUG FATAL: %p has %d references!", this, ref); else eDebug("OBJECT_DEBUG refcount ok! (%p)", this); 
+#endif
+       }
 };
 
 };
 
-#define DECLARE_REF private: oRefCount ref; public: void AddRef(); void Release();
+#ifndef SWIG
+#define DECLARE_REF(x) private: oRefCount ref; public: void AddRef(); void Release();
 #ifdef OBJECT_DEBUG
 extern int object_total_remaining;
 #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; }
 #else
 #define DEFINE_REF(c) void c::AddRef() { ++ref; } void c::Release() { if (!--ref) delete this; }
 #endif
 #ifdef OBJECT_DEBUG
 extern int object_total_remaining;
 #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; }
 #else
 #define DEFINE_REF(c) void c::AddRef() { ++ref; } void c::Release() { if (!--ref) delete this; }
 #endif
+#else
+#define DECLARE_REF(x) private: void AddRef(); void Release();
+#endif
+
+#ifdef SWIG
+class Object
+{
+};
+#endif
 
 #endif
 
 #endif