Jpp  pmt_effective_area_update
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPrintDB.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 
4 #include "dbclient/KM3NeTDBClient.h"
5 
6 #include "JDB/JDB.hh"
7 #include "JDB/JSelector.hh"
8 
9 #include "Jeep/JParser.hh"
10 #include "Jeep/JMessage.hh"
11 
12 
13 /**
14  * \file
15  *
16  * Auxiliary program to print data from data base.
17  * \author mdejong
18  */
19 int main(int argc, char **argv)
20 {
21  using namespace std;
22  using namespace JPP;
23 
24  JServer server;
25  string usr;
26  string pwd;
27  string cookie;
28  string query;
29  JSelector selection;
30  int width;
31  int debug;
32 
33  try {
34 
35  JParser<> zap("Auxiliary program to print data from data base.");
36 
37  zap['s'] = make_field(server) = getServernames();
38  zap['u'] = make_field(usr) = "";
39  zap['!'] = make_field(pwd) = "";
40  zap['C'] = make_field(cookie) = "";
41  zap['q'] = make_field(query) = "";
42  zap['@'] = make_field(selection) = JPARSER::initialised();
43  zap['W'] = make_field(width) = 16;
44  zap['d'] = make_field(debug) = 1;
45 
46  zap(argc, argv);
47  }
48  catch(const exception &error) {
49  FATAL(error.what() << endl);
50  }
51 
52  DEBUG("Server: " << JDB::getServer().HostName() << endl);
53  DEBUG("Selection:" << endl << selection << endl);
54 
55  try {
56 
57  JDB::reset(usr, pwd, cookie);
58 
59  ResultSet& rs = getResultSet(query, selection);
60 
61  for (unsigned int i = 0; i != rs.FieldCount(); ++i) {
62  cout << ' ' << setw(width) << left << rs.FieldName(i) << flush;
63  }
64  cout << endl;
65 
66  while (rs.Next()) {
67  for (unsigned int i = 0; i != rs.FieldCount(); ++i) {
68  cout << ' ' << setw(width) << left << rs.GetString(i) << flush;
69  }
70 
71  cout << endl;
72  }
73  }
74  catch(const exception& error) {
75  FATAL(error.what() << endl);
76  }
77 
78  return 0;
79 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
const Server & getServer(const std::string &server)
Get server by name.
Definition: JDB.hh:81
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
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.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:432
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:98