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

JobCleaner.h

Go to the documentation of this file.
00001 
00002 // $Id: JobCleaner.h,v 1.1 2002/04/02 23:54:56 messier Exp $
00003 //
00004 // This bogus little class is a work around for cint's lazy handling of
00005 // deleting object at scope boundaries. At the end of a job the JobC
00006 // object *must* be deleted or the module EndJob methods will not be
00007 // called leaving files open etc. etc. This cleaner object forces
00008 // deletion of any remaining JobC objects at the end of the job. If
00009 // root ever improves its object management, this class will become
00010 // obsolete.
00011 //
00012 // messier@huhepl.harvard.edu
00014 #ifndef JOBCLEANER_H
00015 #ifndef VECTOR
00016 # include <vector>
00017 # define VECTOR
00018 #endif
00019 class JobC;
00020 
00021 class JobCleaner
00022 {
00023 public:
00024   ~JobCleaner();
00025 
00026   void Add(JobC* j);
00027   void Remove(JobC* j);
00028   void Reap();
00029 
00030   static JobCleaner& Instance();
00031   // Helper class to handle deletion of singleton
00032   struct Cleaner {
00033     void ClassIsUsed() { }; // Dummy to quiet compilers...
00034     ~Cleaner() { 
00035       if (JobCleaner::fInstance) {
00036         delete JobCleaner::fInstance;
00037         JobCleaner::fInstance = 0;
00038       }
00039     }
00040   };
00041   friend struct Cleaner;
00042 
00043 private:
00044   JobCleaner();
00045 
00046   static JobCleaner* fInstance;
00047   std::vector<JobC*> fJobCList;
00048 };
00049 #endif // JOBCLEANER_H
00050 

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