EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairRuntimeDb.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairRuntimeDb.h
1 #ifndef FAIRRUNTIMEDB_H
2 #define FAIRRUNTIMEDB_H
3 
4 #include "TObject.h"
5 #include "TList.h"
6 #include "FairLogger.h"
7 
8 class FairParIo;
9 class FairParSet;
10 class FairRtdbRun;
11 class FairContFact;
12 
13 class FairParTSQLIo;
14 class FairDetParTSQLIo;
16 
17 
18 static TList contFactories;
19 
20 class FairRuntimeDb : public TObject
21 {
22  private:
23  static FairRuntimeDb* gRtdb;
24 
25  protected:
26  FairRuntimeDb(void);
27  TList* containerList; // list of parameter containers
28  TList* runs; // list of runs
29  FairParIo* firstInput; // first (prefered) input for parameters
30  FairParIo* secondInput; // second input (used if not found in first input)
31  FairParIo* output; // output for parameters
32  FairRtdbRun* currentRun; // Current run
33  TString currentFileName; // Name of current event file
34  Bool_t versionsChanged; // flag for write of list of runs (set kTRUE by each write)
35  Bool_t isRootFileOutput; // flag indicating that the output is a ROOT file
38 
42  typedef enum {
44  AsciiFileOutput = 1,// Ascii in-out-put
45  RootFileOutput = 2,// Root Files
46  RootTSQLOutput = 3// Use a TSQL db
47  } ParamIOType;
48  ParamIOType ioType;//IO Type
49 
50  public:
51  static FairRuntimeDb* instance(void);
52  ~FairRuntimeDb(void);
53 
54  Bool_t addParamContext(const char*);
55  void printParamContexts();
57  FairContFact* getContFactory(const Text_t*);
58 
59  Bool_t addContainer(FairParSet*);
60  FairParSet* getContainer(const Text_t*);
61  FairParSet* findContainer(const char*);
62  void removeContainer(Text_t*);
63  void removeAllContainers(void);
64  Bool_t initContainers(Int_t runId,Int_t refId=-1,const Text_t* fileName="");
65  void setContainersStatic(Bool_t f=kTRUE);
66  Bool_t writeContainers(void);
68 
69  FairRtdbRun* addRun(Int_t runId,Int_t refId=-1);
70  FairRtdbRun* getRun(Int_t);
71  FairRtdbRun* getRun(Text_t*);
73  Text_t const* getCurrentFileName() {return currentFileName.Data();}
74  void clearRunList(void);
75 
76  void removeRun(Text_t*);
77 
78  Bool_t setInputVersion(Int_t run,Text_t* container,
79  Int_t version,Int_t inputNumber);
80  Bool_t setRootOutputVersion(Int_t run,Text_t* container,Int_t version);
81  void setVersionsChanged(Bool_t f=kTRUE) {versionsChanged=f;}
82  void resetInputVersions(void);
83  void resetOutputVersions(void);
84  void resetAllVersions(void);
85 
86  Bool_t readAll(void);
87  void writeVersions(void);
88  void saveOutput(void);
89 
90  Bool_t setFirstInput(FairParIo*);
91  Bool_t setSecondInput(FairParIo*);
92  Bool_t setOutput(FairParIo*);
93  FairParIo* getFirstInput(void);
95  FairParIo* getOutput(void);
96  void closeFirstInput(void);
97  void closeSecondInput(void);
98  void closeOutput(void);
99  void activateParIo(FairParIo*);
101  void print(void);
102 
104 
105  private:
106  FairRuntimeDb(const FairRuntimeDb& M);
107  FairRuntimeDb& operator= (const FairRuntimeDb&) {return *this;}
108  Bool_t initContainers(void);
109 
110  ClassDef(FairRuntimeDb,0) // Class for runtime database
111 };
112 
113 #endif /* !FAIRRUNTIMEDB_H */