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(); }
180 if ( p ) p->release();
182 []( boost::blank ) {} );
205 if ( p ) p->release();
207 []( boost::blank ) {} );
220 if ( p ) p->release();
222 []( boost::blank ) {} );
232 m_dataLoader = pDataLoader;
233 if ( m_dataLoader ) m_dataLoader->
setDataProvider( dpsvc ? dpsvc :
this );
234 for (
auto& i : m_partitions ) { i.second.dataManager->setDataLoader( m_dataLoader.
get() ).ignore(); }
316 return create( nam, typ, pPartition );
327 m_partitions.
emplace( nam, Partition{dataProv, dataMgr, nam} );
333 auto i = m_partitions.
find( nam );
335 if ( i->second.dataManager == m_current.dataManager ) { m_current = Partition(); }
336 i->second.dataManager->clearStore().ignore();
337 m_partitions.
erase( i );
346 [&]( Partitions::const_reference p ) {
return p.second.dataProvider == provider; } );
348 i->second.dataManager->clearStore().ignore();
349 m_partitions.
erase( i );
355 auto i = m_partitions.
find( nam );
356 if ( i != m_partitions.
end() ) {
357 m_current = i->second;
367 m_current = Partition();
370 [&]( Partitions::const_reference p ) {
return p.second.dataProvider == provider; } );
372 m_current = i->second;
378 auto i = m_partitions.
find( nam );
379 if ( i != m_partitions.
end() ) {
380 pPartition = i->second.dataProvider;
383 pPartition =
nullptr;
389 if ( m_current.dataProvider ) {
390 nam = m_current.name;
391 pPartition = m_current.dataProvider;
395 pPartition =
nullptr;
402 if ( !m_addrCreator ) {
403 error() <<
"Failed to retrieve data loader " 408 auto dataLoader = service<IConversionSvc>(
m_loader,
true );
410 error() <<
"Failed to retrieve data loader " 411 <<
"\"" << m_loader <<
"\"" <<
endmsg;
415 if ( !sc.isSuccess() ) {
416 error() <<
"Failed to set data loader " 417 <<
"\"" << m_loader <<
"\"" <<
endmsg;
423 m_addrCreator.
reset();
424 m_dataLoader.
reset();
435 error() <<
"Failed to connect to all store partitions." <<
endmsg;
445 error() <<
"Enable to reinitialize base class" <<
endmsg;
451 error() <<
"Failed to attach necessary services." <<
endmsg;
456 error() <<
"Failed to connect to store partitions." <<
endmsg;
468 m_current = Partition();
476 using extends::extends;
489 for (
auto& i : m_partitions ) {
493 if ( !address ) return StatusCode::FAILURE;
494 ADDRESS* pAdd = nullptr;
495 ADDRESS* p = address;
496 auto sc = m_addrCreator->createAddress( p->svcType(), p->clID(), p->par(), p->ipar(), pAdd );
497 return sc.isSuccess() ? i.second.dataManager->setRoot( m_root.path, pAdd ) : sc;
499 [&](
OBJECT*
object ) -> StatusCode {
500 if ( object && object->clID() == CLID_DataObject ) {
501 return i.second.dataManager->setRoot( m_root.path, new DataObject() );
506 if ( !sc.isSuccess() ) iret = sc;
514 m_partitions.clear();
524 for (
auto attrib : Parser(
std::move( part ) ) ) {
525 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 registerAddress(std::string_view path, ADDRESS *pAddr) override
IDataManagerSvc: Register object address with the data store.
class MergingTransformer< Out(const vector_of_const_< In > true
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 initialize() override
StatusCode clearSubTree(std::string_view 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.
Partitions m_partitions
Datastore partitions.
const std::string & name() const override
Retrieve name of the service.
StatusCode unlinkObject(std::string_view path) override
Remove a link to another object.
StatusCode traverseTree(AGENT *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
virtual StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress)=0
Register object address with the data store.
virtual StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *toObj)=0
Add a link to another object.
struct MultiStoreSvc::tagROOT m_root
StatusCode finalize() override
Implementation of property with value of concrete type.
virtual StatusCode traverseSubTree(std::string_view sub_tree_path, IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects below the sub tree identified by its full path name...
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 objectLeaves(const OBJECT *pObject, std::vector< IRegistry * > &leaves) override
Explore the object store: retrieve all leaves attached to the object.
StatusCode unregisterObject(std::string_view path) override
Unregister object from the data store.
Root type (address or object)
virtual StatusCode unregisterAddress(std::string_view fullPath)=0
Unregister object address from the data store.
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.
StatusCode registerAddress(IRegistry *parent, std::string_view path, ADDRESS *pAddr) override
IDataManagerSvc: Register object address with the data store.
StatusCode unlinkObject(OBJECT *from, std::string_view objPath) override
Remove a link to another object.
virtual StatusCode resetPreLoad()=0
Clear the preload list.
StatusCode linkObject(std::string_view fullPath, OBJECT *to) override
Add a link to another object.
Gaudi::Property< CLID > m_rootCLID
StatusCode unlinkObject(IRegistry *from, std::string_view objPath) override
Remove a link to another object.
Data provider interface definition.
Description of the DataStoreItem class.
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.
virtual StatusCode findObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Find object identified by its directory entry.
virtual StatusCode unlinkObject(IRegistry *from, std::string_view objPath)=0
Remove a link to another object.
StatusCode registerObject(std::string_view parent, std::string_view obj, OBJECT *pObj) override
Register object with the data store.
Invalid root path object cannot be retrieved or stored.
StatusCode attachServices()
#define DECLARE_COMPONENT(type)
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.
virtual StatusCode unregisterObject(std::string_view fullPath)=0
Unregister object from the data store.
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)
virtual StatusCode clearSubTree(std::string_view sub_path)=0
Remove all data objects below the sub tree identified by its full path name.
StatusCode unregisterAddress(std::string_view path) override
IDataManagerSvc: Unregister object address from the data store.
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
General service interface definition.
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 findObject(IRegistry *parent, std::string_view path, OBJECT *&pObj) override
Find object identified by its full path in the data store.
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
StatusCode findObject(std::string_view path, OBJECT *&pObj) override
Find object identified by its full path 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 reinitialize() override
unsigned int CLID
Class ID definition.
StatusCode registerObject(OBJECT *parent, std::string_view obj, OBJECT *pObj) override
Register object with the data store.
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.
StatusCode traverseSubTree(std::string_view path, AGENT *pAgent) override
Analyze by traversing all data objects below the sub tree.
StatusCode create(CSTR &nam, CSTR &typ, IInterface *&pPartition) override
Create a partition object. The name identifies the partition uniquely.
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
Generic data agent interface.
StatusCode resetPreLoad() override
Clear the preload list.
StatusCode registerObject(std::string_view fullPath, DataObject *pObject)
Register object with the data store.
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 updateObject(OBJECT *pObj) override
Update object.
SmartIF< IAddressCreator > m_addrCreator
Reference to address creator.
auto overload(lambda_ts &&...lambdas)
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 unregisterAddress(IRegistry *pParent, std::string_view path) override
IDataManagerSvc: Unregister object address from the data store.
StatusCode activate(IInterface *pPartition) override
Activate a partition object.
constexpr static const auto FAILURE
StatusCode initialize() override
Service initialisation.
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.
StatusCode unregisterObject(OBJECT *pObj, std::string_view path) override
Unregister object from the data store.
StatusCode retrieveObject(IRegistry *parent, std::string_view path, OBJECT *&pObj) override
Retrieve object from data store.
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 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.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
void toupper(std::string &s)
StatusCode linkObject(IRegistry *from, std::string_view objPath, OBJECT *to) override
Add a link to another object.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
~MultiStoreSvc() override
Standard Destructor.
virtual unsigned long addRef()=0
Add reference to object.