KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVDataBase.cpp
1/***************************************************************************
2$Id: KVDataBase.cpp,v 1.26 2009/01/22 13:55:00 franklan Exp $
3 KVDataBase.cpp - description
4 -------------------
5 begin : jeu fév 6 2003
6 copyright : (C) 2003 by Alexis Mignon
7 email : mignon@ganil.fr
8 ***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
19#include "KVDataBase.h"
20#include "TROOT.h"
21#include "Riostream.h"
22#include "TPluginManager.h"
23#include "KVNumberList.h"
24
25using namespace std;
26
27
29
32{
33 gROOT->GetRootFolder()->Add(this);
34 SetOwner(kTRUE);
35}
36
37
38
40
41KVDataBase::KVDataBase(const Char_t* name, const Char_t* title)
42 : TFolder(name, title)
43{
44 gROOT->GetRootFolder()->Add(this);
47}
48
49
50
52
54 : TFolder(name, "database")
55{
56 gROOT->GetRootFolder()->Add(this);
59}
60
61
62
65
67{
68 //reset global database pointer if it was pointing to this DB
69 gROOT->GetRootFolder()->Remove(this);
70 gROOT->GetListOfCleanups()->Remove(this);
71 Info("~KVDataBase", "%s", GetName());
72}
73
74
75
83
85{
86// Add a table to the list of available tables and return kTRUE
87// it's added. As each table must have a unique name we check if the new table's name
88// already exists, if not the table is added otherwise it's not added
89// and the method return kFALSE.
90//
91
92 //table with this name already in DB ?
93 if (GetTable(tab->GetName()))
94 return kFALSE;
95
96 Add(tab);
97 tab->SetFullPath(Form("//root/%s/%s", fFolderName.Data(), tab->GetName()));
98 return kTRUE;
99}
100
101
102
108
109KVDBTable* KVDataBase::AddTable(const Char_t* name, const Char_t* title,
110 Bool_t unique)
111{
112// Add a table to the list of tables and check if the new table's name already exists.
113// If it exists the table is not added and null pointer is returned, otherwise a new
114// table is created and added to the list and its address is returned.
115
116 //Table with this name already in DB ?
117 if (GetTable(name))
118 return 0;
119
120 KVDBTable* table = new KVDBTable(name, title, unique);
121 Add(table);
122 table->SetFullPath(Form("//root/%s/%s", fFolderName.Data(), name));
123 return table;
124}
125
126
127
132
134 const Char_t* rec_name) const
135{
136//
137// Return the KVDBRecord rec_name found in the table table_name
138//
139 KVDBTable* table = GetTable(table_name);
140 if (!table) {
141 TObject::Warning("GetRecord(const Char_t*,const Char_t*)",
142 "No Table named %s found.", table_name);
143 return NULL;
144 }
145 return table->GetRecord(rec_name);
146}
147
148
149
151
153{
154
155
156 cout << "_______________________________________________________" <<
157 endl;
158 cout << ClassName() << " : " << GetName() << " <---> " << GetTitle() <<
159 endl;
160 cout << "Available Tables :" << endl;
161 TIter next(GetTables());
163 while ((table = (KVDBTable*) next())) {
164 cout << " " << table->GetName() << endl;
165 }
166 cout << "_______________________________________________________" <<
167 endl;
168}
169
170
171
172
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
const char Option_t
char name[80]
#define gROOT
char * Form(const char *fmt,...)
Record folder for the database.
Definition KVDBRecord.h:43
Table in a database.
Definition KVDBTable.h:34
virtual void SetFullPath(const Char_t *path)
Definition KVDBTable.h:71
Simple cross-referenced database structure.
Definition KVDataBase.h:137
virtual void Print(Option_t *option="") const
virtual ~KVDataBase()
reset global database pointer if it was pointing to this DB
virtual KVDBTable * GetTable(const Char_t *table) const
Definition KVDataBase.h:159
virtual KVDBRecord * GetRecord(const Char_t *table_name, const Char_t *rec_name) const
virtual TList * GetTables() const
Definition KVDataBase.h:164
TString fFolderName
Definition KVDataBase.h:139
virtual Bool_t AddTable(KVDBTable *table)
virtual void Add(TObject *obj)
virtual void SetOwner(Bool_t owner=kTRUE)
const char * GetName() const override
const char * GetTitle() const override
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
const char * Data() const
Table in an SQLite database.
ClassImp(TPyArg)