1 #ifndef _Q_GLOBALHANDLE_HH_
2 #define _Q_GLOBALHANDLE_HH_
47 GlobalHandle(
const std::string& name,
const std::string& defaultOwner =
"")
128 void AddKey(
const std::string& key,
const int digits)
135 void SetKey(
const std::string& key,
const int value)
138 std::stringstream msg;
140 <<
" has no extra key: \""
142 <<
"\". Add it via GloabalHandle::AddKey() in your GlobalHandle ctor)";
152 std::stringstream msg;
154 <<
" has no extra key: \""
156 <<
"\". Add it via GloabalHandle::AddKey() in your GlobalHandle ctor)";
182 std::stringstream msg;
183 msg<<
"Global Object (Name: \""<<this->
GetName()
211 std::string str =
"Error while opening file: \"";
212 str += fname +
"\": ";
213 str +=
err.GetDescription();
214 err.SetDescription(str);
220 if(tobj->IsValid())
fObject->Validate();
223 std::string str =
"Error while reading object: \"";
225 str +=
"From file \"";
228 str +=
err.GetDescription();
229 err.SetDescription(str);
242 std::stringstream strstr;
244 strstr<<
"StoreOnFile(): global Object (Name: \""<<this->
GetName()
245 <<
"\" , Owner: \""<<this->
GetOwner()<<
"\") is not valid, so it is not being written";
252 std::string str =
"Error while opening file: \"";
253 str += fname +
"\": ";
254 str +=
err.GetDescription();
255 err.SetDescription(str);
259 std::string str =
"Error while writing object: \"";
264 str +=
err.GetDescription();
265 err.SetDescription(str);
275 std::stringstream strstr;
276 strstr<<
"FillFromDB() is not implemented for object of type: "
278 <<
"\" , Owner: \""<<this->
GetOwner()<<
"\")."
279 <<
" Write a specific GlobalHandle!";
288 std::stringstream strstr;
289 strstr<<
"StoreOnDB() is not implemented for object of type: "
291 <<
"\" , Owner: \""<<this->
GetOwner()<<
"\")."
292 <<
" Write a specific GlobalHandle!";
319 std::stringstream msg;
321 <<
" already owns a QObject"
std::string Demangle(const C &obj, int firstChar=0)
#define Q_BEGIN_NAMESPACE
template class to handle diana global QObject with QGlobalDataManager
int GetDataset() const
Get dataset of validity.
const QError & GetError() const
Get I/O error.
GlobalHandle()
default ctor. Needed to compile on gcc3
Q * fMyObject
Object created by this class.
GlobalHandle(const std::string &name, const std::string &defaultOwner="")
ctor
void SetRunInterval(const int start, const int end)
Set Validity Interval.
QGlobalLabel fLabel
unique identifier of the object
int GetBeginRun() const
Get first run of validity.
void SetDescription(const std::string &descr)
set object description (experimental)
const std::string & GetName() const
Get object name.
virtual QError FillFromFile(const std::string &fname)
fill QObject from file fname
int GetKey(const std::string &key) const
Get extra integer key.
std::string fDescription
Object description.
int GetEndRun() const
Get last run of validity.
std::string fVersion
Version of the QObject to be read / written.
void SetDatasetInterval(const int start, const int end)
Set Dataset Validity Interval.
virtual ~GlobalHandle()
dtor
virtual QError StoreOnDB()
store object on DB, non const version
bool IsValid() const
check QObject validity
virtual QError StoreOnDB() const
store object on DB
int GetEndDataset() const
Get last dataset of validity.
void AddKey(const std::string &key, const int digits)
Add an extra integer key to the label.
Q **const GetAddress() const
get object address (const)
virtual QError StoreOnFile(const std::string &fname) const
store object on file fname
int GetRun() const
Get run of validity.
void SetKey(const std::string &key, const int value)
Set extra integer key to value.
const QGlobalLabel & GetLabel() const
Get label.
const GlobalHandle< Q > & operator=(const GlobalHandle< Q > &other)
operator= must not be used, use copy ctor
int GetBeginDataset() const
Get first dataset of validity.
Q ** GetAddress()
get object address
void CreateObject()
instantiate object of type Q
void SetChannel(const int chan)
Set Channel.
int GetChannel() const
Get Channel associated to the object.
std::string fDefaultOwner
Default owner of the QObject.
void SetOwner(const std::string &owner)
set object owner
std::string GetVersion() const
Get version tag of the object, if any.
const std::string & GetOwner() const
Get object owner.
void GetValidityInterval(int &beginRun, int &endRun) const
Get run validity interval.
int GetChannel2() const
Get Second Channel associated to the object.
GlobalHandle(const GlobalHandle< Q > &other)
copy ctor
QError fGlobalDataManagerError
I/O error from the QGlobalDataManager.
const std::string & GetDefaultOwner() const
Get default owner (may be set by inheriting classes)
void SetRun(const int run)
Set BeginRun = EndRun = run.
void Set(const Q &obj)
set the QObject
virtual QError FillFromDB()
fill object from DB
const Q & Get() const
get the QObject
void SetVersion(const std::string &tag)
set version tag of the object to be read (used by QGlobalDataManager)
bool HaveKey(const std::string &key) const
void SetDataset(const int ds)
Set dataset of validity.
void SetChannel2(const int chan)
Set Channel2.
error class with error type and description
void SetDescription(const std::string &descr)
set error description
const std::string & GetDescription() const
get error description
Object to manage I/O (DB, file, or memory) of diana global quantities.
Label for global QObject's.
std::map< std::string, ExtraKey > fExtraKeys
std::string fName
Object name.
std::string fOwner
Object owner.
std::string GetStringLabel() const
convert label to string
int fBeginRun
begin validity
QGlobalReader * GetReader(const std::string &filename, QError &err)
get reader
static QGlobalReaderDispatcher & GetInstance()
Abstract class for global readers.
const Q * Get(const std::string &name, QError &err) const
Get QObject, owned by this reader.
QGlobalWriter * GetWriter(const std::string &filename, QError &err)
get writer
static QGlobalWriterDispatcher & GetInstance()
Abstract class for global writers.
QError Set(const std::string &name, const Q &obj, const std::string &descr="")
Set QObject, owned by the caller, - leave it undeclared if you can't implement it.