Jpp  test_elongated_shower_pde
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  string csv;
32  int debug;
33 
34  try {
35 
36  JParser<> zap("Auxiliary program to print data from data base.");
37 
38  zap['s'] = make_field(server) = getServernames();
39  zap['u'] = make_field(usr) = "";
40  zap['!'] = make_field(pwd) = "";
41  zap['C'] = make_field(cookie) = "";
42  zap['q'] = make_field(query) = "";
43  zap['@'] = make_field(selection) = JPARSER::initialised();
44  zap['W'] = make_field(width) = 16;
45  zap['c'] = make_field(csv) = " ";
46  zap['d'] = make_field(debug) = 1;
47 
48  zap(argc, argv);
49  }
50  catch(const exception &error) {
51  FATAL(error.what() << endl);
52  }
53 
54  DEBUG("Server: " << JDB::getServer().HostName() << endl);
55  DEBUG("Selection:" << endl << selection << endl);
56 
57  try {
58 
59  JDB::reset(usr, pwd, cookie);
60 
61  ResultSet& rs = getResultSet(query, selection);
62 
63  for (unsigned int i = 0; i != rs.FieldCount(); ++i) {
64  cout << (i != 0 ? csv : "") << setw(width) << left << rs.FieldName(i) << flush;
65  }
66  cout << endl;
67 
68  while (rs.Next()) {
69  for (unsigned int i = 0; i != rs.FieldCount(); ++i) {
70  cout << (i != 0 ? csv : "") << setw(width) << left << rs.GetString(i) << flush;
71  }
72 
73  cout << endl;
74  }
75 
76  rs.Close();
77  }
78  catch(const exception& error) {
79  FATAL(error.what() << endl);
80  }
81 
82  return 0;
83 }
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:68
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