Jpp  master_rocky-43-ge265d140c
the software that should make you happy
Functions
getLocationID.cc File Reference

Auxiliary program to get location ID corresponding to given user login. More...

#include <iostream>
#include <iomanip>
#include "dbclient/KM3NeTDBClient.h"
#include "JDB/JDB.hh"
#include "JDB/JPersons.hh"
#include "JDB/JSelector.hh"
#include "JDB/JDBToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to get location ID corresponding to given user login.

Author
bjung

Definition in file getLocationID.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 21 of file getLocationID.cc.

22 {
23  using namespace std;
24  using namespace JPP;
25 
26  JServer server;
27  string usr;
28  string pwd;
29  string cookie;
30  string login;
31  int debug;
32 
33  try {
34 
35  JParser<> zap("Auxiliary program to get location ID corresponding to given user login.");
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['L'] = make_field(login) = "";
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  JSelector selector = getSelector<JPersons>(login.empty() ? JDB::get()->User() : login);
56  ResultSet& rs = getResultSet(getTable<JPersons>(), selector);
57 
58  JPersons personalia;
59  rs >> personalia;
60 
61  cout << personalia.LOCATIONID << endl;
62  }
63  catch(const exception& error) {
64  FATAL(error.what() << endl);
65  }
66 }
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Auxiliary class for specifying selection of database data.
Utility class to parse command line options.
Definition: JParser.hh:1698
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:437
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:107
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
void reset(T &value)
Reset value.
Definition: JSTDTypes.hh:14
std::string LOCATIONID
Definition: JPersons.hh:29
Wrapper class for server name.
Definition: JDB.hh:53
Template definition for getting table specific selector.