EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairDetParTSQLIo.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairDetParTSQLIo.cxx
1 /***************************************
2  * Author: M.Babai (M.Babai@rug.nl) *
3  * License: *
4  * Version: *
5  ***************************************/
6 #include "FairDetParTSQLIo.h"
7 
8 #include "FairRun.h"
9 #include "FairRuntimeDb.h"
10 #include "FairDbMultConnector.h"
11 #include "FairRtdbRun.h"
12 #include "FairParSet.h"
13 
15 
16 
18  : FairDetParIo(),
19  fDefaultDb(-1),
20  fConnections(new FairDbMultConnector()),
21  fcontainerList(0),
22  factContVers(0),
23  actRunId(-1)
24 {}
25 
35  : FairDetParIo(),
36  fDefaultDb(dbNum),
37  fConnections(new FairDbMultConnector(cons)),
38  fcontainerList(0),
39  factContVers(0),
40  actRunId(-1)
41 {}
42 
45 {
46  std::cout << "\n\t<DEBUG> FairDetParTSQLIo::~FairDetParTSQLIo()\n\n";
47  if( fConnections ) {
48  delete fConnections;
49  }
50 
51  if( factContVers ) {
52  delete factContVers;
53  }
54 
55  if( fcontainerList ) {
56  fcontainerList->Delete();
57  delete fcontainerList;
58  }
59 }
60 
62 {
63  std::cout << "\n\n\n\n\t<DEBUG> FairDetParTSQLIo::getRunStart(FairParSet* pPar)\n\n\n\n";
64  actRunId=-1;
65  int runStart=-1;
67 
68  if (!factContVers) {
69  Error("getRunStart()","current run not set in runtime database");
70  return -1;
71  }
72 
73  const Text_t* refRun=factContVers->getRefRun();
74 
75  if (strlen(refRun) > 0) {
76  sscanf(refRun,"%i",&actRunId);
77  } else {
79  }
80 
81  if(pPar) {
82  Int_t contVers = 10;//getPredefVersion(pPar);
83  if (contVers>=0) {
84  actRunId = contVers;
85  }
86  }
87  //runStart=pConn->getRunStart(actRunId);
88  return runStart;
89 }
90 
92 {
93  // sets the changed flag, the version (id of actual run) and the comment
94  pPar->setChanged();
95  //pPar->setInputVersion(getActRunId(), inputNumber);
96  TString s="Read from TSQL\n Valid for Run Id ";
97  //s.Append(Form("%d",getActRunId()));
98  s.Append("\n Status at ");
99  //s.Append(pConn->getHistoryDate());
100  pPar->setDescription(s.Data());
101 }
102 
103 // commits changes.
105 {
106  std::cerr << "<ERROR> Commit() is Not implemented yet. Maybe later"
107  << std::endl;
108 }
109 
110 // Undo the changes made since last commit.
112 {
113  std::cerr << "<ERROR> Rollback() Not implemented yet. Maybe later\n"
114  << " It remains engine dependent."
115  << std::endl;
116 }
117 
118 
120 {
121  std::cout << "========================================================\n";
122  pars->Print();
123  std::cout << "\n\t<DEBUG>FairDetParTSQLIo::READ(FairParSet* pars)\n"
124  << "========================================================\n";
125  return false;
126 }
127 
129 {
130  std::cout << "========================================================\n"
131  <<"\t<DEBUG> FairDetParTSQLIo::WRITE(FairParSet* pars)\n"
132  << "Name is = " << pars->GetName() << " "
133  << " Desc = " << pars->getDescription() << " "
134  << " Autho = " << pars->getAuthor() << " "
135  << " Context = " << pars->getParamContext() << " "
136  << " DetNAme = " << pars->getDetectorName()
137  << "\n========================================================\n";
138  return 0;
139 }