Changeset 988 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 10/24/01 15:12:21 (24 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MReadTree.cc
r965 r988 42 42 // calling MReadTree::UseLeaf. // 43 43 // // 44 // FIXME: An automatic enabeling scheme would be nice. // 45 // // 44 46 // Later we'll use TChain::SetNotify to notify MReadTree if the TChain // 45 47 // starts to read a new file. // … … 258 260 Bool_t MReadTree::Process() 259 261 { 260 return fChain->GetEntry(fNumEntry++ , 0) == 0 ? kFALSE : kTRUE;262 return fChain->GetEntry(fNumEntry++) == 0 ? kFALSE : kTRUE; 261 263 } 262 264 -
trunk/MagicSoft/Mars/mbase/MTask.cc
r961 r988 67 67 #include "MTask.h" 68 68 69 #include "MLog.h" 70 #include "MLogManip.h" 71 72 #include "MFilter.h" 73 69 74 ClassImp(MTask); 75 76 MTask::MTask(const char *name, const char *title) 77 : fFilter(NULL), fIsPreprocessed(kFALSE), fNumExecutions() 78 { 79 *fName = name ? name : "MTask"; 80 *fTitle = title ? title : "Base class for all tasks (dummy task)."; 81 } 82 83 // -------------------------------------------------------------------------- 84 // 85 // Mapper function for PreProcess. 86 // Sets the preprocessed flag dependend on the return value of PreProcess. 87 // 88 Bool_t MTask::CallPreProcess(MParList *plist) 89 { 90 if (!PreProcess(plist)) 91 return kFALSE; 92 93 fIsPreprocessed = kTRUE; 94 return kTRUE; 95 } 96 97 // -------------------------------------------------------------------------- 98 // 99 // Mapper function for Process. 100 // Executes Process dependent on the existance of a filter and its possible 101 // return value. 102 // If Process is executed, the execution counter is increased. 103 // 104 inline Bool_t MTask::CallProcess() 105 { 106 // 107 // Check for the existance of a filter. If a filter is existing 108 // check for its value. If the value is kFALSE don't execute 109 // this task. 110 // 111 const Bool_t exec = fFilter ? fFilter->IsExpressionTrue() : kTRUE; 112 113 if (!exec) 114 return kTRUE; 115 116 fNumExecutions++; 117 return Process(); 118 } 119 120 // -------------------------------------------------------------------------- 121 // 122 // Mapper function for PreProcess. 123 // Calls Postprocess dependent on the state of the preprocessed flag, 124 // resets this flag. 125 // 126 Bool_t MTask::CallPostProcess() 127 { 128 if (!fIsPreprocessed) 129 return kTRUE; 130 131 fIsPreprocessed = kFALSE; 132 return PostProcess(); 133 } 70 134 71 135 // -------------------------------------------------------------------------- … … 105 169 } 106 170 107 171 // -------------------------------------------------------------------------- 172 // 173 // Prints the number of times this task has been processed. 174 // For convinience the lvl argument results in a number of spaces at the 175 // beginning of the line. So that the structur of a tasklist can be 176 // identified. 177 // 178 void MTask::PrintStatistics(const Int_t lvl) const 179 { 180 *fLog << setw(lvl) << " " << GetName() << " ["; 181 *fLog << ClassName() << "] \t" << fNumExecutions; 182 *fLog << endl; 183 } -
trunk/MagicSoft/Mars/mbase/MTask.h
r867 r988 23 23 24 24 Bool_t fIsPreprocessed; // Indicates the success of the PreProcessing (set by MTaskList) 25 26 public: 27 MTask() : fFilter(NULL), fIsPreprocessed(kFALSE) {} 28 ~MTask() 29 { 30 } 31 32 const MFilter *GetFilter() const { return fFilter; } 33 void SetFilter(const MFilter *filter) { fFilter=filter; } 34 35 Bool_t IsPreprocessed() const { return fIsPreprocessed; } 36 void SetIsPreprocessed(Bool_t state=kTRUE) { fIsPreprocessed = state; } 25 UInt_t fNumExecutions; // Number of Excutions 37 26 38 27 virtual Bool_t PreProcess(MParList *pList); … … 40 29 virtual Bool_t PostProcess(); 41 30 31 public: 32 MTask(const char *name=NULL, const char *title=NULL); 33 virtual ~MTask() 34 { 35 } 36 37 void SetFilter(const MFilter *filter) { fFilter=filter; } 38 virtual void PrintStatistics(const Int_t lvl=0) const; 39 40 Bool_t CallPreProcess(MParList *plist); 41 Bool_t CallProcess(); 42 Bool_t CallPostProcess(); 43 42 44 ClassDef(MTask, 0) //Abstract base class for a task 43 45 }; -
trunk/MagicSoft/Mars/mbase/MTaskList.cc
r961 r988 49 49 #include "MLog.h" 50 50 #include "MLogManip.h" 51 #include "MFilter.h" 51 52 52 #include "MParList.h" 53 53 #include "MInputStreamID.h" … … 232 232 *fLog << task->GetName() << "... " << flush; 233 233 234 if (!task-> PreProcess(fParList))234 if (!task->CallPreProcess(fParList)) 235 235 return kFALSE; 236 237 task->SetIsPreprocessed();238 236 } 239 237 … … 278 276 279 277 // 280 // Check for the existance of a filter. If a filter is existing 281 // check for its value. If the value is kFALSE don't execute 282 // this task. 283 // 284 const MFilter *filter = task->GetFilter(); 285 286 const Bool_t rc = filter ? filter->IsExpressionTrue() : kTRUE; 287 288 if (!rc) 289 continue; 290 291 // 292 // if it has the right stream id execute the Process() function 278 // if it has the right stream id execute the CallProcess() function 293 279 // and check what the result of it is. 294 // 295 switch (task->Process()) 280 // The CallProcess() function increases the execution counter and 281 // calls the Process() function dependent on the existance and 282 // return value of a filter. 283 // 284 switch (task->CallProcess()) 296 285 { 297 286 case kTRUE: … … 312 301 // 313 302 return kTRUE; 303 304 default: 305 *fLog << "MTaskList::Process: Unknown return value from MTask::Process()... ignored." << endl; 314 306 } 315 307 } … … 349 341 while ( (task=(MTask*)Next()) ) 350 342 { 351 if (!task-> IsPreprocessed())352 continue;343 if (!task->CallPostProcess()) 344 return kFALSE; 353 345 354 346 *fLog << task->GetName() << "... " << flush; 355 356 //357 // FIXME: should we only skip this task?358 //359 if (!task->PostProcess())360 return kFALSE;361 347 } 362 348 … … 367 353 368 354 // -------------------------------------------------------------------------- 369 void MTaskList::Print(Option_t *t) 370 { 371 *fLog << "TaskList: " << this->GetName() << " <" << this->GetTitle() << ">" << endl; 355 // 356 // Prints the number of times all the tasks in the list has been. 357 // For convinience the lvl argument results in a number of spaces at the 358 // beginning of the line. So that the structur of a tasklist can be 359 // identified. Use MTaskList::PrintStatistics without an argument. 360 // 361 void MTaskList::PrintStatistics(const Int_t lvl) const 362 { 363 if (lvl==0) 364 { 365 *fLog << endl; 366 *fLog << "Execution Statistics: " << endl; 367 *fLog << "---------------------" << endl; 368 *fLog << GetName() << " [" << ClassName() << "]" << endl; 369 } 370 else 371 { 372 *fLog << setw(lvl) << " " << GetName() << " ["; 373 *fLog << ClassName() << "]" << endl; 374 } 375 376 // 377 // create the Iterator for the TaskList 378 // 379 TIter Next(&fTasks); 380 381 MTask *task=NULL; 382 // 383 // loop over all tasks for postprocessing 384 // only tasks which have successfully been preprocessed are postprocessed. 385 // 386 while ( (task=(MTask*)Next()) ) 387 task->PrintStatistics(lvl+1); 388 389 if (lvl==0) 390 *fLog << endl; 391 } 392 393 // -------------------------------------------------------------------------- 394 void MTaskList::Print(Option_t *t) const 395 { 396 *fLog << "TaskList: " << GetName() << " <" << GetTitle() << ">" << endl; 372 397 373 398 fTasks.Print(); -
trunk/MagicSoft/Mars/mbase/MTaskList.h
r959 r988 27 27 MParList *fParList; 28 28 29 UInt_t *fCntContinue; 30 UInt_t *fCntTrue; 31 29 32 enum { kIsOwner = BIT(14) }; 30 33 … … 46 49 Bool_t PostProcess(); 47 50 48 void Print(Option_t *opt = ""); 51 void Print(Option_t *opt = "") const; 52 void PrintStatistics(const Int_t lvl=0) const; 49 53 void SetOwner(Bool_t enable=kTRUE); 50 54
Note:
See TracChangeset
for help on using the changeset viewer.