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

Last change on this file since 3592 was 3497, 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 UInt_t fNumExecutions; //! Number of Excutions
32
33 TStopwatch *fStopwatch; //!
34
35 virtual Int_t PreProcess(MParList *pList);
36 virtual Int_t Process();
37 virtual Int_t PostProcess();
38
39protected:
40 void AddToBranchList(const char *b);
41 void AddToBranchList(const TString &str);
42 void AddToBranchList(const char *master, const char *sub, const UInt_t first, const UInt_t last)
43 {
44 if (first==0 && last==0)
45 {
46 AddToBranchList(sub);
47 return;
48 }
49
50 for (unsigned int i=first; i<last+1; i++)
51 AddToBranchList(Form("%s;%d.%s", master, i, sub));
52 }
53 void AddToBranchList(TString &master, TString &sub, const UInt_t first, const UInt_t last)
54 {
55 AddToBranchList((const char*)master, (const char*)sub, first, last);
56 }
57 void AddToBranchList(const char *master, const char *sub, const UInt_t num)
58 {
59 AddToBranchList(master, sub, 0, num);
60 }
61 void AddToBranchList(TString &master, TString &sub, const UInt_t num)
62 {
63 AddToBranchList(master, sub, 0, num);
64 }
65
66public:
67 MTask(const char *name=NULL, const char *title=NULL);
68 MTask(MTask &t);
69 virtual ~MTask();
70
71 const TList *GetListOfBranches() const { return fListOfBranches; }
72 Bool_t OverwritesProcess(TClass *cls=NULL) const;
73
74 // Filter functions
75 virtual void SetFilter(MFilter *filter) { fFilter=filter; }
76 const MFilter *GetFilter() const { return fFilter; }
77 MFilter *GetFilter() { return fFilter; } // for MContinue only
78
79 // Display functions
80 void SetDisplay(MStatusDisplay *d);
81
82 // Function for parallel executions
83 static TString AddSerialNumber(const char *str, UInt_t num) { TString s(str); if (num==0) return s; s += ";"; s += num; return s; }
84 static TString AddSerialNumber(const TString &str, UInt_t num) { return AddSerialNumber((const char*)str, num); }
85 TString AddSerialNumber(const char *str) const { return AddSerialNumber(str, fSerialNumber); }
86 TString AddSerialNumber(const TString &str) const { return AddSerialNumber(str, fSerialNumber); }
87
88 virtual void SetSerialNumber(Byte_t num) { fSerialNumber = num; }
89 Byte_t GetSerialNumber() const { return fSerialNumber; }
90
91 const char *GetDescriptor() const;
92
93 // Task execution statistics
94 UInt_t GetNumExecutions() const { return fNumExecutions; }
95 Double_t GetCpuTime() const;
96 Double_t GetRealTime() const;
97 virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE, Double_t time=0) const;
98
99 // Task overwrite functions
100 virtual Bool_t ReInit(MParList *pList);
101
102 virtual Int_t CallPreProcess(MParList *plist);
103 virtual Int_t CallProcess();
104 virtual Int_t CallPostProcess();
105
106 void SavePrimitive(ofstream &out, Option_t *o="");
107
108 ClassDef(MTask, 2) //Abstract base class for a task
109};
110
111#endif
Note: See TracBrowser for help on using the repository browser.