EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairDbConfigSet.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairDbConfigSet.cxx
1 
2 #include "FairDb.h"
3 #include "FairDbConfigSet.h"
4 #include "FairDbOutRowStream.h"
5 #include "FairDbResult.h"
6 
7 //#include "FairDbResPtr.h"
8 //#include "FairDbWriter.h"
9 
10 #include <iostream>
11 
13 
14 
15 
16 #include "FairDbResPtr.tpl"
18 
19 #include "FairDbWriter.tpl"
20 template class FairDbWriter<FairDbConfigSet>;
21 
22 
24 {
25 
26  for ( vector<Param*>::iterator itr = fParams.begin();
27  itr != fParams.end();
28  ++itr ) { delete (*itr); }
29 
30 }
31 
32 
33 ostream& operator<<(ostream& s, const FairDbConfigSet& cfSet)
34 {
35 
36  s << "FairDbConfigSet: Number of parameters: "
37  << cfSet.GetNumParams() << endl;
38 
39  for ( UInt_t iParam = 0; iParam < cfSet.GetNumParams(); ++iParam) {
40  s << " " << cfSet.GetParamName(iParam) << ": "
41  << cfSet.GetParamValue(iParam) << " ("
42  << cfSet.GetParamType(iParam).AsString() << ")" << endl;
43  }
44 
45  return s;
46 
47 }
48 
49 
50 
51 
53  const FairDbValidityRec* vrec)
54 {
55 
56 // Don't count leading SeqNo, its already been skipped.
57  UInt_t numParams = rs.NumCols()-1;
58 // Skip the ROW_COUNTER if present
59  if ( rs.HasRowCounter() ) { --numParams; }
60 
61  for (UInt_t iParam = 0; iParam < numParams; ++iParam ) {
62  Param* par = new Param;
63  par->Name = rs.CurColName();
64  par->Value = rs.CurColValue();
65  par->Type = rs.CurColFieldType();
66 
67  fParams.push_back(par);
68  rs.IncrementCurCol();
69  }
70 
71  fAggregateNo = vrec->GetAggregateNo ();
72 
73 }
74 
75 string FairDbConfigSet::GetParamName(UInt_t parNo) const
76 {
77 
78  return ( parNo <= GetNumParams() ) ?
79  fParams[parNo]->Name : "";
80 
81 }
82 
84 {
85 
86  return ( parNo <= GetNumParams() ) ?
88 
89 }
90 
91 string FairDbConfigSet::GetParamValue(UInt_t parNo) const
92 {
93 
94  return ( parNo <= GetNumParams() ) ?
95  fParams[parNo]->Value : "";
96 
97 }
98 
99 
100 void FairDbConfigSet::PushBack(const string& name,
101  const string& value,
102  const FairDbFieldType& type)
103 {
104 
105  fParams.push_back(new Param(name,value,type));
106 }
107 
108 
110  const FairDbValidityRec* /* vrec */) const
111 {
112 
113  for ( vector<Param*>::const_iterator itr = fParams.begin();
114  itr != fParams.end();
115  ++itr ) { ors.Store((*itr)->Value.c_str()); }
116 
117 }
118