FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairParamList.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 FAIRPARAMLIST_H
9 #define FAIRPARAMLIST_H
10 
11 #include <Rtypes.h> // for Text_t, Int_t, Bool_t, etc
12 #include <TArrayC.h> // for TArrayC
13 #include <TFile.h> // for TFile
14 #include <THashTable.h> // for THashTable
15 #include <TNamed.h> // for TNamed
16 #include <TObject.h> // for TObject
17 #include <TROOT.h> // for TROOT, gROOT
18 #include <TSeqCollection.h> // for TSeqCollection
19 #include <TString.h> // for TString
20 
21 class TArrayD;
22 class TArrayF;
23 class TArrayI;
24 
25 class FairParamObj : public TNamed
26 {
27  protected:
28  UChar_t* paramValue; // Pointer to binary array
29  Int_t arraySize; // Size of binary array
30  TString paramType; // Type of parameter value or class name
31  Bool_t basicType; // kTRUE for C-types and C-type parameter arrays, kFALSE for classes
32  Int_t bytesPerValue; // number of bytes per value
33  Int_t classVersion; // Code version of classes stored as binary
34  UChar_t* streamerInfo; // Pointer to binary array container the streamer info
35  Int_t streamerInfoSize; // Size of streamer info array
36 
37  public:
38  FairParamObj(const Text_t* name = "");
40  FairParamObj(const Text_t*, Int_t);
41  FairParamObj(const Text_t*, Bool_t);
42  FairParamObj(const Text_t*, UInt_t);
43  FairParamObj(const Text_t*, Float_t);
44  FairParamObj(const Text_t*, Double_t);
45  FairParamObj(const Text_t*, const Int_t*, const Int_t);
46  FairParamObj(const Text_t*, const UInt_t*, const Int_t);
47  FairParamObj(const Text_t*, const Float_t*, const Int_t);
48  FairParamObj(const Text_t*, const Double_t*, const Int_t);
49  FairParamObj(const Text_t*, const Text_t*);
50  FairParamObj(const Text_t*, const Char_t*, const Int_t);
51  FairParamObj(const Text_t*, const UChar_t*, const Int_t);
52  ~FairParamObj();
53  void setParamType(const Text_t* t);
54  UChar_t* setLength(Int_t l);
55  void setParamValue(UChar_t*, const Int_t);
56  void setClassVersion(const Int_t v) { classVersion = v; }
57  UChar_t* setStreamerInfoSize(Int_t);
58  void setStreamerInfo(UChar_t*, const Int_t);
59  UChar_t* getParamValue() { return paramValue; }
60  Bool_t isBasicType() { return basicType; }
61  const char* getParamType() { return paramType.Data(); }
62  Int_t getBytesPerValue() { return bytesPerValue; }
63  Int_t getClassVersion() { return classVersion; }
64  Int_t getLength() { return arraySize; }
65  Int_t getNumParams();
66  UChar_t* getStreamerInfo() { return streamerInfo; }
68  void print();
69 
70  protected:
71  template<class type>
72  void printData(type*, Int_t);
73 
74  private:
75  FairParamObj& operator=(const FairParamObj&);
76 
77  // Class for binary parameter object (name + binary array)
78  ClassDef(FairParamObj, 0);
79 };
80 
81 class FairParamList : public TObject
82 {
83  protected:
84  THashTable paramList; // List for parameters stored as string
85  class FairParamTFile : public TFile
86  {
87  public:
89  {
90  // Create StreamerInfo index
91  Int_t lenIndex = gROOT->GetListOfStreamerInfo()->GetSize() + 1;
92  if (lenIndex < 5000) {
93  lenIndex = 5000;
94  }
95  fClassIndex = new TArrayC(lenIndex);
96  }
98  {
99  delete fClassIndex;
100  fClassIndex = 0;
101  }
102  };
103 
104  public:
105  FairParamList();
106  ~FairParamList();
107  void add(FairParamObj&);
108  void add(const Text_t*, const Text_t*);
109  void add(const Text_t*, Int_t);
110  void add(const Text_t*, Bool_t);
111  void add(const Text_t*, UInt_t);
112  void add(const Text_t*, Float_t);
113  void add(const Text_t*, Double_t);
114  void add(const Text_t*, TArrayI&);
115  void add(const Text_t*, TArrayC&);
116  void add(const Text_t*, TArrayF&);
117  void add(const Text_t*, TArrayD&);
118  void add(const Text_t*, const UChar_t*, const Int_t);
119  void add(const Text_t*, const Int_t*, const Int_t);
120  void add(const Text_t*, const Float_t*, const Int_t);
121  void add(const Text_t*, const Double_t*, const Int_t);
122  void addObject(const Text_t*, TObject*);
123  Bool_t fill(const Text_t*, Text_t*, const Int_t);
124  Bool_t fill(const Text_t*, Int_t*, const Int_t nValues = 1);
125  Bool_t fill(const Text_t*, Bool_t*, const Int_t nValues = 1);
126  Bool_t fill(const Text_t*, UInt_t*, const Int_t nValues = 1);
127  Bool_t fill(const Text_t*, Float_t*, const Int_t nValues = 1);
128  Bool_t fill(const Text_t*, Double_t*, const Int_t nValues = 1);
129  Bool_t fill(const Text_t*, UChar_t*, const Int_t nValues = 1);
130  Bool_t fill(const Text_t*, TArrayI*);
131  Bool_t fill(const Text_t*, TArrayC*);
132  Bool_t fill(const Text_t*, TArrayF*);
133  Bool_t fill(const Text_t*, TArrayD*);
134  Bool_t fillObject(const Text_t*, TObject*);
135  void print();
136  FairParamObj* find(const Text_t* name) { return static_cast<FairParamObj*>(paramList.FindObject(name)); }
137  THashTable* getList() { return &paramList; }
138 
139  private:
141  FairParamList& operator=(const FairParamList&);
142 
143  // Class for lists of parameters (of type FairParamObj)
144  ClassDef(FairParamList, 4);
145 };
146 
147 #endif /* !FAIRPARAMLIST_H */
Int_t bytesPerValue
Definition: FairParamList.h:32
void printData(type *, Int_t)
const char * getParamType()
Definition: FairParamList.h:61
THashTable * getList()
UChar_t * paramValue
Definition: FairParamList.h:28
Int_t classVersion
Definition: FairParamList.h:33
void addObject(const Text_t *, TObject *)
Bool_t fillObject(const Text_t *, TObject *)
void setParamValue(UChar_t *, const Int_t)
THashTable paramList
Definition: FairParamList.h:84
FairParamObj(const Text_t *name="")
UChar_t * setLength(Int_t l)
TString paramType
Definition: FairParamList.h:30
UChar_t * getParamValue()
Definition: FairParamList.h:59
Int_t getClassVersion()
Definition: FairParamList.h:63
UChar_t * setStreamerInfoSize(Int_t)
Bool_t basicType
Definition: FairParamList.h:31
Int_t getBytesPerValue()
Definition: FairParamList.h:62
Int_t streamerInfoSize
Definition: FairParamList.h:35
Bool_t fill(const Text_t *, Text_t *, const Int_t)
Bool_t isBasicType()
Definition: FairParamList.h:60
Int_t getLength()
Definition: FairParamList.h:64
Int_t getNumParams()
void setParamType(const Text_t *t)
UChar_t * getStreamerInfo()
Definition: FairParamList.h:66
void setClassVersion(const Int_t v)
Definition: FairParamList.h:56
Int_t getStreamerInfoSize()
Definition: FairParamList.h:67
void setStreamerInfo(UChar_t *, const Int_t)
UChar_t * streamerInfo
Definition: FairParamList.h:34
void add(FairParamObj &)
FairParamObj * find(const Text_t *name)