18 #define DATASVC_MULTISTORESVC_CPP
49 struct Partition final {
106 template <
typename... Args,
typename... UArgs>
109 return m_current.dataProvider ? (m_current.dataProvider->*pmf)(std::forward<UArgs>(
args)...)
112 template <
typename... Args,
typename... UArgs>
115 return m_current.dataManager ? (m_current.dataManager->*pmf)(std::forward<UArgs>(
args)...)
179 for(
auto &
i : m_partitions) {
180 i.second.dataManager->clearStore().ignore();
226 return activate(m_defaultPartition);
248 return activate(m_defaultPartition);
254 m_dataLoader = pDataLoader;
255 if ( m_dataLoader ) m_dataLoader->
setDataProvider(dpsvc ? dpsvc :
this);
256 for(
auto&
i : m_partitions) {
257 i.second.dataManager->setDataLoader(m_dataLoader.
get()).ignore();
433 return create(nam, typ, pPartition);
437 if (
get(nam, pPartition).isSuccess() )
return PARTITION_EXISTS;
440 if (!isvc)
return NO_INTERFACE;
443 if ( !dataMgr || !dataProv )
return NO_INTERFACE;
444 m_partitions.
emplace( nam, Partition{ dataProv, dataMgr, nam } );
450 auto i = m_partitions.
find(nam);
451 if (
i == m_partitions.
end() )
return PARTITION_NOT_PRESENT;
452 if (
i->second.dataManager == m_current.dataManager ) {
453 m_current = Partition();
455 i->second.dataManager->clearStore().ignore();
463 if ( !provider )
return NO_INTERFACE;
465 [&](Partitions::const_reference p) {
466 return p.second.dataProvider == provider;
468 if (
i==
std::end(m_partitions))
return PARTITION_NOT_PRESENT;
469 i->second.dataManager->clearStore().ignore();
476 auto i = m_partitions.
find(nam);
477 if (
i != m_partitions.
end() ) {
478 m_current =
i->second;
481 m_current = Partition();
482 return PARTITION_NOT_PRESENT;
488 m_current = Partition();
489 if ( !provider )
return NO_INTERFACE;
491 [&](Partitions::const_reference p) {
492 return p.second.dataProvider == provider;
494 if (
i ==
std::end(m_partitions))
return PARTITION_NOT_PRESENT;
495 m_current =
i->second;
501 auto i = m_partitions.
find(nam);
502 if (
i != m_partitions.
end() ) {
503 pPartition =
i->second.dataProvider;
506 pPartition =
nullptr;
507 return PARTITION_NOT_PRESENT;
512 if ( m_current.dataProvider ) {
513 nam = m_current.name;
514 pPartition = m_current.dataProvider;
518 pPartition =
nullptr;
519 return NO_ACTIVE_PARTITION;
524 m_addrCreator =
service(m_loader,
true);
525 if (!m_addrCreator) {
527 <<
"Failed to retrieve data loader "
528 <<
"\"" << m_loader <<
"\"" <<
endmsg;
532 auto dataLoader = service<IConversionSvc>(
m_loader,
true);
534 error() <<
"Failed to retrieve data loader "
535 <<
"\"" << m_loader <<
"\"" <<
endmsg;
539 if (!
sc.isSuccess()) {
540 error() <<
"Failed to set data loader "
541 <<
"\"" << m_loader <<
"\"" <<
endmsg;
547 m_addrCreator.
reset();
548 m_dataLoader.
reset();
559 error() <<
"Failed to connect to all store partitions." <<
endmsg;
569 error() <<
"Enable to reinitialize base class"
576 error() <<
"Failed to attach necessary services." <<
endmsg;
581 error() <<
"Failed to connect to store partitions." <<
endmsg;
593 m_current = Partition();
623 for(
auto&
i : m_partitions) {
636 sc =
i.second.dataManager->setRoot(
m_root.
path, pAdd);
658 for(
auto &
i : m_partitions)
i.second.dataManager->clearStore().ignore();
659 m_partitions.clear();
668 for(
auto part: m_partitionDefs) {
669 for(
auto attrib: Parser(
std::move(part))) {
670 switch( ::
toupper(attrib.tag[0]) ) {
681 if ( m_defaultPartition.
empty() ) m_defaultPartition = nam;
virtual StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent)=0
IDataManagerSvc: Explore the object store: retrieve the object's parent.
Parse attribute strings allowing iteration over the various attributes.
STATUS objectLeaves(const IRegistry *pObject, std::vector< IRegistry * > &leaves) override
Explore the object store: retrieve all leaves attached to the object.
virtual const std::string * par() const =0
Retrieve String parameters.
StatusCode initialize() override
STATUS clearSubTree(CSTR &path) override
Remove all data objects below the sub tree identified.
STATUS unregisterObject(CSTR &path) override
Unregister object from the data store.
STATUS removePreLoadItem(CSTR &item) override
Add an item to the preload list.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
STATUS preLoad() override
load all preload items of the list
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Partitions m_partitions
Datastore partitions.
STATUS unlinkObject(CSTR &path) override
Remove a link to another object.
STATUS finalize() override
Service initialisation.
STATUS registerAddress(CSTR &path, ADDRESS *pAddr) override
IDataManagerSvc: Register object address with the data store.
PartitionDefs m_partitionDefs
Datastore partition definitions.
StatusCode finalize() override
virtual StatusCode addPreLoadItem(const DataStoreItem &item)=0
Add an item to the preload list.
STATUS updateObject(OBJECT *pObj) override
Update object.
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ipar, IOpaqueAddress *&refpAddress)=0
Create a Generic address using explicit arguments to identify a single object.
virtual StatusCode clearSubTree(const std::string &sub_path)=0
Remove all data objects below the sub tree identified by its full path name.
Invalid root path object cannot be retrieved or stored.
STATUS objectParent(const OBJECT *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
STATUS findObject(OBJECT *parent, int item, OBJECT *&pObject) override
Find object in the data store.
bool isSuccess() const
Test for a status code of SUCCESS.
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
virtual StatusCode preLoad()=0
Load all preload items of the list.
STATUS registerObject(CSTR &parent, CSTR &obj, OBJECT *pObj) override
Register object with the data store.
virtual StatusCode resetPreLoad()=0
Clear the preload list.
STATUS unregisterAddress(OBJECT *pParent, CSTR &path) override
IDataManagerSvc: Unregister object address from the data store.
STATUS unregisterObject(CSTR &parent, CSTR &obj) override
Unregister object from the data store.
STATUS unlinkObject(OBJECT *from, CSTR &objPath) override
Remove a link to another object.
virtual unsigned long release()=0
release reference to object
STATUS create(CSTR &nam, CSTR &typ, IInterface *&pPartition) override
Create a partition object. The name identifies the partition uniquely.
virtual StatusCode unregisterAddress(const std::string &fullPath)=0
Unregister object address from the data store.
STATUS findObject(CSTR &parent, int item, OBJECT *&pObject) override
Find object in the data store.
STATUS reinitialize() override
Service initialisation.
Data provider interface definition.
STATUS removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
Description of the DataStoreItem class.
virtual long svcType() const =0
Retrieve service type.
STATUS linkObject(OBJECT *from, CSTR &objPath, OBJECT *to) override
Add a link to another object.
std::string m_rootName
Name of root event.
SmartIF< IConversionSvc > m_dataLoader
Pointer to data loader service.
STATUS traverseSubTree(CSTR &path, AGENT *pAgent) override
Analyze by traversing all data objects below the sub tree.
#define DECLARE_COMPONENT(type)
STATUS create(CSTR &nam, CSTR &typ) override
Create a partition object. The name identifies the partition uniquely.
STATUS linkObject(CSTR &from, CSTR &objPath, OBJECT *to) override
Add a link to another object.
STATUS setDataLoader(IConversionSvc *pDataLoader, IDataProviderSvc *dpsvc=nullptr) override
IDataManagerSvc: Pass a default data loader to the service.
STATUS updateObject(CSTR &parent, CSTR &updatePath) override
Update object.
std::vector< std::string > PartitionDefs
virtual StatusCode removePreLoadItem(const DataStoreItem &item)=0
Remove an item from the preload list.
TYPE * get() const
Get interface pointer.
STATUS updateObject(OBJECT *parent, CSTR &updatePath) override
Update object.
STATUS makePartitions()
Create all partitions according to job options.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
const std::string & name() const override
Retrieve name of the service.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
STATUS retrieveObject(CSTR &path, OBJECT *&pObj) override
Retrieve object identified by its full path from the data store.
STATUS unlinkObject(IRegistry *from, CSTR &objPath) override
Remove a link to another object.
STATUS unregisterAddress(IRegistry *pParent, CSTR &path) override
IDataManagerSvc: Unregister object address from the data store.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
virtual StatusCode findObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Find object identified by its directory entry.
STATUS setRoot(std::string path, OBJECT *pObj) override
Initialize data store for new event by giving new event path and root object.
virtual const CLID & clID() const =0
Retrieve class information from link.
virtual StatusCode traverseTree(IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects in the data store.
STATUS addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
STATUS findObject(IRegistry *parent, CSTR &path, OBJECT *&pObj) override
Find object identified by its full path in the data store.
virtual StatusCode unregisterObject(const std::string &fullPath)=0
Unregister object from the data store.
STATUS retrieveObject(IRegistry *parent, CSTR &path, OBJECT *&pObj) override
Retrieve object from data store.
virtual StatusCode linkObject(IRegistry *from, const std::string &objPath, DataObject *toObj)=0
Add a link to another object.
General service interface definition.
STATUS clearSubTree(OBJECT *pObject) override
Remove all data objects below the sub tree identified.
This class is used for returning status codes from appropriate routines.
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
STATUS activate(CSTR &nam) override
Activate a partition object. The name identifies the partition uniquely.
Definition of the basic interface.
struct MultiStoreSvc::tagROOT m_root
STATUS registerObject(CSTR &path, OBJECT *pObj) override
Register object with the data store.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
STATUS findObject(CSTR &parent, CSTR &path, OBJECT *&pObj) override
Find object in the data store.
MultiStoreSvc(CSTR &name, ISvcLocator *svc)
Standard Constructor.
StatusCode reinitialize() override
STATUS retrieveObject(CSTR &parent, int item, OBJECT *&pObj) override
Retrieve object from data store.
STATUS unregisterObject(OBJECT *pObj, CSTR &path) override
Unregister object from the data store.
STATUS linkObject(CSTR &fullPath, OBJECT *to) override
Add a link to another object.
STATUS clearPartitions()
Clear all partitions.
unsigned int CLID
Class ID definition.
STATUS call_(STATUS(IDataProviderSvc::*pmf)(Args...), UArgs &&...args)
union MultiStoreSvc::tagROOT::@1 root
std::string m_loader
Data loader name.
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
const std::string & rootName() const override
Name for root Event.
Partition m_current
Current partition.
STATUS unregisterAddress(CSTR &path) override
IDataManagerSvc: Unregister object address from the data store.
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
STATUS retrieveObject(OBJECT *parent, CSTR &path, OBJECT *&pObj) override
Retrieve object from data store.
STATUS preparePartitions()
Prepare partition for usage.
STATUS objectLeaves(const OBJECT *pObject, std::vector< IRegistry * > &leaves) override
Explore the object store: retrieve all leaves attached to the object.
STATUS unregisterObject(OBJECT *pObj) override
Unregister object from the data store.
STATUS setRoot(std::string path, ADDRESS *pAddr) override
Initialize data store for new event by giving new event path and address of root object.
virtual StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves)=0
Explore the object store: retrieve all leaves attached to the object The object is identified by its ...
virtual unsigned long release()
release reference to object
STATUS resetPreLoad() override
Clear the preload list.
STATUS unregisterObject(OBJECT *pObj, int item) override
Unregister object from the data store.
STATUS initialize() override
Service initialisation.
Generic data agent interface.
STATUS drop(CSTR &nam) override
Drop a partition object. The name identifies the partition uniquely.
Base class used to extend a class implementing other interfaces.
virtual StatusCode unlinkObject(IRegistry *from, const std::string &objPath)=0
Remove a link to another object.
STATUS activate(IInterface *pPartition) override
Activate a partition object.
STATUS addPreLoadItem(CSTR &item) override
Add an item to the preload list.
StatusCode activePartition(std::string &nam, IInterface *&pPartition) const override
Access the active partition object.
SmartIF< IAddressCreator > m_addrCreator
Reference to address creator.
STATUS registerObject(OBJECT *parent, CSTR &obj, OBJECT *pObj) override
Register object with the data store.
CLID m_rootCLID
Integer Property corresponding to CLID of root entry.
STATUS retrieveObject(OBJECT *parent, int item, OBJECT *&pObj) override
Retrieve object from data store.
STATUS findObject(CSTR &path, OBJECT *&pObj) override
Find object identified by its full path in the data store.
STATUS retrieveObject(CSTR &parent, CSTR &path, OBJECT *&pObj) override
Retrieve object from data store.
STATUS linkObject(IRegistry *from, CSTR &objPath, OBJECT *to) override
Add a link to another object.
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
STATUS updateObject(CSTR &path) override
Update object.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
virtual StatusCode registerAddress(const std::string &fullPath, IOpaqueAddress *pAddress)=0
Register object address with the data store.
Opaque address interface definition.
STATUS unregisterObject(CSTR &parent, int obj) override
Unregister object from the data store.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
virtual StatusCode registerObject(const std::string &fullPath, DataObject *pObject)=0
Register object with the data store.
STATUS traverseSubTree(OBJECT *pObject, AGENT *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects below the sub tree.
virtual StatusCode traverseSubTree(const std::string &sub_path, IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects below the sub tree identified by its full path name...
STATUS call_(STATUS(IDataManagerSvc::*pmf)(Args...), UArgs &&...args)
std::map< std::string, Partition > Partitions
A DataObject is the base class of any identifiable object on any data store.
STATUS clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
std::string m_defaultPartition
Default partition.
STATUS registerObject(CSTR &parent, int item, OBJECT *pObj) override
Register object with the data store.
STATUS registerAddress(OBJECT *parent, CSTR &path, ADDRESS *pAddr) override
IDataManagerSvc: Register object address with the data store.
STATUS registerAddress(IRegistry *parent, CSTR &path, ADDRESS *pAdd) override
IDataManagerSvc: Register object address with the data store.
STATUS updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
STATUS unlinkObject(CSTR &from, CSTR &objPath) override
Remove a link to another object.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
STATUS findObject(OBJECT *parent, CSTR &path, OBJECT *&pObject) override
Find object in the data store.
void toupper(std::string &s)
STATUS drop(IInterface *pPartition) override
Drop a partition object. The name identifies the partition uniquely.
STATUS traverseTree(AGENT *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
STATUS objectParent(const IRegistry *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
STATUS registerObject(OBJECT *parent, int obj, OBJECT *pObj) override
Register object with the data store.
~MultiStoreSvc() override
Standard Destructor.
virtual unsigned long addRef()=0
Add reference to object.
virtual StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.