Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPrintRunsetup.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <map>
4 
5 #include "JDB/JDB.hh"
6 #include "JDB/JDBToolkit.hh"
7 #include "JDB/JSelector.hh"
9 #include "JDB/JAllParams.hh"
10 #include "JDB/JRunsetupParams.hh"
11 
12 #include "Jeep/JParser.hh"
13 #include "Jeep/JMessage.hh"
14 
15 
16 /**
17  * \file
18  * Auxiliary program to print run setup data.
19  * \author lnauta
20  */
21 int main(const int argc, const char * const argv[])
22 {
23  using namespace std;
24  using namespace JPP;
25 
26  string usr;
27  string pwd;
28  string cookie;
29  string detid;
30  string rs_oid;
31  int debug;
32 
33  try {
34 
35  JParser<> zap("Auxiliary program to print run setup data.");
36 
37  zap['u'] = make_field(usr) = "";
38  zap['!'] = make_field(pwd) = "";
39  zap['C'] = make_field(cookie) = "";
40  zap['D'] = make_field(detid);
41  zap['R'] = make_field(rs_oid);
42  zap['d'] = make_field(debug) = 1;
43 
44  zap(argc, argv);
45  }
46  catch(const exception& error) {
47  FATAL(error.what() << endl);
48  }
49 
50 
51  try {
52 
53  JDB::reset(usr, pwd, cookie);
54 
55  if (is_integer(detid)) {
56  detid = getDetector(to_value<int>(detid));
57  }
58 
60 
61  {
62  ResultSet& rs = getResultSet(getTable<JAllParams>()); //, getSelector<JAllParams>("DATAACQUISITION"));
63 
64  for (JAllParams buffer; rs >> buffer; ) {
65  umap[buffer.OID] = buffer.NAME;
66  }
67 
68  rs.Close();
69  }
70 
71  ResultSet& rs = getResultSet(getTable<JRunsetupParams>(), getSelector<JRunsetupParams>(detid, rs_oid));
72 
73  for (JRunsetupParams buffer; rs >> buffer; ) {
74  cout << setw(24) << left << buffer.UPIFILTER << right << " " << buffer.PAR_OID << " -> " << umap[buffer.PAR_OID] << " = " << buffer.VALUE << endl;
75  }
76  }
77  catch(const exception& error) {
78  FATAL(error.what() << endl);
79  }
80 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
JDetectorsHelper getDetector
Function object for mapping serial number to object identifier of detector and vice versa...
Definition: JDBToolkit.cc:5
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
bool is_integer(const std::string &buffer)
Check if string is an integer.
Definition: JLangToolkit.hh:58
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
void reset(T &value)
Reset value.
Utility class to parse command line options.
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:269