Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

LeaLeakChecker.h

Go to the documentation of this file.
00001 // $Id: LeaLeakChecker.h,v 1.5 2002/10/16 08:22:51 rhatcher Exp $
00002 
00003 #ifndef LEALEAKCHECKER_H
00004 #define LEALEAKCHECKER_H
00005 
00007 // LeaLeakChecker                                                     //
00008 //                                                                    //
00009 // Package: Lea (Leak Checker).                                       //
00010 //                                                                    //
00011 // Concept:  Leak Checker controller.                                 //
00012 //                                                                    //
00013 // N. West  03/2000                                                   //
00015 
00016 #include <map>
00017 #include <string>
00018 #include <iosfwd>
00019 
00020 // not inheriting from TObject so we need an explicit Rtypes
00021 // for Char_t typedef, but hit it from CINT
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 // Typedefs and enumerations
00038   typedef  std::map<std::string,LeaClassMonitor*>::iterator MapItr; 
00039   typedef  std::map<std::string,LeaClassMonitor*>::const_iterator MapConstItr; 
00040 
00041 // Constructors and destructors
00042   virtual ~LeaLeakChecker();
00043 
00044 // State testing member functions.
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 // State changing member functions
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 // Helper class to handle deletion of singleton
00060 //   (cribbed from JobCEnv).
00061  struct Cleaner {
00062    void ClassIsUsed() { }; // Dummy method to keep compilers quiet
00063    ~Cleaner() {
00064      if (LeaLeakChecker::fgInstance) {
00065        delete LeaLeakChecker::fgInstance;
00066        LeaLeakChecker::fgInstance = 0;
00067      }
00068    }
00069  };
00070  friend struct Cleaner;
00071 
00072 // Constructors and destructors
00073            LeaLeakChecker();
00074 
00075 // Data members.
00076    std::map<std::string,LeaClassMonitor*> fMonitors; // Monitors by class name.
00077 
00078   static LeaLeakChecker *fgInstance; // Sole instance of leak checker
00079   
00080 
00081 ClassDef(LeaLeakChecker,0)     //Leak Checker controller 
00082 
00083 };
00084 
00085 #endif  // LEALEAKCHECKER_H

Generated on Mon Feb 15 11:06:51 2010 for loon by  doxygen 1.3.9.1