source: trunk/MagicSoft/Mars/mjobs/MJob.h@ 9087

Last change on this file since 9087 was 8902, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 3.0 KB
Line 
1#ifndef MARS_MJob
2#define MARS_MJob
3
4#ifndef MARS_MSequence
5#include "MSequence.h"
6#endif
7
8class MEnv;
9class MEvtLoop;
10
11class MJob : public MParContainer
12{
13private:
14 enum { kIsOwner = BIT(14) };
15
16 // Helper functions for paths
17 static TString CombinePath(TString path, TString fname);
18 static void FixPath(TString &path);
19
20 // Helper functions to set a new fEnv
21 void SetPrefix(const char *prefix);
22 void ClearEnv();
23
24 // Data members for resource files
25 const MEnv *fEnv; // Resource file
26 TString fEnvPrefix; // Prefix for resources
27 Int_t fEnvDebug; // Debug setup of resources
28
29protected:
30 TString fPathOut; // Directory to write output file to (eg. calib*.root)
31 TString fPathIn; // Directory to read output from (eg. calib*.root)
32
33 Bool_t fOverwrite; // Allow overwriting output files
34 Int_t fMaxEvents; // Maximum number of events
35
36 Bool_t fNullOut; // Suppress output files
37
38 // FIXME: Split into MJobSequence and MJobDataSet
39 MSequence fSequence; // Sequence
40
41 const TEnv *GetEnv() const;
42 const MEnv *GetMEnv() const { return fEnv; }
43 const TString &GetEnvPrefix() const { return fEnvPrefix; }
44 Int_t GetEnvDebug() const { return fEnvDebug; }
45
46 Int_t GetEnv(const char *name, Int_t dflt) const;
47 Double_t GetEnv(const char *name, Double_t dflt) const;
48 const char *GetEnv(const char *name, const char *dflt) const;
49 Bool_t HasEnv(const char *name) const;
50
51 Bool_t SetupEnv(MEvtLoop &loop) const;
52 Bool_t CheckEnv();
53 Bool_t CheckEnv(MParContainer &c) const;
54 void PrintUntouchedEnv() const;
55 virtual Bool_t CheckEnvLocal() { return kTRUE; }
56
57 Bool_t WriteContainer(TCollection &list) const;
58 Bool_t ReadContainer(TCollection &list) const;
59 Bool_t WriteContainer(TCollection &cont, const char *name, const char *option="RECREATE", const int compr=2) const;
60 Bool_t WriteDisplay(const char *name, const char *option="RECREATE", const int comp=2) const;
61
62public:
63 MJob(const char *name=NULL, const char *title=NULL);
64 ~MJob();
65
66 // Setter
67 void SetPathOut(const char *path=".");
68 void SetPathIn(const char *path=".");
69
70 void SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }
71 Bool_t SetEnv(const char *env, const char *prefix=0);
72 void SetEnv(MEnv *env, const char *prefix=0);
73 void SetEnvDebug(Int_t d=2) { fEnvDebug=d; }
74
75 void SetMaxEvents(Int_t max) { fMaxEvents = max; }
76 void SetSequence(const MSequence &seq) { fSequence = seq; }
77
78 void SetNullOut(Bool_t b=kTRUE) { fNullOut=b; }
79
80 // Getter
81 TString GetPathOut() const { return fPathOut; }
82 TString GetPathIn() const { return fPathIn; }
83
84 Bool_t HasWritePermission(TString fname) const;
85
86 Bool_t HasNullOut() const { return fNullOut; }
87
88 // Others
89 MStatusDisplay *GetDisplay() { return fDisplay; }
90
91 static TString ExpandPath(TString fname);
92 static void SortArray(TArrayI &arr);
93
94 ClassDef(MJob, 0) // Bas class for Jobs
95};
96
97#endif
Note: See TracBrowser for help on using the repository browser.