00001 00002 // $Id: JobCleaner.cxx,v 1.1 2002/04/02 23:54:56 messier Exp $ 00003 // 00004 // Implementation of JobCleaner class for JobC 00005 // 00006 // messier@huhepl.harvard.edu 00008 #include "JobControl/JobCleaner.h" 00009 #include "JobControl/JobC.h" 00010 00011 JobCleaner* JobCleaner::fInstance = 0; 00012 00013 //...................................................................... 00014 00015 JobCleaner::~JobCleaner() { this->Reap(); } 00016 00017 //...................................................................... 00018 00019 void JobCleaner::Add(JobC* j) { fJobCList.push_back(j); } 00020 00021 //...................................................................... 00022 00023 void JobCleaner::Remove(JobC* j) 00024 { 00025 // Remove the JobC object from the list of managed objects 00026 std::vector<JobC*>::iterator itr(fJobCList.begin()); 00027 std::vector<JobC*>::iterator itrEnd(fJobCList.end()); 00028 for (; itr!=itrEnd; ++itr) { 00029 if (*itr == j) { 00030 *itr = 0; 00031 return; 00032 } 00033 } 00034 } 00035 00036 //...................................................................... 00037 00038 void JobCleaner::Reap() { 00039 std::vector<JobC*>::iterator itr(fJobCList.begin()); 00040 std::vector<JobC*>::iterator itrEnd(fJobCList.end()); 00041 for (; itr!=itrEnd; ++itr) { 00042 if (*itr) { 00043 delete *itr; 00044 *itr = 0; 00045 } 00046 } 00047 } 00048 00049 //...................................................................... 00050 00051 JobCleaner& JobCleaner::Instance() 00052 { 00053 if (fInstance) return *fInstance; 00054 00055 static JobCleaner::Cleaner c; 00056 c.ClassIsUsed(); 00057 fInstance = new JobCleaner(); 00058 return *fInstance; 00059 } 00060 00061 //...................................................................... 00062 00063 JobCleaner::JobCleaner() { } 00064
1.3.9.1