FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairRtdbRun.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 FAIRRTDBRUN_H
9 #define FAIRRTDBRUN_H
10 
11 #include <Rtypes.h> // for Int_t, Text_t, UInt_t, etc
12 #include <TNamed.h> // for TNamed
13 #include <TString.h> // for TString
14 #include <iosfwd> // for fstream
15 #include <stdio.h> // for sprintf, sscanf
16 
17 class TList;
18 using std::fstream;
19 
20 class FairParVersion : public TNamed
21 {
22  protected:
23  Int_t inputVersions[3];
24  Int_t rootVersion; // version of the parameter container in the ROOT output file
25 
26  public:
28  : TNamed()
29  , rootVersion(0)
30  {}
31  FairParVersion(Text_t* name);
33  void setInputVersion(Int_t v = -1, Int_t i = 0)
34  {
35  if (i >= 0 && i < 3) {
36  inputVersions[i] = v;
37  }
38  }
39  Int_t getInputVersion(Int_t i)
40  {
41  if (i >= 0 && i < 3) {
42  return inputVersions[i];
43  } else {
44  return -1;
45  }
46  }
48  {
49  for (Int_t i = 0; i < 3; i++) {
50  inputVersions[i] = -1;
51  }
52  }
53  void setRootVersion(Int_t v) { rootVersion = v; }
54  Int_t getRootVersion() { return rootVersion; }
55  ClassDef(FairParVersion, 1); // Class for parameter versions
56 };
57 
58 class FairRtdbRun : public TNamed
59 {
60  protected:
61  TList* parVersions; // List of container names with the versions
62  TString refRun;
63 
64  public:
65  FairRtdbRun();
66  FairRtdbRun(const Text_t* name, const Text_t* refName = "");
67  FairRtdbRun(Int_t r, Int_t rr = -1);
69  ~FairRtdbRun();
70  inline UInt_t getRunId(void);
71  void addParVersion(FairParVersion* pv);
72  FairParVersion* getParVersion(const Text_t* name);
73  TList* getParVersions() { return parVersions; }
74  const Text_t* getRefRun() { return refRun.Data(); }
75  void setRefRun(Text_t* s) { refRun = s; }
76  inline void setRefRun(Int_t r);
77  void resetInputVersions();
78  void resetOutputVersions();
79  void print();
80  void write(std::fstream&);
81 
82  private:
83  FairRtdbRun& operator=(const FairRtdbRun&);
84 
85  ClassDef(FairRtdbRun, 1); // Class for parameter version management of a run
86 };
87 
88 // -------------------- inlines ---------------------------
89 
90 inline UInt_t FairRtdbRun::getRunId(void)
91 {
92  UInt_t r;
93  sscanf(GetName(), "%i", &r);
94  return r;
95 }
96 
97 inline void FairRtdbRun::setRefRun(Int_t r)
98 {
99  if (r == -1) {
100  refRun = "";
101  } else {
102  char name[255];
103  sprintf(name, "%i", r);
104  refRun = name;
105  }
106 }
107 
108 #endif /* !FAIRRTDBRUN_H */
void resetOutputVersions()
void addParVersion(FairParVersion *pv)
FairParVersion * getParVersion(const Text_t *name)
Int_t rootVersion
version of the parameter container in the 2 possible inputs
Definition: FairRtdbRun.h:24
void resetInputVersions()
const Text_t * getRefRun()
Definition: FairRtdbRun.h:74
void write(std::fstream &)
void setInputVersion(Int_t v=-1, Int_t i=0)
Definition: FairRtdbRun.h:33
void setRefRun(Text_t *s)
Definition: FairRtdbRun.h:75
ClassDef(FairParVersion, 1)
TString refRun
Definition: FairRtdbRun.h:62
Int_t getInputVersion(Int_t i)
Definition: FairRtdbRun.h:39
void setRootVersion(Int_t v)
Definition: FairRtdbRun.h:53
TList * getParVersions()
Definition: FairRtdbRun.h:73
Int_t getRootVersion()
Definition: FairRtdbRun.h:54
FairRtdbRun()
name of the reference run for initialization
Definition: FairRtdbRun.cxx:88
UInt_t getRunId(void)
Definition: FairRtdbRun.h:90
void resetInputVersions()
Definition: FairRtdbRun.h:47
Int_t inputVersions[3]
Definition: FairRtdbRun.h:23
TList * parVersions
Definition: FairRtdbRun.h:61