18 #define DATASVC_MULTISTORESVC_CPP 36 #include "boost/variant.hpp" 50 struct Partition final {
61 return dataProvider.get();
66 return dataManager.get();
71 template <
typename lambda>
72 struct arg_helper :
public arg_helper<decltype( &lambda::operator() )> {
74 template <
typename T,
typename Ret,
typename Arg>
75 struct arg_helper<Ret ( T::* )( Arg ) const> {
81 template <
typename lambda>
84 auto dispatch_variant = [](
auto&& variant,
auto&&... lambdas ) -> decltype(
auto ) {
120 boost::variant<boost::blank, ADDRESS*, OBJECT*>
root;
128 template <
typename Fun>
131 auto* svc = m_current.get<std::decay_t<detail::argument_t<Fun>>>();
204 for (
auto& i : m_partitions ) {
205 i.second.dataManager->clearStore().
ignore();
209 if ( p ) p->release();
211 []( boost::blank ) {} );
237 if ( p ) p->release();
239 []( boost::blank ) {} );
243 return activate( m_defaultPartition );
252 if ( p ) p->release();
254 []( boost::blank ) {} );
260 return activate( m_defaultPartition );
265 m_dataLoader = pDataLoader;
266 if ( m_dataLoader ) m_dataLoader->
setDataProvider( dpsvc ? dpsvc :
this );
267 for (
auto& i : m_partitions ) {
268 i.second.dataManager->setDataLoader( m_dataLoader.
get() ).ignore();
305 return registerObject(
nullptr, path, pObj );
487 return create( nam, typ, pPartition );
494 auto isvc = serviceLocator()->service<
IService>( typ );
499 m_partitions.
emplace( nam, Partition{dataProv, dataMgr, nam} );
506 auto i = m_partitions.
find( nam );
508 if ( i->second.dataManager == m_current.dataManager ) {
509 m_current = Partition();
511 i->second.dataManager->clearStore().ignore();
512 m_partitions.
erase( i );
522 [&]( Partitions::const_reference p ) {
return p.second.dataProvider == provider; } );
524 i->second.dataManager->clearStore().ignore();
525 m_partitions.
erase( i );
532 auto i = m_partitions.
find( nam );
533 if ( i != m_partitions.
end() ) {
534 m_current = i->second;
545 m_current = Partition();
548 [&]( Partitions::const_reference p ) {
return p.second.dataProvider == provider; } );
550 m_current = i->second;
557 auto i = m_partitions.
find( nam );
558 if ( i != m_partitions.
end() ) {
559 pPartition = i->second.dataProvider;
562 pPartition =
nullptr;
569 if ( m_current.dataProvider ) {
570 nam = m_current.name;
571 pPartition = m_current.dataProvider;
575 pPartition =
nullptr;
582 m_addrCreator = service( m_loader,
true );
583 if ( !m_addrCreator ) {
584 error() <<
"Failed to retrieve data loader " 585 <<
"\"" << m_loader <<
"\"" <<
endmsg;
589 auto dataLoader = service<IConversionSvc>( m_loader, true );
591 error() <<
"Failed to retrieve data loader " 592 <<
"\"" << m_loader <<
"\"" <<
endmsg;
595 auto sc = setDataLoader( dataLoader.get() );
596 if ( !sc.isSuccess() ) {
597 error() <<
"Failed to set data loader " 598 <<
"\"" << m_loader <<
"\"" <<
endmsg;
605 m_addrCreator.
reset();
606 m_dataLoader.
reset();
616 sc = makePartitions();
618 error() <<
"Failed to connect to all store partitions." <<
endmsg;
621 return attachServices();
629 error() <<
"Enable to reinitialize base class" <<
endmsg;
633 sc = attachServices();
635 error() <<
"Failed to attach necessary services." <<
endmsg;
638 sc = makePartitions();
640 error() <<
"Failed to connect to store partitions." <<
endmsg;
650 setDataLoader(
nullptr ).
ignore();
652 clearPartitions().
ignore();
653 m_current = Partition();
661 using extends::extends;
666 setDataLoader(
nullptr ).ignore();
667 resetPreLoad().ignore();
668 clearStore().ignore();
669 clearPartitions().ignore();
676 for (
auto& i : m_partitions ) {
680 if ( !address ) return StatusCode::FAILURE;
681 ADDRESS* pAdd = nullptr;
682 ADDRESS* p = address;
684 m_addrCreator->createAddress( p->svcType(), p->clID(), p->par(), p->ipar(), pAdd );
685 return sc.isSuccess() ? i.second.dataManager->setRoot( m_root.path, pAdd ) : sc;
687 [&](
OBJECT*
object ) -> StatusCode {
688 if ( object && object->clID() == CLID_DataObject ) {
689 return i.second.dataManager->setRoot( m_root.path, new DataObject() );
694 if ( !sc.isSuccess() ) iret = sc;
702 for (
auto& i : m_partitions ) i.second.dataManager->clearStore().
ignore();
703 m_partitions.clear();
712 clearPartitions().ignore();
713 for (
auto part : m_partitionDefs ) {
714 for (
auto attrib : Parser(
std::move( part ) ) ) {
715 switch (::
toupper( attrib.tag[0] ) ) {
726 if ( m_defaultPartition.empty() ) m_defaultPartition = nam;
virtual StatusCode traverseTree(IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects in the data store.
StatusCode detachServices()
Parse attribute strings allowing iteration over the various attributes.
StatusCode unregisterAddress(boost::string_ref path) override
IDataManagerSvc: Unregister object address from the data store.
Requested interface is not available.
StatusCode create(CSTR &nam, CSTR &typ) override
Create a partition object. The name identifies the partition uniquely.
constexpr static const auto FAILURE
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
StatusCode registerObject(OBJECT *parent, boost::string_ref obj, OBJECT *pObj) override
Register object with the data store.
StatusCode initialize() override
StatusCode clearSubTree(boost::string_ref path) override
Remove all data objects below the sub tree identified.
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 ...
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
virtual StatusCode unlinkObject(IRegistry *from, boost::string_ref objPath)=0
Remove a link to another object.
Partitions m_partitions
Datastore partitions.
StatusCode traverseTree(AGENT *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
StatusCode finalize() override
Implementation of property with value of concrete type.
StatusCode retrieveObject(OBJECT *parent, int item, OBJECT *&pObj) override
Retrieve object from data store.
virtual StatusCode addPreLoadItem(const DataStoreItem &item)=0
Add an item to the preload list.
const std::string & rootName() const override
Name for root Event.
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
StatusCode unlinkObject(IRegistry *from, boost::string_ref objPath) override
Remove a link to another object.
virtual StatusCode findObject(IRegistry *pDirectory, boost::string_ref path, DataObject *&pObject)=0
Find object identified by its directory entry.
StatusCode objectLeaves(const OBJECT *pObject, std::vector< IRegistry * > &leaves) override
Explore the object store: retrieve all leaves attached to the object.
Root type (address or object)
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
boost::variant< boost::blank, ADDRESS *, OBJECT * > root
StatusCode registerObject(boost::string_ref path, OBJECT *pObj) override
Register object with the data store.
virtual StatusCode preLoad()=0
Load all preload items of the list.
virtual StatusCode resetPreLoad()=0
Clear the preload list.
StatusCode updateObject(boost::string_ref parent, boost::string_ref updatePath) override
Update object.
StatusCode linkObject(boost::string_ref from, boost::string_ref objPath, OBJECT *to) override
Add a link to another object.
StatusCode linkObject(boost::string_ref fullPath, OBJECT *to) override
Add a link to another object.
StatusCode linkObject(IRegistry *from, boost::string_ref objPath, OBJECT *to) override
Add a link to another object.
Data provider interface definition.
Description of the DataStoreItem class.
StatusCode registerObject(boost::string_ref parent, int item, OBJECT *pObj) override
Register object with the data store.
StatusCode findObject(boost::string_ref path, OBJECT *&pObj) override
Find object identified by its full path in the data store.
virtual StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent)=0
IDataManagerSvc: Explore the object store: retrieve the object's parent.
SmartIF< IConversionSvc > m_dataLoader
Pointer to data loader service.
Invalid root path object cannot be retrieved or stored.
StatusCode attachServices()
virtual StatusCode linkObject(IRegistry *from, boost::string_ref objPath, DataObject *toObj)=0
Add a link to another object.
#define DECLARE_COMPONENT(type)
std::vector< std::string > PartitionDefs
virtual StatusCode removePreLoadItem(const DataStoreItem &item)=0
Remove an item from the preload list.
StatusCode unregisterObject(boost::string_ref path) override
Unregister object from the data store.
TYPE * get() const
Get interface pointer.
virtual StatusCode traverseSubTree(boost::string_ref sub_path, IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects below the sub tree identified by its full path name...
StatusCode setRoot(std::string path, OBJECT *pObj) override
Initialize data store for new event by giving new event path and root object.
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
StatusCode addPreLoadItem(std::string item) override
Add an item to the preload list.
StatusCode unregisterAddress(OBJECT *pParent, boost::string_ref path) override
IDataManagerSvc: Unregister object address from the data store.
StatusCode registerAddress(IRegistry *parent, boost::string_ref path, ADDRESS *pAddr) override
IDataManagerSvc: Register object address with the data store.
StatusCode retrieveObject(OBJECT *parent, boost::string_ref path, OBJECT *&pObj) override
Retrieve object from data store.
General service interface definition.
StatusCode findObject(IRegistry *parent, boost::string_ref path, OBJECT *&pObj) override
Find object identified by its full path in the data store.
StatusCode unregisterObject(boost::string_ref parent, boost::string_ref obj) override
Unregister object from the data store.
This class is used for returning status codes from appropriate routines.
typename arg_helper< lambda >::type argument_t
StatusCode drop(CSTR &nam) override
Drop a partition object. The name identifies the partition uniquely.
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
Definition of the basic interface.
StatusCode removePreLoadItem(std::string item) override
Add an item to the preload list.
StatusCode clearPartitions()
Clear all partitions.
StatusCode unregisterObject(OBJECT *pObj) override
Unregister object from the data store.
StatusCode findObject(boost::string_ref parent, int item, OBJECT *&pObject) override
Find object in the data store.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
StatusCode preparePartitions()
Prepare partition for usage.
StatusCode linkObject(OBJECT *from, boost::string_ref objPath, OBJECT *to) override
Add a link to another object.
StatusCode reinitialize() override
StatusCode unlinkObject(boost::string_ref path) override
Remove a link to another object.
virtual StatusCode retrieveObject(IRegistry *pDirectory, boost::string_ref path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
unsigned int CLID
Class ID definition.
virtual StatusCode clearSubTree(boost::string_ref sub_path)=0
Remove all data objects below the sub tree identified by its full path name.
StatusCode retrieveObject(boost::string_ref parent, int item, OBJECT *&pObj) override
Retrieve object from data store.
StatusCode updateObject(boost::string_ref path) override
Update object.
StatusCode traverseSubTree(OBJECT *pObject, AGENT *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects below the sub tree.
constexpr static const auto SUCCESS
Partition m_current
Current partition.
StatusCode findObject(OBJECT *parent, int item, OBJECT *&pObject) override
Find object in the data store.
StatusCode unlinkObject(boost::string_ref from, boost::string_ref objPath) override
Remove a link to another object.
StatusCode objectParent(const OBJECT *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode drop(IInterface *pPartition) override
Drop a partition object. The name identifies the partition uniquely.
StatusCode objectLeaves(const IRegistry *pObject, std::vector< IRegistry * > &leaves) override
Explore the object store: retrieve all leaves attached to the object.
virtual StatusCode unregisterAddress(boost::string_ref fullPath)=0
Unregister object address from the data store.
virtual StatusCode unregisterObject(boost::string_ref fullPath)=0
Unregister object from the data store.
StatusCode create(CSTR &nam, CSTR &typ, IInterface *&pPartition) override
Create a partition object. The name identifies the partition uniquely.
Generic data agent interface.
StatusCode resetPreLoad() override
Clear the preload list.
StatusCode updateObject(OBJECT *parent, boost::string_ref updatePath) override
Update object.
StatusCode retrieveObject(boost::string_ref parent, boost::string_ref path, OBJECT *&pObj) override
Retrieve object from data store.
Base class used to extend a class implementing other interfaces.
StatusCode findObject(boost::string_ref parent, boost::string_ref path, OBJECT *&pObj) override
Find object in the data store.
virtual StatusCode registerObject(boost::string_ref fullPath, DataObject *pObject)=0
Register object with the data store.
StatusCode setRoot(std::string path, ADDRESS *pAddr) override
Initialize data store for new event by giving new event path and address of root object.
const StatusCode & ignore() const
Ignore/check StatusCode.
StatusCode registerObject(boost::string_ref parent, boost::string_ref obj, OBJECT *pObj) override
Register object with the data store.
StatusCode updateObject(OBJECT *pObj) override
Update object.
SmartIF< IAddressCreator > m_addrCreator
Reference to address creator.
virtual StatusCode registerAddress(boost::string_ref fullPath, IOpaqueAddress *pAddress)=0
Register object address with the data store.
StatusCode activePartition(std::string &nam, IInterface *&pPartition) const override
Access the active partition object.
StatusCode activate(CSTR &nam) override
Activate a partition object. The name identifies the partition uniquely.
StatusCode activate(IInterface *pPartition) override
Activate a partition object.
StatusCode registerAddress(OBJECT *parent, boost::string_ref path, ADDRESS *pAddr) override
IDataManagerSvc: Register object address with the data store.
StatusCode unregisterObject(boost::string_ref parent, int obj) override
Unregister object from the data store.
StatusCode initialize() override
Service initialisation.
StatusCode unregisterObject(OBJECT *pObj, boost::string_ref path) override
Unregister object from the data store.
StatusCode setDataLoader(IConversionSvc *pDataLoader, IDataProviderSvc *dpsvc=nullptr) override
IDataManagerSvc: Pass a default data loader to the service.
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
auto compose(lambda_ts &&...lambdas)
StatusCode makePartitions()
Create all partitions according to job options.
StatusCode clearSubTree(OBJECT *pObject) override
Remove all data objects below the sub tree identified.
Opaque address interface definition.
StatusCode reinitialize() override
Service initialisation.
StatusCode objectParent(const IRegistry *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode finalize() override
Service initialisation.
StatusCode traverseSubTree(boost::string_ref path, AGENT *pAgent) override
Analyze by traversing all data objects below the sub tree.
StatusCode preLoad() override
load all preload items of the list
std::map< std::string, Partition > Partitions
A DataObject is the base class of any identifiable object on any data store.
StatusCode unlinkObject(OBJECT *from, boost::string_ref objPath) override
Remove a link to another object.
StatusCode retrieveObject(IRegistry *parent, boost::string_ref path, OBJECT *&pObj) override
Retrieve object from data store.
StatusCode unregisterObject(OBJECT *pObj, int item) override
Unregister object from the data store.
void toupper(std::string &s)
StatusCode unregisterAddress(IRegistry *pParent, boost::string_ref path) override
IDataManagerSvc: Unregister object address from the data store.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
StatusCode registerAddress(boost::string_ref path, ADDRESS *pAddr) override
IDataManagerSvc: Register object address with the data store.
StatusCode registerObject(OBJECT *parent, int obj, OBJECT *pObj) override
Register object with the data store.
StatusCode retrieveObject(boost::string_ref path, OBJECT *&pObj) override
Retrieve object identified by its full path from the data store.
~MultiStoreSvc() override
Standard Destructor.
virtual unsigned long addRef()=0
Add reference to object.
StatusCode findObject(OBJECT *parent, boost::string_ref path, OBJECT *&pObject) override
Find object in the data store.