source: trunk/Mars/mjobs/MJob.h@ 18450

Last change on this file since 18450 was 9482, checked in by tbretz, 15 years ago
*** empty log message ***
File size: 3.3 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 TString fCommandLine; // Command line for possible storage
42
43 const TEnv *GetEnv() const;
44 const MEnv *GetMEnv() const { return fEnv; }
45 const TString &GetEnvPrefix() const { return fEnvPrefix; }
46 Int_t GetEnvDebug() const { return fEnvDebug; }
47
48 Int_t GetEnv(const char *name, Int_t dflt) const;
49 Double_t GetEnv(const char *name, Double_t dflt) const;
50 const char *GetEnv(const char *name, const char *dflt) const;
51 Bool_t HasEnv(const char *name) const;
52
53 Bool_t InitRandomNumberGenerator() const;
54 Bool_t SetupEnv(MEvtLoop &loop) const;
55 Bool_t CheckEnv();
56 Bool_t CheckEnv(MParContainer &c) const;
57 void PrintUntouchedEnv() const;
58 virtual Bool_t CheckEnvLocal() { return kTRUE; }
59
60 Bool_t WriteContainer(TCollection &list) const;
61 Bool_t ReadContainer(TCollection &list) const;
62 Bool_t WriteContainer(TCollection &cont, const char *name, const char *option="RECREATE", const int compr=2) const;
63 Bool_t WriteDisplay(const char *name, const char *option="RECREATE", const int comp=2) const;
64
65public:
66 MJob(const char *name=NULL, const char *title=NULL);
67 ~MJob();
68
69 // Setter
70 void SetPathOut(const char *path=".");
71 void SetPathIn(const char *path=".");
72
73 void SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }
74 Bool_t SetEnv(const char *env, const char *prefix=0);
75 void SetEnv(MEnv *env, const char *prefix=0);
76 void SetEnvDebug(Int_t d=2) { fEnvDebug=d; }
77
78 void SetMaxEvents(Int_t max) { fMaxEvents = max; }
79 void SetSequence(const MSequence &seq) { fSequence = seq; }
80
81 void SetNullOut(Bool_t b=kTRUE) { fNullOut=b; }
82
83 void SetCommandLine(const TString &s) { fCommandLine = s; }
84
85 // Getter
86 TString GetPathOut() const { return fPathOut; }
87 TString GetPathIn() const { return fPathIn; }
88
89 Bool_t HasWritePermission(TString fname) const;
90
91 Bool_t HasNullOut() const { return fNullOut; }
92
93 // Others
94 MStatusDisplay *GetDisplay() { return fDisplay; }
95
96 static TString ExpandPath(TString fname);
97 static void SortArray(TArrayI &arr);
98
99 static TString Esc(TString esc) { esc.ReplaceAll("/", "\\/"); return esc; }
100
101 ClassDef(MJob, 0) // Bas class for Jobs
102};
103
104#endif
Note: See TracBrowser for help on using the repository browser.