00001 /****************************************************************************\ 00002 * * 00003 * 22.05.2005 * 00004 * IManagedObject - Header File * 00005 * * 00006 * (c) Raphael Charwot * 00007 * * 00008 \****************************************************************************/ 00009 00010 #ifndef __IMANAGEDOBJECT_H__ 00011 #define __IMANAGEDOBJECT_H__ 00012 00013 /****************************************************************************\ 00014 * REQUIRED HEADERS * 00015 \****************************************************************************/ 00016 #include <Definitions.h> 00017 #include <Memory/mmgr.h> 00018 00019 /****************************************************************************\ 00020 * DEFINITIONS * 00021 \****************************************************************************/ 00022 00023 /****************************************************************************\ 00024 * CLASS * 00025 \****************************************************************************/ 00026 class IManagedObject 00027 { 00028 /**************************************************************************\ 00029 * PUBLIC CLASS FUNCTIONS * 00030 \**************************************************************************/ 00031 public: 00032 virtual ~IManagedObject() {} 00033 00034 inline void AddRef() {++m_wRefCount;} 00035 inline bool Release() {return (--m_wRefCount <= 0);} 00036 00037 inline word GetRefCount() const {return m_wRefCount;} 00038 00039 /**************************************************************************\ 00040 * PROTECTED CLASS FUNCTIONS * 00041 \**************************************************************************/ 00042 protected: 00043 //Protected constructor to prevent direct instantiation (this is an interface, man!) 00044 IManagedObject() : m_wRefCount(0) {} 00045 00046 /**************************************************************************\ 00047 * PRIVATE CLASS FUNCTIONS * 00048 \**************************************************************************/ 00049 private: 00050 //Copy constructor and assignment operator: 00051 IManagedObject(const IManagedObject &); 00052 IManagedObject &operator=(const IManagedObject &); 00053 00054 /**************************************************************************\ 00055 * PRIVATE CLASS MEMBERS * 00056 \**************************************************************************/ 00057 private: 00058 word m_wRefCount; 00059 }; 00060 00061 #endif