9 #include "dbclient/KM3NeTDBClient.h"
20 namespace JDATABASE {}
21 namespace JPP {
using namespace JDATABASE; }
25 using KM3NeT::DB::DBException;
26 using KM3NeT::DB::Server;
27 using KM3NeT::DB::Client;
28 using KM3NeT::DB::ResultSet;
29 using KM3NeT::DB::Selector;
39 const char* home = getenv(
"HOME");
41 return MAKE_CSTRING((home != NULL ? home :
".") <<
"/" <<
".km3netdb_cookie");
52 return getenv(
"DBCOOKIE");
73 public std::shared_ptr<Client>
96 if (db.
get() != NULL) {
98 static_cast<std::shared_ptr<Client>&
>(db).
reset();
109 static void reset(
const std::string& usr,
110 const std::string& pwd)
112 static_cast<std::shared_ptr<Client>&
>(
JDB::get()) = Client::Create(Server::Default, usr.c_str(), pwd.c_str());
121 static void reset(
const std::string& cookie)
126 string buffer = cookie;
130 ifstream
in(cookie.c_str());
139 if (pos != string::npos) {
140 buffer.erase(0, pos);
143 static_cast<std::shared_ptr<Client>&
>(
JDB::get()) = Client::Create(Server::Default, buffer.c_str());
161 static void reset(
const std::string& usr,
162 const std::string& pwd,
163 const std::string& cookie)
168 if (usr !=
"" && pwd !=
"")
170 else if (cookie !=
"")
199 template<
class JTable_t>
212 template<
class JTable_t,
class JType_t>
213 inline const char*
getColumn(JType_t JTable_t::*data_member)
216 TClass* rc =
dynamic_cast<TClass*
>(TDictionary::GetDictionary(
typeid(JTable_t)));
220 TIterator* i = rc->GetListOfDataMembers()->MakeIterator();
222 for (
const TDataMember* p; (p = (
const TDataMember*) i->Next()) != NULL; ) {
224 if (p->GetOffset() == (
char*) &(pc->*data_member) - (
char*) pc) {
239 template<
class JTable_t>
246 TClass* rc =
dynamic_cast<TClass*
>(TDictionary::GetDictionary(
typeid(JTable_t)));
250 TIterator* i = rc->GetListOfDataMembers()->MakeIterator();
252 for (
const TDataMember* p; (p = (
const TDataMember*) i->Next()) != NULL; ) {
254 buffer.push_back(p->GetName());
284 return JDB::get()->StreamDS(query.c_str(), selection);
static void reset()
Reset connection to database.
static void reset(const std::string &cookie)
Reset connection to database.
const char * getTable()
Get table name.
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
#define MAKE_CSTRING(A)
Make C-string.
static const std::string PREFIX_ADF
const char * getColumn(JType_t JTable_t::*data_member)
Get column name.
const char * getPrivateCookie()
Get private cookie.
std::vector< std::string > getColumns()
Get column names.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
static const char PREFIX_COOKIE
Cookie prefix.
static JStat getFileStatus
Function object for file status.
static const std::string PREFIX_DATAFILTER
This string is prepended to every parameter in the database output for the corresponding process...
static void reset(const std::string &usr, const std::string &pwd, const std::string &cookie)
Reset connection to database.
const char * getPublicCookie()
Get public cookie.
Auxiliary class for connection to data base.
ResultSet & getResultSet(const std::string &query)
Get result set.
static void reset(const std::string &usr, const std::string &pwd)
Reset connection to database.
JDB()
Default constructor.
const char * getName()
Get ROOT name of given data type.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
JDB & operator=(const JDB &)
static JDB & get()
Get connection to database.