![]() |
Diana Software
|
Object to manage I/O (DB, file, or memory) of diana global quantities. More...
Classes | |
| struct | CachedObject |
| store source of cached objects More... | |
Public Member Functions | |
| QGlobalDataManager () | |
| constructor More... | |
| ~QGlobalDataManager () | |
| dtor More... | |
| void | Clear () |
| clear cache More... | |
| template<class Q > | |
| QError | Get (const std::string &owner, GlobalHandle< Q > *gh, const std::string &inSource, bool printError=true) const |
| Get an object using a global handle. More... | |
| template<class Q > | |
| QError | Get (GlobalHandle< Q > *gh, const std::string &inSource, bool printError=true) const |
| Get an object owned by the caller module using a global handle. More... | |
| template<class Q > | |
| const Q & | Get (const std::string &owner, const std::string &name, const std::string &inSource) const |
| Get a QObject of type Q. More... | |
| template<class Q > | |
| const Q & | Get (const std::string &name, const std::string &inSource) const |
| Get a QObject of type Q owned by the caller module. More... | |
| template<class Q > | |
| QError | Set (GlobalHandle< Q > *gh, const std::string &outSource, bool printError=true) const |
| Set a QObject using a GlobalHandle. More... | |
| template<class Q > | |
| QError | Set (const std::string &name, const Q &obj, const std::string &outSource) const |
| Set a QObject of type Q. More... | |
| std::vector< QGlobalLabel > | GetWriteLabels () const |
| get labels More... | |
| const QObject * | GetByLabel (const QGlobalLabel &) const |
| get object by label (not-recommended). Works only on cached object's More... | |
| void | SetOwner (const std::string &owner) |
| set the module that is accessing this object More... | |
| void | SetInputVersion (std::string versionTag) |
| set the version tag of the object to be read (default = this release) More... | |
| void | EnableCache (const bool enable) |
| enable / disable caching of objects More... | |
| void | Dump (std::ostream &o) const |
| Dump cached objects to stream. More... | |
| bool | GetCacheEnable () const |
Static Public Member Functions | |
| static QGlobalDataManager & | GetInstance (const std::string &owner="") |
| singleton interface provided for use in non diana executables. Do not use it within diana or root macros. More... | |
Private Attributes | |
| std::string | fOwner |
| the module that is accessing this object More... | |
| std::map< QGlobalLabel, CachedObject > | fDataMap |
| cached QObject 's More... | |
| std::map< QGlobalLabel, std::string > | fDefaultMap |
| default owners More... | |
| bool | fCacheEnabled |
| cache enabled More... | |
| std::string | fOutputVersion |
| Version tag of this release, used to write onto the DB. Parameter not accessible to the user. More... | |
| std::string | fInputVersion |
| Version tag of the objects to be read, used to read from the DB. Parameter not accessible to the user in diana, but accesible outside diana. More... | |
Static Private Attributes | |
| static int | fInstances = 0 |
| number of instances More... | |
| static QGlobalDataManager * | fUniqueInstance = 0 |
| singleton instance More... | |
Friends | |
| class | QBaseModule |
Object to manage I/O (DB, file, or memory) of diana global quantities.
QGlobalDataManager is the I/O class for global QObject s. Any QObject can be saved or retrived using this class. It is interfaced with the DB and files via Get/Set interfaces, using the GlobalHandle class to wrap the QObject s and store their ancillary information. Like in the QEvent, each object has a type, a name and an owner. When this class is invoked in diana via QBaseModule::GlobalData(), the owner of the QObject s that will be saved is automatically set as the name of the caller module. To retrive a QObject owned by someone else, the owner must be specified, as in the QEvent.
A global QObject is identified int the QGlobalDataManager cache by its label. The label is composed by the owner and the name, plus the ancillary information that have been provided. Only the needed ancillary information must be filled. The QGlobalDataManager can be used both in ROOT macros and in external compiled code.
The QGlobalDataManager by default caches QObject s, to speed up the I/O in Diana and to avoid the declaration of the input source every time the QObject is read. A QObject can also be saved in the cache without saving it in a file or a DB. This feature can be used to share global data between modules.
Warning: The I/O source is not recorded in the cache. So if a QObject of same type and same GlobalHandle ancillary information of an already read QObject is read specifying a different input source, the returned QObject will be the cached one and the one from the second source will be ignored (an error will be printed). When using the QGlobalDataManager outside diana users can disable the cache (via EnableCache(false)) and get the same QObject from different sources.
Definition at line 48 of file QGlobalDataManager.hh.
| QGlobalDataManager::QGlobalDataManager | ( | ) |
constructor
Definition at line 25 of file QGlobalDataManager.cc.
References fCacheEnabled, fInputVersion, fInstances, fOutputVersion, fOwner, and QSWInfo::GetDianaCleanVersionTag().
Referenced by GetInstance().
| QGlobalDataManager::~QGlobalDataManager | ( | ) |
| void QGlobalDataManager::Clear | ( | ) |
clear cache
Definition at line 47 of file QGlobalDataManager.cc.
References fDataMap, and fDefaultMap.
Referenced by QSequence::QSequence(), ~QGlobalDataManager(), and QSequence::~QSequence().
| void QGlobalDataManager::Dump | ( | std::ostream & | o | ) | const |
Dump cached objects to stream.
Definition at line 58 of file QGlobalDataManager.cc.
References QObject::Dump(), QGlobalLabel::fBeginRun, QGlobalLabel::fChannel, fDataMap, QGlobalLabel::fEndRun, QGlobalLabel::fName, fOwner, QGlobalLabel::fOwner, QObject::IsValid(), and QStringHandler::Resize().
Referenced by main(), and QSequence::PrintGlobal().
|
inline |
enable / disable caching of objects
Definition at line 169 of file QGlobalDataManager.hh.
References fCacheEnabled.
Referenced by ScanEvents().
|
inline |
Get a QObject of type Q owned by the caller module.
| name | name of the object |
| insource | "filename" or "" to access cached object's;
const QMyObject& obj = dm.Get<QMyObject>("ObjectName","DB");
|
Definition at line 118 of file QGlobalDataManager.hh.
References GlobalHandle< Q >::Get(), and Get().
|
inline |
Get a QObject of type Q.
| owner | name of the module that set the quantity |
| name | name of the object |
| inSource | "filename" or "" to access cached object's;
const QMyObject& obj = dm.Get<QMyObject>("ModuleNameWithoutM","ObjectName","DB");
|
Definition at line 104 of file QGlobalDataManager.hh.
References GlobalHandle< Q >::Get(), and Get().
| QError QGlobalDataManager::Get | ( | const std::string & | owner, |
| GlobalHandle< Q > * | gh, | ||
| const std::string & | inSource, | ||
| bool | printError = true |
||
| ) | const |
Get an object using a global handle.
| owner | name of the module that set the quantity |
| gh | GlobalHandle class to be filled |
| inSource | "DB" or "filename" or "" to access cached object's |
| printError | print errors on screen and logfile. Error is anyhow stored in the return value; |
GlobalHandle<QMyObject> handle("ObjectName");
handle.SetChannel(3); // optional
handle.SetRun(000809); // optional
dm.Get("ModuleNameWithoutM",&handle,"DB");
const QMyObject& obj = handle.Get();
Definition at line 220 of file QGlobalDataManager.hh.
References QMessageHandler::Debug(), err, QMessageHandler::Error(), fCacheEnabled, fDataMap, fDefaultMap, GlobalHandle< Q >::fGlobalDataManagerError, GlobalHandle< Q >::FillFromDB(), GlobalHandle< Q >::FillFromFile(), fInputVersion, QGlobalLabel::fOwner, GlobalHandle< Q >::GetAddress(), GlobalHandle< Q >::GetDefaultOwner(), GlobalHandle< Q >::GetLabel(), GlobalHandle< Q >::GetOwner(), QGlobalLabel::GetStringLabel(), GlobalHandle< Q >::GetVersion(), QERR_GLOBAL_GENERIC, QERR_SUCCESS, GlobalHandle< Q >::SetOwner(), and GlobalHandle< Q >::SetVersion().
Referenced by QFileWriter::BuildFileName(), QTriggerOptimumFilter::BuildOptimumFilter(), QFileWriter::Do(), DrawAveragePulse(), FillFromDB(), Get(), QInitFileHandler::GetBool(), QInitFileHandler::GetDouble(), QInitFileHandler::GetInt(), QInitFileHandler::GetQObject(), QInitFileHandler::GetStdVector(), QInitFileHandler::GetString(), main(), Read(), QSequence::Run(), QSequence::SaveConfig(), ScanEvents(), and StoreOnDB().
| QError QGlobalDataManager::Get | ( | GlobalHandle< Q > * | gh, |
| const std::string & | inSource, | ||
| bool | printError = true |
||
| ) | const |
Get an object owned by the caller module using a global handle.
| bgh | GlobalHandle class to be filled |
| inSource | "DB" or "filename" or "" to access cached object's |
| printError | print errors on screen and logfile. Error is anyhow stored in the return value; |
GlobalHandle<QMyObject> handle("ObjectName");
handle.SetChannel(3); // optional
handle.SetRun(000809); // optional
dm.Get(&handle,"DB");
const QMyObject& obj = handle.Get();
Definition at line 214 of file QGlobalDataManager.hh.
References fOwner, Get(), GlobalHandle< Q >::GetOwner(), and GlobalHandle< Q >::SetOwner().
| const QObject * QGlobalDataManager::GetByLabel | ( | const QGlobalLabel & | label | ) | const |
get object by label (not-recommended). Works only on cached object's
Definition at line 125 of file QGlobalDataManager.cc.
References fDataMap.
|
inline |
Definition at line 174 of file QGlobalDataManager.hh.
References fCacheEnabled.
|
static |
singleton interface provided for use in non diana executables. Do not use it within diana or root macros.
| owner | owner of the objects that will be seved. Must be specified at the first call of this function. |
Definition at line 13 of file QGlobalDataManager.cc.
References DianaThrow, fUniqueInstance, QGlobalDataManager(), and SetOwner().
| std::vector< QGlobalLabel > QGlobalDataManager::GetWriteLabels | ( | ) | const |
|
inline |
Set a QObject of type Q.
| name | name of the QObject |
| obj | the QObject to be saved |
| outsource | "filename" or "" to set an object in memory;
QMyObject obj;
dm.Set("ObjectName",obj,"filename");
|
Definition at line 149 of file QGlobalDataManager.hh.
References GlobalHandle< Q >::Set(), and Set().
| QError QGlobalDataManager::Set | ( | GlobalHandle< Q > * | gh, |
| const std::string & | outSource, | ||
| bool | printError = true |
||
| ) | const |
Set a QObject using a GlobalHandle.
| bgh | GlobalHandle class to be stored |
| outSource | "DB" or "filename" or "" to set an object in memory; |
| printError | print errors on screen and logfile. Error is anyhow stored in the return value;
QMyObject obj;
GlobalHandle<QMyObject> handle("ObjectName");
handle.SetChannel(3); // optional
handle.SetRun(000809); // optional
handle.Set(obj)
dm.Set(&handle,"DB");
|
Definition at line 304 of file QGlobalDataManager.hh.
References QMessageHandler::Debug(), err, QMessageHandler::Error(), fCacheEnabled, fDataMap, fDefaultMap, fOutputVersion, fOwner, QGlobalLabel::fOwner, GlobalHandle< Q >::GetAddress(), GlobalHandle< Q >::GetLabel(), GlobalHandle< Q >::GetOwner(), QGlobalLabel::GetStringLabel(), GlobalHandle< Q >::GetVersion(), GlobalHandle< Q >::IsValid(), QERR_GLOBAL_GENERIC, QERR_SUCCESS, GlobalHandle< Q >::SetOwner(), GlobalHandle< Q >::SetVersion(), GlobalHandle< Q >::StoreOnDB(), and GlobalHandle< Q >::StoreOnFile().
Referenced by DrawAveragePulse(), main(), QSequence::Run(), QSequence::SaveConfig(), Set(), StoreOnDB(), Write(), QInitFileHandler::WriteBool(), QInitFileHandler::WriteDouble(), QInitFileHandler::WriteInt(), QInitFileHandler::WriteQObject(), QInitFileHandler::WriteStdVector(), and QInitFileHandler::WriteString().
|
inline |
set the version tag of the object to be read (default = this release)
Definition at line 166 of file QGlobalDataManager.hh.
References fInputVersion.
Referenced by QSequence::Run().
|
inline |
set the module that is accessing this object
Definition at line 163 of file QGlobalDataManager.hh.
References fOwner.
Referenced by QBaseModule::BeginBase(), DrawAveragePulse(), QBaseModule::EndBase(), FillFromDB(), GetInstance(), main(), QBaseModule::ProcessBase(), Read(), QSequence::Run(), QSequence::SaveConfig(), ScanEvents(), StoreOnDB(), Write(), QInitFileHandler::WriteBool(), QInitFileHandler::WriteDouble(), QInitFileHandler::WriteInt(), QInitFileHandler::WriteQObject(), QInitFileHandler::WriteStdVector(), and QInitFileHandler::WriteString().
|
friend |
Definition at line 209 of file QGlobalDataManager.hh.
|
private |
cache enabled
Definition at line 195 of file QGlobalDataManager.hh.
Referenced by EnableCache(), Get(), GetCacheEnable(), QGlobalDataManager(), and Set().
|
mutableprivate |
cached QObject 's
Definition at line 189 of file QGlobalDataManager.hh.
Referenced by Clear(), Dump(), Get(), GetByLabel(), GetWriteLabels(), and Set().
|
mutableprivate |
default owners
Definition at line 192 of file QGlobalDataManager.hh.
|
private |
Version tag of the objects to be read, used to read from the DB. Parameter not accessible to the user in diana, but accesible outside diana.
Definition at line 205 of file QGlobalDataManager.hh.
Referenced by Get(), QGlobalDataManager(), and SetInputVersion().
|
staticprivate |
number of instances
Definition at line 198 of file QGlobalDataManager.hh.
Referenced by QGlobalDataManager(), and ~QGlobalDataManager().
|
private |
Version tag of this release, used to write onto the DB. Parameter not accessible to the user.
Definition at line 201 of file QGlobalDataManager.hh.
Referenced by QGlobalDataManager(), and Set().
|
private |
the module that is accessing this object
Definition at line 185 of file QGlobalDataManager.hh.
Referenced by Dump(), Get(), QGlobalDataManager(), Set(), and SetOwner().
|
staticprivate |
singleton instance
Definition at line 208 of file QGlobalDataManager.hh.
Referenced by GetInstance().