00001 // -*- C++ -*- 00002 00003 #ifndef _included_ObjectCounter_h 00004 #define _included_ObjectCounter_h 00005 00025 class ObjectCounter 00026 { 00027 int references; 00028 public: 00029 inline ObjectCounter() : references(1) { } 00030 inline ObjectCounter *alias() { references++; return(this); } 00031 inline void free() { if (--references == 0) delete this; } 00032 // Make sure all the derived classes have their destructors; 00033 inline virtual ~ObjectCounter() { } 00034 }; 00035 00036 #endif