1#include "KVSQLROOTFile.h"
14 fObjDB->select_data(
"objTable",
"unique_id",
Form(
"name = \"%s\"",
name.Data()));
16 while (fObjDB->get_next_result())
17 uuid = get_objTable()[
"unique_id"].get_data<
KVString>();
31 if (it !=
fObjList.end())
return it->second;
83 if (
OPT.Contains(
"CREATE")) {
89 TString rpath = FP +
"objStore.root";
96 TString sqlpath = FP +
"objInfos.sqlite";
99 if (
OPT.Contains(
"CREATE")) {
169 if (!
fObjDB->has_table(
"objInfos")) {
177 fObjDB->add_missing_columns(
"objInfos", infos);
184 obj->
Write(unique_id);
188 fObjDB->prepare_data_insertion(
"objTable");
192 fObjDB->insert_data_row();
193 fObjDB->end_data_insertion();
195 fObjDB->select_data(
"objTable",
"obj_idx",
Form(
"unique_id=\"%s\"", unique_id.
Data()));
197 while (
fObjDB->get_next_result()) obj_idx =
get_objTable()[
"obj_idx"].get_data<
int>();
199 fObjDB->prepare_data_insertion(
"objInfos");
201 info_copy.
SetValue(
"obj_idx", obj_idx);
205 fObjDB->insert_data_row();
206 fObjDB->end_data_insertion();
233 while (!colnames.
End()) {
234 std::cout << colnames.
Next() << tabs;
236 std::cout <<
"\n==========================================================================================\n";
237 if (
fObjDB->select_data(
"objTable,objInfos", colnames)) {
238 while (
fObjDB->get_next_result()) {
240 while (!colnames.
End()) {
241 auto colname = colnames.
Next();
242 if (colname ==
"name" || colname ==
"class")
247 std::cout << std::endl;
251 Error(
"ls",
"Problem with KVSQLite::database::select_data");
300 fObjDB->select_data(
"objTable,objInfos",
"unique_id", where);
301 while (
fObjDB->get_next_result()) {
357 fObjDB->select_data(
"objTable,objInfos",
Form(
"unique_id,%s", numberlist_column.
Data()), where);
358 while (
fObjDB->get_next_result()) {
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
void SetValue(const Char_t *name, value_type value)
Strings used to represent a set of ranges of values.
Bool_t Contains(Int_t val) const
returns kTRUE if the value 'val' is contained in the ranges defined by the number list
Combine ROOT file containing objects with SQLite database with info on the objects.
KVSQLite::table & get_objInfos() const
void WriteObject(const TObject *, const KVNameValueList &)
KVSQLite::table & get_objTable() const
void FillListOfObjectsWithSelection(KVSeqCollection *list, const KVString &where)
TObject * Get(const KVString &name) const
Return pointer to object with given name.
void ls(Option_t *="") const
List the contents of the file with associated infos.
std::unordered_map< std::string, TObject * > fObjList
for quick look-up of objects using unique id
TObject * get_object_with_UUID(const KVString &name) const
Retrieve object from file using its name.
void restore_working_directory()
KVString UUID_for_object(const KVString &) const
Return unique identifier used to store object with given name in ROOT file.
std::unique_ptr< TFile > fObjStore
TString fCurrentROOTFilePath
full path to current ROOT file
std::unique_ptr< KVSQLite::database > fObjDB
KVSQLROOTFile(const KVString &filepath, Option_t *option="READ")
void save_working_directory()
Interface to ROOT SQLite database backend.
const column & add_foreign_key(const TString &other_table, const TString &other_column)
const column & add_primary_key(const TString &name)
column & add_column(const KVSQLite::column &c)
TString get_column_names(const TString &exclude="", const TString &delim=",") const
void prepare_data(const KVNameValueList &, const KVNamedParameter *=nullptr)
KaliVeda extensions to ROOT collection classes.
virtual void Add(TObject *obj)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
virtual const char * GetName() const
virtual const char * ClassName() const
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
virtual void Error(const char *method, const char *msgfmt,...) const
const char * Data() const
TString & Append(char c, Ssiz_t rep=1)
virtual int Chmod(const char *file, UInt_t mode)
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
virtual char * ExpandPathName(const char *path)
virtual int Unlink(const char *name)
const char * AsString() const