Go to the documentation of this file.
26 #include <ThreadLocalStorage.h>
27 #include <boost/callable_traits.hpp>
29 #include <tbb/concurrent_queue.h>
45 struct Partition final {
56 return dataProvider.get();
60 return dataManager.get();
66 template <
typename T,
typename Mutex = std::recursive_mutex,
typename ReadLock = std::scoped_lock<Mutex>,
67 typename WriteLock = ReadLock>
75 WriteLock
lock{ m_mtx };
79 decltype(
auto )
with_lock( F&& f )
const {
80 ReadLock
lock{ m_mtx };
85 template <
typename Fun>
87 return [f = std::forward<Fun>( f )](
auto& p ) -> decltype(
auto ) {
return p.with_lock( f ); };
90 template <
typename ContainerOfSynced,
typename Fun>
91 void for_( ContainerOfSynced&
c, Fun&& f ) {
102 template <
typename F>
103 using argument_t = std::tuple_element_t<0, boost::callable_traits::args_t<F>>;
106 template <
typename Fun>
109 return s_current->with_lock( [&]( Partition& p ) {
110 auto* svc = p.get<std::decay_t<detail::argument_t<Fun>>>();
135 "force creation of default leaves on registerObject" };
137 "enable incidents on data creation requests" };
151 using extends::extends;
159 p.dataManager->release();
160 p.dataProvider->release();
215 for_(
m_partitions, []( Partition& p ) { p.dataManager->clearStore().ignore(); } );
250 if ( pDataLoader ) pDataLoader->
addRef();
259 p.dataProvider->addPreLoadItem( item ).ignore( );
266 p.dataProvider->removePreLoadItem( item ).ignore( );
273 p.dataProvider->resetPreLoad().ignore( );
348 return m_partitions[partition].with_lock( []( Partition& p ) {
return p.dataManager->clearStore(); } );
360 warning() <<
"Too late to change the number of slots!" <<
endmsg;
380 size_t slot = std::string::npos;
382 assert( slot != std::string::npos );
384 m_partitions[slot].with_lock( [evtnumber]( Partition& p ) {
385 assert( p.eventNumber == -1 );
386 p.eventNumber = evtnumber;
395 auto prev =
m_partitions[partition].with_lock( []( Partition& p ) {
return std::exchange( p.eventNumber, -1 ); } );
404 with_lock( [eventnumber](
const Partition& p ) {
return p.eventNumber == eventnumber; } ) );
411 error() <<
"Failed to retrieve data loader "
417 error() <<
MSG::ERROR <<
"Failed to retrieve data loader "
423 error() <<
MSG::ERROR <<
"Failed to set data loader "
444 error() <<
"Unable to initialize base class" <<
endmsg;
448 error() <<
"Invalid number of slots (" <<
m_slots <<
")" <<
endmsg;
453 error() <<
"Cannot set number of slots" <<
endmsg;
458 for (
size_t i = 0; i <
m_slots; i++ ) {
471 error() <<
"Failed to instantiate DataSvc as store partition" <<
endmsg;
475 p.dataProvider = svc;
488 error() <<
"Unable to reinitialize base class" <<
endmsg;
494 error() <<
"Failed to attach necessary services." <<
endmsg;
StatusCode linkObject(std::string_view fullPath, DataObject *to) override
Add a link to another object.
StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *to) override
Add a link to another object.
StatusCode traverseTree(IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
Gaudi::Property< std::string > m_rootName
virtual StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent)=0
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode reinitialize() override
Service initialisation.
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
~HiveWhiteBoard() override
Standard Destructor.
StatusCode initialize() override
StatusCode findObject(std::string_view path, DataObject *&pObj) override
Find object identified by its full path in the data store.
virtual StatusCode unregisterObject(std::string_view fullPath)=0
Unregister object from the data store.
StatusCode registerAddress(std::string_view path, IOpaqueAddress *pAddr) override
IDataManagerSvc: Register object address with the data store.
Gaudi::Property< std::string > m_loader
size_t allocateStore(int evtnumber) override
Allocate a store partition for a given event number.
virtual StatusCode unlinkObject(IRegistry *from, std::string_view objPath)=0
Remove a link to another object.
StatusCode unlinkObject(IRegistry *from, std::string_view objPath) override
Remove a link to another object.
StatusCode finalize() override
Service initialisation.
StatusCode updateObject(DataObject *pObj) override
Update object.
StatusCode setNumberOfStores(size_t slots) override
Set the number of event slots (copies of DataSvc objects).
SmartIF< IConversionSvc > m_dataLoader
Pointer to data loader service.
StatusCode unregisterAddress(IRegistry *pParent, std::string_view path) override
IDataManagerSvc: Unregister object address from the data store.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
StatusCode resetPreLoad() override
Clear the preload list.
StatusCode setProperty(const std::string &name, const Gaudi::Details::PropertyBase &p) override
set the property from another property with a different name
get
decorate the vector of properties
StatusCode clearSubTree(DataObject *pObject) 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 unregisterObject(DataObject *pObj) override
Unregister object from the data store.
StatusCode traverseSubTree(std::string_view path, IDataStoreAgent *pAgent) override
Analyze by traversing all data objects below the sub tree.
size_t getPartitionNumber(int eventnumber) const override
Get the partition number corresponding to a given event.
std::vector< Synced< Partition > > m_partitions
Datastore partitions.
StatusCode unregisterAddress(std::string_view path) override
IDataManagerSvc: Unregister object address from the data store.
StatusCode freeStore(size_t partition) override
Free a store partition.
StatusCode unregisterObject(std::string_view path) override
Unregister object from the data store.
StatusCode finalize() override
Gaudi::StateMachine::State FSMState() const override
StatusCode clearStore(size_t partition) override
Remove all data objects in one 'slot' of the data store.
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.
StatusCode registerObject(std::string_view fullPath, DataObject *pObject)
Register object with the data store.
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
StatusCode clearSubTree(std::string_view path) override
Remove all data objects below the sub tree identified.
size_t freeSlots() override
Get free slots number.
virtual StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *toObj)=0
Add a link to another object.
StatusCode objectLeaves(const IRegistry *pObject, std::vector< IRegistry * > &leaves) override
Explore the object store: retrieve all leaves attached to the object.
StatusCode detachServices()
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
StatusCode objectParent(const IRegistry *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
@ INVALID_ROOT
Invalid root path object cannot be retrieved or stored.
StatusCode selectStore(size_t partition) override
Activate a partition object. The identifies the partition uniquely.
AttribStringParser::Iterator begin(const AttribStringParser &parser)
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
const std::string & name() const override
Retrieve name of the service
StatusCode preLoad() override
load all preload items of the list
virtual StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress)=0
Register object address with the data store.
size_t getNumberOfStores() const override
Get the number of event slots (copies of DataSvc objects).
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
StatusCode unlinkObject(std::string_view path) override
Remove a link to another object.
virtual StatusCode unregisterAddress(std::string_view fullPath)=0
Unregister object address from the data store.
virtual StatusCode preLoad()=0
Load all preload items of the list.
Gaudi::Property< size_t > m_slots
virtual StatusCode traverseTree(IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects in the data store.
typename arg_helper< lambda >::type argument_t
unsigned int CLID
Class ID definition.
StatusCode registerAddress(IRegistry *parent, std::string_view path, IOpaqueAddress *pAdd) override
IDataManagerSvc: Register object address with the data store.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Base class used to extend a class implementing other interfaces.
Gaudi::Property< CLID > m_rootCLID
StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode unlinkObject(DataObject *from, std::string_view objPath) override
Remove a link to another object.
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
decltype(auto) for_(F &&f)
TTHREAD_TLS(Synced< Partition > *) s_current
StatusCode setRoot(std::string path, DataObject *pObj) override
Initialize data store for new event by giving new event path and root object.
StatusCode traverseSubTree(DataObject *pObject, IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects below the sub tree.
constexpr static const auto SUCCESS
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
Gaudi::Property< std::vector< std::string > > m_inhibitPathes
Gaudi::Property< bool > m_forceLeaves
StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &leaves) override
Explore the object store: retrieve all leaves attached to the object.
SmartIF< IAddressCreator > m_addrCreator
Reference to address creator.
#define DECLARE_COMPONENT(type)
StatusCode initialize() override
Service initialisation.
const std::string & rootName() const override
Name for root Event.
StatusCode reinitialize() override
StatusCode attachServices()
StatusCode setDataLoader(IConversionSvc *pDataLoader, IDataProviderSvc *=nullptr) override
IDataManagerSvc: Pass a default data loader to the service.
StatusCode setRoot(std::string path, IOpaqueAddress *pAddr) override
Initialize data store for new event by giving new event path and address of root object.
StatusCode initialize() override
Service initialization.
virtual StatusCode clearSubTree(std::string_view sub_path)=0
Remove all data objects below the sub tree identified by its full path name.
static GAUDI_API void setNumConcEvents(const std::size_t &nE)
constexpr static const auto FAILURE
tbb::concurrent_queue< size_t > m_freeSlots
fifo queue of free slots
StatusCode findObject(IRegistry *parent, std::string_view path, DataObject *&pObj) override
Find object identified by its full path in the data store.
StatusCode retrieveObject(IRegistry *parent, std::string_view path, DataObject *&pObj) override
Retrieve object from data store.
bool exists(const DataObjID &id) override
check if a data object exists in the current store
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.
Gaudi::Property< int > m_outputLevel
flag indicating whether ToolHandle tools have been added to m_tools
Gaudi::Property< bool > m_enableFaultHdlr
StatusCode registerObject(DataObject *parent, std::string_view obj, DataObject *pObj) override
Register object with the data store.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
virtual StatusCode setRoot(std::string root_name, DataObject *pObject)=0
Initialize data store for new event by giving new event path.
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator
StatusCode registerObject(std::string_view parent, std::string_view obj, DataObject *pObj) override
Register object with the data store.
StatusCode unregisterObject(DataObject *pObj, std::string_view path) override
Unregister object from the data store.