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

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