18 #define DATASVC_MULTISTORESVC_CPP 36 #include "boost/variant.hpp" 49 struct Partition final {
59 return dataProvider.get();
63 return dataManager.get();
67 template <
typename lambda>
68 struct arg_helper :
public arg_helper<decltype( &lambda::operator() )> {};
69 template <
typename T,
typename Ret,
typename Arg>
70 struct arg_helper<Ret ( T::* )( Arg ) const> {
76 template <
typename lambda>
79 auto visit = [](
auto&& variant,
auto&&... lambdas ) -> decltype(
auto ) {
114 boost::variant<boost::blank, ADDRESS*, OBJECT*>
root;
122 template <
typename Fun>
124 auto* svc = m_current.get<std::decay_t<detail::argument_t<Fun>>>();
176 for (
auto& i : m_partitions ) { i.second.dataManager->clearStore().
ignore(); }
179 if ( p ) p->release();
181 []( boost::blank ) {} );
203 if ( p ) p->release();
205 []( boost::blank ) {} );
217 if ( p ) p->release();
219 []( boost::blank ) {} );
229 m_dataLoader = pDataLoader;
230 if ( m_dataLoader ) m_dataLoader->
setDataProvider( dpsvc ? dpsvc :
this );
231 for (
auto& i : m_partitions ) { i.second.dataManager->setDataLoader( m_dataLoader.
get() ).ignore(); }
313 return create( nam, typ, pPartition );
324 m_partitions.
emplace( nam, Partition{dataProv, dataMgr, nam} );
330 auto i = m_partitions.
find( nam );
332 if ( i->second.dataManager == m_current.dataManager ) { m_current = Partition(); }
333 i->second.dataManager->clearStore().ignore();
334 m_partitions.
erase( i );
343 [&]( Partitions::const_reference p ) {
return p.second.dataProvider == provider; } );
345 i->second.dataManager->clearStore().ignore();
346 m_partitions.
erase( i );
352 auto i = m_partitions.
find( nam );
353 if ( i != m_partitions.
end() ) {
354 m_current = i->second;
364 m_current = Partition();
367 [&]( Partitions::const_reference p ) {
return p.second.dataProvider == provider; } );
369 m_current = i->second;
375 auto i = m_partitions.
find( nam );
376 if ( i != m_partitions.
end() ) {
377 pPartition = i->second.dataProvider;
380 pPartition =
nullptr;
386 if ( m_current.dataProvider ) {
387 nam = m_current.name;
388 pPartition = m_current.dataProvider;
392 pPartition =
nullptr;
399 if ( !m_addrCreator ) {
400 error() <<
"Failed to retrieve data loader " 405 auto dataLoader = service<IConversionSvc>(
m_loader, true );
407 error() <<
"Failed to retrieve data loader " 408 <<
"\"" << m_loader <<
"\"" <<
endmsg;
412 if ( !sc.isSuccess() ) {
413 error() <<
"Failed to set data loader " 414 <<
"\"" << m_loader <<
"\"" <<
endmsg;
420 m_addrCreator.
reset();
421 m_dataLoader.
reset();
432 error() <<
"Failed to connect to all store partitions." <<
endmsg;
442 error() <<
"Enable to reinitialize base class" <<
endmsg;
448 error() <<
"Failed to attach necessary services." <<
endmsg;
453 error() <<
"Failed to connect to store partitions." <<
endmsg;
465 m_current = Partition();
473 using extends::extends;
486 for (
auto& i : m_partitions ) {
489 if ( !address ) return StatusCode::FAILURE;
490 ADDRESS* pAdd = nullptr;
491 ADDRESS* p = address;
493 m_addrCreator->createAddress( p->svcType(), p->clID(), p->par(), p->ipar(), pAdd );
494 return sc.isSuccess() ? i.second.dataManager->setRoot( m_root.path, pAdd ) : sc;
496 [&](
OBJECT*
object ) -> StatusCode {
497 if ( object && object->clID() == CLID_DataObject ) {
498 return i.second.dataManager->setRoot( m_root.path, new DataObject() );
503 if ( !sc.isSuccess() ) iret = sc;
511 m_partitions.clear();
521 for (
auto attrib : Parser(
std::move( part ) ) ) {
522 switch ( ::
toupper( attrib.tag[0] ) ) {
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.
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.
const std::string & name() const override
Retrieve name of the service.
StatusCode traverseTree(AGENT *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
struct MultiStoreSvc::tagROOT m_root
StatusCode finalize() override
Implementation of property with value of concrete type.
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
constexpr static const auto SUCCESS
virtual StatusCode preLoad()=0
Load all preload items of the list.
virtual StatusCode resetPreLoad()=0
Clear the preload list.
StatusCode linkObject(boost::string_ref fullPath, OBJECT *to) override
Add a link to another object.
Gaudi::Property< CLID > m_rootCLID
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 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.
virtual StatusCode traverseSubTree(boost::string_ref sub_tree_path, IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects below the sub tree identified by its full path name...
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.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
StatusCode setRoot(std::string path, OBJECT *pObj) override
Initialize data store for new event by giving new event path and root object.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
StatusCode registerAddress(IRegistry *parent, boost::string_ref path, ADDRESS *pAddr) override
IDataManagerSvc: Register object address with the 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.
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.
Gaudi::Property< std::string > m_loader
StatusCode clearPartitions()
Clear all partitions.
StatusCode unregisterObject(OBJECT *pObj) override
Unregister object from the data store.
Gaudi::Property< std::string > m_defaultPartition
The IRegistry represents the entry door to the environment any data object residing in a transient da...
StatusCode preparePartitions()
Prepare partition for usage.
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 traverseSubTree(OBJECT *pObject, AGENT *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects below the sub tree.
Partition m_current
Current partition.
Gaudi::Property< std::string > m_rootName
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.
StatusCode registerObject(boost::string_ref fullPath, DataObject *pObject)
Register object with 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.
Base class used to extend a class implementing other interfaces.
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.
auto overload(lambda_ts &&...lambdas)
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.
constexpr static const auto FAILURE
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 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.
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.
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.
Gaudi::Property< PartitionDefs > m_partitionDefs
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.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
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.
~MultiStoreSvc() override
Standard Destructor.
virtual unsigned long addRef()=0
Add reference to object.