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")) {
170 if (!
fObjDB->has_table(
"objInfos")) {
180 fObjDB->add_missing_columns(
"objInfos", infos);
187 obj->
Write(unique_id);
191 fObjDB->prepare_data_insertion(
"objTable");
195 fObjDB->insert_data_row();
196 fObjDB->end_data_insertion();
198 fObjDB->select_data(
"objTable",
"obj_idx",
Form(
"unique_id='%s'", unique_id.
Data()));
200 while (
fObjDB->get_next_result()) obj_idx =
get_objTable()[
"obj_idx"].get_data<
int>();
202 fObjDB->prepare_data_insertion(
"objInfos");
204 info_copy.
SetValue(
"obj_idx", obj_idx);
208 fObjDB->insert_data_row();
209 fObjDB->end_data_insertion();
236 while (!colnames.
End()) {
237 std::cout << colnames.
Next() << tabs;
239 std::cout <<
"\n==========================================================================================\n";
240 if (
fObjDB->select_data(
"objTable,objInfos", colnames)) {
241 while (
fObjDB->get_next_result()) {
243 while (!colnames.
End()) {
244 auto colname = colnames.
Next();
245 if (colname ==
"name" || colname ==
"class")
250 std::cout << std::endl;
254 Error(
"ls",
"Problem with KVSQLite::database::select_data");
303 fObjDB->select_data(
"objTable,objInfos",
"unique_id", where);
304 while (
fObjDB->get_next_result()) {
360 fObjDB->select_data(
"objTable,objInfos",
Form(
"unique_id,%s", numberlist_column.
Data()), where);
361 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.
void WriteObject(const TObject *, const KVNameValueList &)
void FillListOfObjectsWithSelection(KVSeqCollection *list, const KVString &where)
KVSQLite::table & get_objTable() const
KVSQLite::table & get_objInfos() const
TObject * Get(const KVString &name) const
Return pointer to object with given name.
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 ls(Option_t *="") const override
List the contents of the file with associated infos.
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.
void primary_key(const TString &cols)
void foreign_key(const TString &child_key, const TString &parent_table, const TString &parent_key)
TString get_column_names(const TString &exclude="", const TString &delim=",") const
column & add_column(const KVSQLite::column &c)
void prepare_data(const KVNameValueList &, const KVNamedParameter *=nullptr)
KaliVeda extensions to ROOT collection classes.
void Add(TObject *obj) override
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