00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _REFCOUNTEDOBJECT_H_
00018 #define _REFCOUNTEDOBJECT_H_
00019
00020 #include "../debug/Formatter.h"
00021 #include "../debug/Log.h"
00022 #include "../thread/Atomic.h"
00023
00024 namespace oasys {
00025
00049 class RefCountedObject : public Formatter {
00050 public:
00055 RefCountedObject(const char* logpath);
00056
00060 virtual ~RefCountedObject();
00061
00069 void add_ref(const char* what1, const char* what2 = "") const;
00070
00078 void del_ref(const char* what1, const char* what2 = "") const;
00079
00083 virtual void no_more_refs() const;
00084
00088 int format(char* buf, size_t sz) const;
00089
00093 u_int32_t refcount() const { return refcount_.value; }
00094
00095 protected:
00097 mutable atomic_t refcount_;
00098
00100 Logger logger_;
00101 };
00102
00103 }
00104
00105 #endif