source: trunk/MagicSoft/Mars/mbase/MTask.h@ 3842

Last change on this file since 3842 was 3666, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.9 KB
Line 
1#ifndef MARS_MTask
2#define MARS_MTask
3
4/////////////////////////////////////////////////////////////////////////////
5// //
6// MTask //
7// //
8// Abstract base class for a task //
9// //
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef MARS_MInputStreamID
13#include "MInputStreamID.h"
14#endif
15
16class TList;
17class TStopwatch;
18
19class MFilter;
20class MParList;
21
22class MTask : public MInputStreamID
23{
24private:
25 TList *fListOfBranches; //! List of Branch names for auto enabeling scheme
26
27 MFilter *fFilter; // Filter for conditional task execution
28 Byte_t fSerialNumber; // Serial number having more than one detector of the same type
29
30 Bool_t fIsPreprocessed; //! Indicates the success of the PreProcessing (set by MTaskList)
31
32 TStopwatch *fStopwatch; //! Count the execution time and number of executions
33
34 virtual Int_t PreProcess(MParList *pList);
35 virtual Int_t Process();
36 virtual Int_t PostProcess();
37
38protected:
39 void AddToBranchList(const char *b);
40 void AddToBranchList(const TString &str);
41 void AddToBranchList(const char *master, const char *sub, const UInt_t first, const UInt_t last)
42 {
43 if (first==0 && last==0)
44 {
45 AddToBranchList(sub);
46 return;
47 }
48
49 for (unsigned int i=first; i<last+1; i++)
50 AddToBranchList(Form("%s;%d.%s", master, i, sub));
51 }
52 void AddToBranchList(TString &master, TString &sub, const UInt_t first, const UInt_t last)
53 {
54 AddToBranchList((const char*)master, (const char*)sub, first, last);
55 }
56 void AddToBranchList(const char *master, const char *sub, const UInt_t num)
57 {
58 AddToBranchList(master, sub, 0, num);
59 }
60 void AddToBranchList(TString &master, TString &sub, const UInt_t num)
61 {
62 AddToBranchList(master, sub, 0, num);
63 }
64
65public:
66 MTask(const char *name=NULL, const char *title=NULL);
67 MTask(MTask &t);
68 virtual ~MTask();
69
70 const TList *GetListOfBranches() const { return fListOfBranches; }
71 Bool_t OverwritesProcess(TClass *cls=NULL) const;
72
73 // Filter functions
74 virtual void SetFilter(MFilter *filter) { fFilter=filter; }
75 const MFilter *GetFilter() const { return fFilter; }
76 MFilter *GetFilter() { return fFilter; } // for MContinue only
77
78 // Display functions
79 void SetDisplay(MStatusDisplay *d);
80
81 // Function for parallel executions
82 static TString AddSerialNumber(const char *str, UInt_t num) { TString s(str); if (num==0) return s; s += ";"; s += num; return s; }
83 static TString AddSerialNumber(const TString &str, UInt_t num) { return AddSerialNumber((const char*)str, num); }
84 TString AddSerialNumber(const char *str) const { return AddSerialNumber(str, fSerialNumber); }
85 TString AddSerialNumber(const TString &str) const { return AddSerialNumber(str, fSerialNumber); }
86
87 virtual void SetSerialNumber(Byte_t num) { fSerialNumber = num; }
88 Byte_t GetSerialNumber() const { return fSerialNumber; }
89
90 const char *GetDescriptor() const;
91
92 // Task execution statistics
93 UInt_t GetNumExecutions() const;
94 Double_t GetCpuTime() const;
95 Double_t GetRealTime() const;
96 virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE, Double_t time=0) const;
97
98 // Task overwrite functions
99 virtual Bool_t ReInit(MParList *pList);
100
101 virtual Int_t CallPreProcess(MParList *plist);
102 virtual Int_t CallProcess();
103 virtual Int_t CallPostProcess();
104
105 void SavePrimitive(ofstream &out, Option_t *o="");
106
107 ClassDef(MTask, 2) //Abstract base class for a task
108};
109
110#endif
Note: See TracBrowser for help on using the repository browser.