| 1 | #ifndef MARS_MJob | 
|---|
| 2 | #define MARS_MJob | 
|---|
| 3 |  | 
|---|
| 4 | #ifndef MARS_MSequence | 
|---|
| 5 | #include "MSequence.h" | 
|---|
| 6 | #endif | 
|---|
| 7 |  | 
|---|
| 8 | class MEnv; | 
|---|
| 9 | class MEvtLoop; | 
|---|
| 10 |  | 
|---|
| 11 | class MJob : public MParContainer | 
|---|
| 12 | { | 
|---|
| 13 | private: | 
|---|
| 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 |  | 
|---|
| 29 | protected: | 
|---|
| 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 | // FIXME: Split into MJobSequence and MJobDataSet | 
|---|
| 37 | MSequence fSequence;      // Sequence | 
|---|
| 38 |  | 
|---|
| 39 | const TEnv *GetEnv() const; | 
|---|
| 40 | const MEnv *GetMEnv() const { return fEnv; } | 
|---|
| 41 | const TString &GetEnvPrefix() const { return fEnvPrefix; } | 
|---|
| 42 | Int_t GetEnvDebug() const { return fEnvDebug; } | 
|---|
| 43 |  | 
|---|
| 44 | Int_t       GetEnv(const char *name, Int_t dflt) const; | 
|---|
| 45 | Double_t    GetEnv(const char *name, Double_t dflt) const; | 
|---|
| 46 | const char *GetEnv(const char *name, const char *dflt) const; | 
|---|
| 47 | Bool_t      HasEnv(const char *name) const; | 
|---|
| 48 |  | 
|---|
| 49 | Bool_t SetupEnv(MEvtLoop &loop) const; | 
|---|
| 50 | Bool_t CheckEnv(); | 
|---|
| 51 | Bool_t CheckEnv(MParContainer &c) const; | 
|---|
| 52 | void PrintUntouchedEnv() const; | 
|---|
| 53 | virtual Bool_t CheckEnvLocal() { return kTRUE; } | 
|---|
| 54 |  | 
|---|
| 55 | Bool_t WriteContainer(TCollection &list) const; | 
|---|
| 56 | Bool_t ReadContainer(TCollection &list) const; | 
|---|
| 57 | Bool_t WriteContainer(TCollection &cont, const char *name, const char *option="RECREATE", const int compr=2) const; | 
|---|
| 58 | Bool_t WriteDisplay(const char *name, const char *option="RECREATE", const int comp=2) const; | 
|---|
| 59 |  | 
|---|
| 60 | public: | 
|---|
| 61 | MJob(const char *name=NULL, const char *title=NULL); | 
|---|
| 62 | ~MJob(); | 
|---|
| 63 |  | 
|---|
| 64 | // Setter | 
|---|
| 65 | void   SetPathOut(const char *path="."); | 
|---|
| 66 | void   SetPathIn(const char *path="."); | 
|---|
| 67 |  | 
|---|
| 68 | void   SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; } | 
|---|
| 69 | Bool_t SetEnv(const char *env, const char *prefix=0); | 
|---|
| 70 | void   SetEnv(MEnv *env, const char *prefix=0); | 
|---|
| 71 | void   SetEnvDebug(Int_t d=2) { fEnvDebug=d; } | 
|---|
| 72 |  | 
|---|
| 73 | void   SetMaxEvents(Int_t max) { fMaxEvents = max; } | 
|---|
| 74 | void   SetSequence(const MSequence &seq) { fSequence = seq; } | 
|---|
| 75 |  | 
|---|
| 76 | // Getter | 
|---|
| 77 | TString GetPathOut() const  { return fPathOut; } | 
|---|
| 78 | TString GetPathIn() const   { return fPathIn; } | 
|---|
| 79 |  | 
|---|
| 80 | Bool_t HasWritePermission(TString fname) const; | 
|---|
| 81 |  | 
|---|
| 82 | // Others | 
|---|
| 83 | MStatusDisplay *GetDisplay() { return fDisplay; } | 
|---|
| 84 |  | 
|---|
| 85 | static TString ExpandPath(TString fname); | 
|---|
| 86 | static void SortArray(TArrayI &arr); | 
|---|
| 87 |  | 
|---|
| 88 | ClassDef(MJob, 0) // Bas class for Jobs | 
|---|
| 89 | }; | 
|---|
| 90 |  | 
|---|
| 91 | #endif | 
|---|