00001
00002
00003 #ifndef LEALEAKCHECKER_H
00004 #define LEALEAKCHECKER_H
00005
00007
00008
00009
00010
00011
00012
00013
00015
00016 #include <map>
00017 #include <string>
00018 #include <iosfwd>
00019
00020
00021
00022 #ifndef ROOT_Rtypes
00023 #if !defined(__CINT__) || defined(__MAKECINT__)
00024 #include "Rtypes.h"
00025 #endif
00026 #endif
00027
00028 class LeaClassMonitor;
00029 class LeaLeakChecker;
00030
00031 std::ostream& operator<<(std::ostream& os, LeaLeakChecker* l);
00032
00033 class LeaLeakChecker
00034 {
00035 public:
00036
00037
00038 typedef std::map<std::string,LeaClassMonitor*>::iterator MapItr;
00039 typedef std::map<std::string,LeaClassMonitor*>::const_iterator MapConstItr;
00040
00041
00042 virtual ~LeaLeakChecker();
00043
00044
00045 LeaClassMonitor* GetExistingMonitor(const Char_t* name) const;
00046 UInt_t GetNumActive(const Char_t* name = 0) const;
00047 UInt_t GetNumCreated(const Char_t* name = 0) const;
00048 std::ostream& Print(std::ostream& os);
00049
00050
00051 Bool_t Add(const Char_t* name, const void* addr);
00052 LeaClassMonitor* GetMonitor(const Char_t* name);
00053 void Reset(const Char_t* name = 0);
00054 static LeaLeakChecker* Instance();
00055 Bool_t Remove(const Char_t* name, const void* addr);
00056
00057 private:
00058
00059
00060
00061 struct Cleaner {
00062 void ClassIsUsed() { };
00063 ~Cleaner() {
00064 if (LeaLeakChecker::fgInstance) {
00065 delete LeaLeakChecker::fgInstance;
00066 LeaLeakChecker::fgInstance = 0;
00067 }
00068 }
00069 };
00070 friend struct Cleaner;
00071
00072
00073 LeaLeakChecker();
00074
00075
00076 std::map<std::string,LeaClassMonitor*> fMonitors;
00077
00078 static LeaLeakChecker *fgInstance;
00079
00080
00081 ClassDef(LeaLeakChecker,0)
00082
00083 };
00084
00085 #endif // LEALEAKCHECKER_H