14 #include "dbclient/KM3NeTDBClient.h" 
   33   using KM3NeT::DB::DBException;
 
   34   using KM3NeT::DB::Server;
 
   35   using KM3NeT::DB::Client;
 
   36   using KM3NeT::DB::ResultSet;
 
   37   using KM3NeT::DB::Selector;
 
   76     { 
"Default", Server::Default },
 
   77     { 
"Test",    Server::Test    },
 
   78     { 
"Lyon",    Server::Lyon    },
 
   79     { 
"Lyon2",   Server::Lyon2   },
 
   80     { 
"Napoli",  Server::Napoli  }
 
   90   inline const Server& 
getServer(
const std::string& server)
 
   93       if (element.first == server) {
 
   94         return element.second;
 
  111     const char* 
const server = getenv(
"DATABASE_SERVER");
 
  113     if (server != NULL) {
 
  114       buffer.push_back(server);
 
  118       if (std::find(buffer.begin(), buffer.end(), element.first) == buffer.end()) {
 
  119         buffer.push_back(element.first);
 
  139     const char* 
const server = getenv(
"DATABASE_SERVER");
 
  146       return Server::Default;
 
  157     const char* home = getenv(
"HOME");
 
  159     return MAKE_CSTRING((home != NULL ? home : 
".") << 
"/" << 
".km3netdb_cookie");
 
  170     return getenv(
"DBCOOKIE");
 
  191     public std::shared_ptr<Client>
 
  249       if (db.
get() != NULL) {
 
  251         static_cast<std::shared_ptr<Client>&
>(db).
reset();
 
  262     static void reset(
const std::string& usr,
 
  263                       const std::string& pwd)
 
  265       static_cast<std::shared_ptr<Client>&
>(
JDB::get()) = Client::Create(
getServer(), usr.c_str(), pwd.c_str());
 
  274     static void reset(
const std::string& cookie)
 
  279       string buffer = cookie;
 
  283         ifstream in(cookie.c_str());
 
  292       if (pos != string::npos) {
 
  293         buffer.erase(0, pos);
 
  296       static_cast<std::shared_ptr<Client>&
>(
JDB::get()) = Client::Create(
getServer(), buffer.c_str());
 
  314     static void reset(
const std::string& usr,
 
  315                       const std::string& pwd,
 
  316                       const std::string& cookie)
 
  321       if      (usr != 
"" && pwd != 
"")
 
  323       else if (cookie != 
"")
 
  358     if (in >> 
static_cast<std::string&
>(server)) {
 
  371   template<
class JTable_t>
 
  384   template<
class JTable_t, 
class JType_t>
 
  385   inline const char* 
getColumn(JType_t JTable_t::*data_member)
 
  388     TClass*   rc = 
dynamic_cast<TClass*
>(TDictionary::GetDictionary(
typeid(JTable_t)));
 
  392       for( std::unique_ptr<TIterator> i(rc->GetListOfDataMembers()->MakeIterator()); 
const TDataMember* p = (
const TDataMember*) i->Next(); ) {
 
  394         if (p->GetOffset() == (
char*) &(pc->*data_member) - (
char*) pc) {
 
  409   template<
class JTable_t>
 
  416     TClass*   rc = 
dynamic_cast<TClass*
>(TDictionary::GetDictionary(
typeid(JTable_t)));
 
  420       for (std::unique_ptr<TIterator> i(rc->GetListOfDataMembers()->MakeIterator()); 
const TDataMember* p = (
const TDataMember*) i->Next(); ) {
 
  422           buffer.push_back(p->GetName());
 
  452     return JDB::get()->StreamDS(query.c_str(), selection);
 
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
 
I/O formatting auxiliaries.
 
#define MAKE_CSTRING(A)
Make C-string.
 
static Server & get_server()
Get server.
 
static JDB & get()
Get connection to database.
 
static void reset(const std::string &cookie)
Reset connection to database.
 
static void reset(const std::string &usr, const std::string &pwd)
Reset connection to database.
 
static void reset()
Reset connection to database.
 
static const Server & getServer()
Get server.
 
static void setServer(const Server &server)
Set server.
 
JDB & operator=(const JDB &)
 
JDB()
Default constructor.
 
static void reset(const std::string &usr, const std::string &pwd, const std::string &cookie)
Reset connection to database.
 
Auxiliary classes and methods for database I/O.
 
const Server & getServer()
Get default server.
 
const char * getPrivateCookie()
Get private cookie.
 
static const std::string PREFIX_ADF
 
const char * getPublicCookie()
Get public cookie.
 
const char * getTable()
Get table name.
 
std::vector< std::string > getColumns()
Get column names.
 
static std::vector< std::pair< JServer, Server > > LIST_OF_SERVERS
Named list of available database servers.
 
ResultSet & getResultSet(const std::string &query, const std::vector< Selector > &selection)
Get result set.
 
static const std::string PREFIX_DATAFILTER
This string is prepended to every parameter in the database output for the corresponding process.
 
std::istream & operator>>(std::istream &in, JServer &server)
Read server name from input stream.
 
void get_json(json &js, const std::string &query, const std::vector< Selector > &selection)
Get json.
 
static const char PREFIX_COOKIE
Cookie prefix.
 
const char * getColumn(JType_t JTable_t::*data_member)
Get column name.
 
const Server & getServer(const std::string &server)
Get server by name.
 
static const JVersion APIV2_VERSION(2, 1, 0)
 
std::vector< JServer > getServernames()
Get list of names of available database servers.
 
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
const char * getName()
Get ROOT name of given data type.
 
static JStat getFileStatus
Function object for file status.
 
Wrapper class for server name.
 
JServer(const char *server)
Constructor.
 
JServer()
Default constructor.
 
Auxiliary data structure for general purpose version number.
 
std::string toString() const
Convert version to string.
 
static bool is_class(const char *const name)
Check name of class against ROOT classes.