FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairRuntimeDb.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 #ifndef FAIRRUNTIMEDB_H
9 #define FAIRRUNTIMEDB_H
10 
11 #include <Rtypes.h> // for Bool_t, Int_t, Text_t, etc
12 #include <TList.h> // for TList
13 #include <TObject.h> // for TObject
14 #include <TString.h> // for TString
15 
16 class FairContFact;
17 class FairLogger;
18 class FairParIo;
19 class FairParSet;
20 class FairRtdbRun;
21 
22 static TList contFactories;
23 
24 class FairRuntimeDb : public TObject
25 {
26  private:
27  static FairRuntimeDb* gRtdb;
28 
29  protected:
30  FairRuntimeDb(void);
31  TList* containerList; // list of parameter containers
32  TList* runs; // list of runs
33  FairParIo* firstInput; // first (prefered) input for parameters
34  FairParIo* secondInput; // second input (used if not found in first input)
35  FairParIo* output; // output for parameters
36  FairRtdbRun* currentRun; // Current run
37  TString currentFileName; // Name of current event file
38  Bool_t versionsChanged; // flag for write of list of runs (set kTRUE by each write)
39  Bool_t isRootFileOutput; // flag indicating that the output is a ROOT file
42 
46  typedef enum
47  {
49  AsciiFileOutput = 1, // Ascii in-out-put
50  RootFileOutput = 2, // Root Files
51  RootTSQLOutput = 3 // Use a TSQL db
52  } ParamIOType;
53  ParamIOType ioType; // IO Type
54 
55  public:
56  static FairRuntimeDb* instance(void);
57  ~FairRuntimeDb(void);
58 
59  Bool_t addParamContext(const char*);
60  void printParamContexts();
62  void removeContFactory(FairContFact* fact);
63  FairContFact* getContFactory(const Text_t*);
64 
65  Bool_t addContainer(FairParSet*);
66  FairParSet* getContainer(const Text_t*);
67  FairParSet* findContainer(const char*);
68  void removeContainer(Text_t*);
69  void removeAllContainers(void);
70  Bool_t initContainers(Int_t runId, Int_t refId = -1, const Text_t* fileName = "");
71  void setContainersStatic(Bool_t f = kTRUE);
72  Bool_t writeContainers(void);
73  Bool_t writeContainer(FairParSet*, FairRtdbRun*, FairRtdbRun* refRun = 0);
74 
75  FairRtdbRun* addRun(Int_t runId, Int_t refId = -1);
76  FairRtdbRun* getRun(Int_t);
77  FairRtdbRun* getRun(Text_t*);
79  Text_t const* getCurrentFileName() { return currentFileName.Data(); }
80  void clearRunList(void);
81 
82  void removeRun(Text_t*);
83 
84  Bool_t setInputVersion(Int_t run, Text_t* container, Int_t version, Int_t inputNumber);
85  Bool_t setRootOutputVersion(Int_t run, Text_t* container, Int_t version);
86  void setVersionsChanged(Bool_t f = kTRUE) { versionsChanged = f; }
87  void resetInputVersions(void);
88  void resetOutputVersions(void);
89  void resetAllVersions(void);
90 
91  Bool_t readAll(void);
92  void writeVersions(void);
93  void saveOutput(void);
94 
95  Bool_t setFirstInput(FairParIo*);
96  Bool_t setSecondInput(FairParIo*);
97  Bool_t setOutput(FairParIo*);
98  FairParIo* getFirstInput(void);
100  FairParIo* getOutput(void);
101  void closeFirstInput(void);
102  void closeSecondInput(void);
103  void closeOutput(void);
104  void activateParIo(FairParIo*);
105  TList* getListOfContainers() { return containerList; }
106  void print(void);
107 
109 
110  private:
111  FairRuntimeDb(const FairRuntimeDb& M);
112  FairRuntimeDb& operator=(const FairRuntimeDb&) { return *this; }
113  Bool_t initContainers(void);
114 
115  ClassDef(FairRuntimeDb, 0); // Class for runtime database
116 };
117 
118 #endif /* !FAIRRUNTIMEDB_H */
Text_t const * getCurrentFileName()
Definition: FairRuntimeDb.h:79
FairRtdbRun * getRun(Int_t)
list of container factories
Definition: FairRuntimeDb.h:24
FairLogger * fLogger
Definition: FairRuntimeDb.h:41
void setVersionsChanged(Bool_t f=kTRUE)
Definition: FairRuntimeDb.h:86
void activateParIo(FairParIo *)
FairRtdbRun * currentRun
Definition: FairRuntimeDb.h:36
void removeAllContainers(void)
Bool_t setInputVersion(Int_t run, Text_t *container, Int_t version, Int_t inputNumber)
Bool_t writeContainer(FairParSet *, FairRtdbRun *, FairRtdbRun *refRun=0)
TList * containerList
Definition: FairRuntimeDb.h:31
FairParIo * secondInput
Definition: FairRuntimeDb.h:34
TString currentFileName
Definition: FairRuntimeDb.h:37
void writeVersions(void)
static FairRuntimeDb * instance(void)
void closeSecondInput(void)
FairParSet * findContainer(const char *)
Bool_t setSecondInput(FairParIo *)
void clearRunList(void)
void print(void)
void resetAllVersions(void)
Int_t findOutputVersion(FairParSet *)
TList * getListOfContainers()
FairRtdbRun * getCurrentRun(void)
Definition: FairRuntimeDb.h:78
FairParIo * output
Definition: FairRuntimeDb.h:35
void setContainersStatic(Bool_t f=kTRUE)
FairParSet * getContainer(const Text_t *)
Bool_t writeContainers(void)
Bool_t initContainers(Int_t runId, Int_t refId=-1, const Text_t *fileName="")
void removeRun(Text_t *)
void closeOutput(void)
Bool_t addContainer(FairParSet *)
void removeContainer(Text_t *)
void printParamContexts()
void addContFactory(FairContFact *)
FairParIo * getSecondInput(void)
ParamIOType ioType
Definition: FairRuntimeDb.h:53
FairParIo * getOutput(void)
Bool_t readAll(void)
Bool_t setOutput(FairParIo *)
Bool_t versionsChanged
Definition: FairRuntimeDb.h:38
void removeContFactory(FairContFact *fact)
FairContFact * getContFactory(const Text_t *)
FairRtdbRun * addRun(Int_t runId, Int_t refId=-1)
void closeFirstInput(void)
void resetOutputVersions(void)
Bool_t setRootOutputVersion(Int_t run, Text_t *container, Int_t version)
Bool_t addParamContext(const char *)
void resetInputVersions(void)
Bool_t setFirstInput(FairParIo *)
void saveOutput(void)
FairParIo * getFirstInput(void)
FairParIo * firstInput
Definition: FairRuntimeDb.h:33
Bool_t isRootFileOutput
Definition: FairRuntimeDb.h:39