/** * Copyright Mikael Högdahl - triyana@users.sourceforge.com * * This source is distributed under the terms of the Q Public License version 1.0, * created by Trolltech (www.trolltech.com). */ #ifndef MH_h #define MH_h #include "MHUtil.h" class MHVector; #ifdef BUGG #define MHINCREF aaReference++ #define MHDECREF aaReference-- #define ASS(val) if (val == 0) {printf ("ASSERT file=%s - line=%d", __FILE__, __LINE__); exit(1);} #define ASSERT_POINTER(a) if (a == 0) {sprintf (debugBuffer, "ASSERT file=%s - line=%d", __FILE__, __LINE__); throw debugBuffer;} #else #define MHINCREF #define MHDECREF #define ASS(val) #define ASSERT_POINTER(a) #endif /** * Base object for assorted utility objects. * To use the reference counter, define compile flag BUGG to use it, * and get number of allocated objects with GetReference method. */ class MH { public: enum a { ERR = 0, OK, }; MH() {MHINCREF;} virtual ~MH() {MHDECREF;} virtual const char* Class () {return "MH";} virtual int Compare (const MH* o, int f) {return 0;} virtual void Message (const MH* sender, const char* m1 = 0, const char* m2 = 0, const char* m3 = 0, void* m4 = 0) {;} virtual const char* ToString () {return "MH";} virtual const char* HashKey () {return "MH";} void IsChanged (bool flag) {aDirty = flag;} bool IsChanged () {return aDirty;} static void ClearChanged (MHVector* ve); #ifdef BUGG static int GetReference() {return aaReference;} #else static int GetReference() {return -1;} #endif static bool IsVectorChanged (MHVector* ve); private: bool aDirty; #ifdef BUGG static int aaReference; #endif }; #endif