28#define DATASVC_MULTISTORESVC_CPP
53typedef const std::string
CSTR;
59 struct Partition final {
69 return dataProvider.get();
73 return dataManager.get();
77 template <
typename lambda>
78 struct arg_helper :
public arg_helper<decltype( &lambda::operator() )> {};
79 template <
typename T,
typename Ret,
typename Arg>
80 struct arg_helper<Ret ( T::* )( Arg ) const> {
86 template <
typename lambda>
87 using argument_t =
typename arg_helper<lambda>::type;
89 auto visit = [](
auto&& variant,
auto&&... lambdas ) ->
decltype( auto ) {
90 return std::visit(
Gaudi::overload( std::forward<
decltype( lambdas )>( lambdas )... ),
91 std::forward<
decltype( variant )>( variant ) );
124 std::variant<std::monostate, ADDRESS*, OBJECT*>
root;
132 template <
typename Fun>
134 auto* svc =
m_current.get<std::decay_t<detail::argument_t<Fun>>>();
186 for (
auto& i :
m_partitions ) { i.second.dataManager->clearStore().ignore(); }
190 if ( p ) p->release();
192 []( std::monostate ) {} );
215 if ( p ) p->release();
217 []( std::monostate ) {} );
218 m_root.path = std::move( path );
230 if ( p ) p->release();
232 []( std::monostate ) {} );
233 m_root.path = std::move( path );
244 if (
auto sc =
m_dataLoader->setDataProvider( dpsvc ? dpsvc :
this ); !sc )
return sc;
246 if (
auto sc = i.second.dataManager->setDataLoader(
m_dataLoader.get() ); !sc )
return sc;
329 return create( nam, typ, pPartition );
340 m_partitions.emplace( nam, Partition{ dataProv, dataMgr, nam } );
349 i->second.dataManager->clearStore().ignore();
359 [&]( Partitions::const_reference p ) {
return p.second.dataProvider == provider; } );
361 i->second.dataManager->clearStore().ignore();
383 [&]( Partitions::const_reference p ) {
return p.second.dataProvider == provider; } );
393 pPartition = i->second.dataProvider;
396 pPartition =
nullptr;
408 pPartition =
nullptr;
416 error() <<
"Failed to retrieve data loader "
423 error() <<
"Failed to retrieve data loader "
428 if ( !sc.isSuccess() ) {
429 error() <<
"Failed to set data loader "
448 error() <<
"Failed to connect to all store partitions." <<
endmsg;
458 error() <<
"Enable to reinitialize base class" <<
endmsg;
463 error() <<
"Failed to detach necessary services." <<
endmsg;
468 error() <<
"Failed to attach necessary services." <<
endmsg;
473 error() <<
"Failed to connect to store partitions." <<
endmsg;
493 using extends::extends;
510 if ( !address ) return StatusCode::FAILURE;
511 ADDRESS* pAdd = nullptr;
512 ADDRESS* p = address;
513 auto sc = m_addrCreator->createAddress( p->svcType(), p->clID(), p->par(), p->ipar(), pAdd );
514 return sc.isSuccess() ? i.second.dataManager->setRoot( m_root.path, pAdd ) : sc;
517 if ( object && object->clID() == CLID_DataObject ) {
518 return i.second.dataManager->setRoot( m_root.path, new DataObject() );
523 if ( !sc.isSuccess() ) iret = sc;
538 std::string typ, nam;
541 for (
auto attrib : Parser( std::move( part ) ) ) {
544 nam = std::move( attrib.value );
547 typ = std::move( attrib.value );
unsigned int CLID
Class ID definition.
void toupper(std::string &s)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_COMPONENT(type)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
A DataObject is the base class of any identifiable object on any data store.
Description of the DataStoreItem class.
Implementation of property with value of concrete type.
Parse attribute strings allowing iteration over the various attributes.
Data provider interface definition.
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
virtual StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *toObj)=0
Add a link to another object.
virtual StatusCode unregisterObject(std::string_view fullPath)=0
Unregister object from the data store.
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
virtual StatusCode addPreLoadItem(const DataStoreItem &item)=0
Add an item to the preload list.
virtual StatusCode unlinkObject(IRegistry *from, std::string_view objPath)=0
Remove a link to another object.
virtual StatusCode removePreLoadItem(const DataStoreItem &item)=0
Remove an item from the preload list.
virtual StatusCode resetPreLoad()=0
Clear the preload list.
@ INVALID_ROOT
Invalid root path object cannot be retrieved or stored.
virtual StatusCode findObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Find object identified by its directory entry.
virtual StatusCode preLoad()=0
Load all preload items of the list.
StatusCode registerObject(std::string_view fullPath, DataObject *pObject)
Register object with the data store.
Generic data agent interface.
Definition of the basic interface.
@ NO_INTERFACE
Requested interface is not available.
Opaque address interface definition.
virtual unsigned long addRef()=0
Add reference to object.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
General service interface definition.
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
StatusCode drop(CSTR &nam) override
Drop a partition object. The name identifies the partition uniquely.
StatusCode traverseTree(AGENT *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
StatusCode objectLeaves(const OBJECT *pObject, std::vector< IRegistry * > &leaves) override
Explore the object store: retrieve all leaves attached to the object.
StatusCode get(CSTR &nam, IInterface *&pPartition) const override
Access a partition object. The name identifies the partition uniquely.
StatusCode attachServices()
const std::string & rootName() const override
Name for root Event.
StatusCode updateObject(OBJECT *pObj) override
Update object.
StatusCode registerObject(std::string_view parent, std::string_view obj, OBJECT *pObj) override
Register object with the data store.
Gaudi::Property< std::string > m_defaultPartition
StatusCode unlinkObject(IRegistry *from, std::string_view objPath) override
Remove a link to another object.
SmartIF< IAddressCreator > m_addrCreator
Reference to address creator.
StatusCode drop(IInterface *pPartition) override
Drop a partition object. The name identifies the partition uniquely.
Gaudi::Property< PartitionDefs > m_partitionDefs
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 unregisterAddress(IRegistry *pParent, std::string_view path) override
IDataManagerSvc: Unregister object address from the data store.
StatusCode activePartition(std::string &nam, IInterface *&pPartition) const override
Access the active partition object.
StatusCode registerObject(OBJECT *parent, std::string_view obj, OBJECT *pObj) override
Register object with the data store.
StatusCode makePartitions()
Create all partitions according to job options.
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
StatusCode unregisterObject(OBJECT *pObj, std::string_view path) override
Unregister object from the data store.
struct MultiStoreSvc::tagROOT m_root
StatusCode findObject(std::string_view path, OBJECT *&pObj) override
Find object identified by its full path in the data store.
Gaudi::Property< std::string > m_loader
Partition m_current
Current partition.
StatusCode retrieveObject(IRegistry *parent, std::string_view path, OBJECT *&pObj) override
Retrieve object from data store.
StatusCode objectParent(const IRegistry *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode preLoad() override
load all preload items of the list
StatusCode unlinkObject(std::string_view path) override
Remove a link to another object.
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
StatusCode traverseSubTree(OBJECT *pObject, AGENT *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects below the sub tree.
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
StatusCode finalize() override
Service initialisation.
StatusCode setRoot(std::string path, ADDRESS *pAddr) override
Initialize data store for new event by giving new event path and address of root object.
StatusCode objectLeaves(const IRegistry *pObject, std::vector< IRegistry * > &leaves) override
Explore the object store: retrieve all leaves attached to the object.
StatusCode clearSubTree(OBJECT *pObject) override
Remove all data objects below the sub tree identified.
StatusCode objectParent(const OBJECT *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode traverseSubTree(std::string_view path, AGENT *pAgent) override
Analyze by traversing all data objects below the sub tree.
StatusCode registerAddress(std::string_view path, ADDRESS *pAddr) override
IDataManagerSvc: Register object address with the data store.
StatusCode reinitialize() override
Service initialisation.
StatusCode findObject(IRegistry *parent, std::string_view path, OBJECT *&pObj) override
Find object identified by its full path in the data store.
~MultiStoreSvc() override
Standard Destructor.
StatusCode initialize() override
Service initialisation.
StatusCode unregisterObject(OBJECT *pObj) override
Unregister object from the data store.
StatusCode registerAddress(IRegistry *parent, std::string_view path, ADDRESS *pAddr) override
IDataManagerSvc: Register object address with the data store.
StatusCode detachServices()
SmartIF< IConversionSvc > m_dataLoader
Pointer to data loader service.
StatusCode setDataLoader(IConversionSvc *pDataLoader, IDataProviderSvc *dpsvc=nullptr) override
IDataManagerSvc: Pass a default data loader to the service.
StatusCode resetPreLoad() override
Clear the preload list.
StatusCode unregisterObject(std::string_view path) override
Unregister object from the data store.
StatusCode setRoot(std::string path, OBJECT *pObj) override
Initialize data store for new event by giving new event path and root object.
StatusCode clearPartitions()
Clear all partitions.
StatusCode unlinkObject(OBJECT *from, std::string_view objPath) override
Remove a link to another object.
StatusCode unregisterAddress(std::string_view path) override
IDataManagerSvc: Unregister object address from the data store.
StatusCode linkObject(IRegistry *from, std::string_view objPath, OBJECT *to) override
Add a link to another object.
StatusCode preparePartitions()
Prepare partition for usage.
Partitions m_partitions
Datastore partitions.
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
StatusCode activate(CSTR &nam) override
Activate a partition object. The name identifies the partition uniquely.
StatusCode linkObject(std::string_view fullPath, OBJECT *to) override
Add a link to another object.
Gaudi::Property< CLID > m_rootCLID
StatusCode activate(IInterface *pPartition) override
Activate a partition object.
std::map< std::string, Partition > Partitions
Gaudi::Property< std::string > m_rootName
StatusCode clearSubTree(std::string_view path) override
Remove all data objects below the sub tree identified.
StatusCode create(CSTR &nam, CSTR &typ, IInterface *&pPartition) override
Create a partition object. The name identifies the partition uniquely.
std::vector< std::string > PartitionDefs
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
StatusCode finalize() override
StatusCode reinitialize() override
SmartIF< IFace > service(const std::string &name, bool createIf=true) const
StatusCode initialize() override
Small smart pointer class with automatic reference counting for IInterface.
This class is used for returning status codes from appropriate routines.
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
Base class used to extend a class implementing other interfaces.
auto overload(lambda_ts &&... lambdas)
virtual StatusCode clearSubTree(std::string_view sub_path)=0
Remove all data objects below the sub tree identified by its full path name.
virtual StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent)=0
IDataManagerSvc: Explore the object store: retrieve the object's parent.
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 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 registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress)=0
Register object address with the data store.
virtual StatusCode unregisterAddress(std::string_view fullPath)=0
Unregister object address from the data store.
virtual StatusCode traverseTree(IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects in the data store.
Root type (address or object)
std::variant< std::monostate, ADDRESS *, OBJECT * > root