Go to the documentation of this file.
30 #define TSDATASVC_DATASVC_CPP
54 #define STD_LOCK_GUARD_MACRO std::scoped_lock lock{ m_accessMutex };
59 s.append(
sr.data(),
sr.size() );
63 std::string_view::size_type find( std::string_view
s,
char c,
size_t o ) {
64 if ( !
s.empty() )
s.remove_prefix( o );
66 return r == std::string_view::npos ? r : ( r + o );
75 #define CAST_REGENTRY( x, y ) dynamic_cast<x>( y )
79 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
80 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
82 #define DEBMSG ON_DEBUG debug()
83 #define VERMSG ON_VERBOSE verbose()
93 if ( !node_entry )
return Status::INVALID_OBJECT;
95 if ( !parent )
return Status::INVALID_PARENT;
96 parent->
remove( node_entry );
104 if ( !
checkRoot() )
return Status::INVALID_ROOT;
106 if ( !entry )
return Status::INVALID_OBJECT;
108 if ( !parent )
return Status::INVALID_PARENT;
115 if ( !
checkRoot() )
return Status::INVALID_ROOT;
132 if ( !
checkRoot() )
return Status::INVALID_ROOT;
134 if ( !entry )
return Status::INVALID_OBJECT;
141 if ( !
checkRoot() )
return Status::INVALID_ROOT;
195 if ( pDataLoader ) pDataLoader->
addRef();
204 if ( !pObject )
return Status::INVALID_OBJECT;
210 if ( !
checkRoot() )
return Status::INVALID_ROOT;
212 if ( !node_entry )
return Status::INVALID_OBJECT;
213 refpParent = node_entry->
parent();
219 if ( !pObject )
return Status::INVALID_OBJECT;
227 if ( !pRegistry )
return Status::INVALID_OBJECT;
229 if ( !node_entry )
return Status::INVALID_OBJECT;
238 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
244 if ( !
checkRoot() )
return Status::INVALID_ROOT;
245 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
248 auto sep = find( objPath,
SEPARATOR, 1 );
249 if ( sep == std::string_view::npos || objPath.substr( 0, sep ) !=
m_rootName.
value() ) {
250 return Status::INVALID_PARENT;
256 if ( !par_entry )
return Status::INVALID_PARENT;
258 if ( sep > 0 && sep != std::string_view::npos ) {
259 auto p_path = objPath.substr( 0, sep );
260 auto o_path = objPath.substr( sep );
268 p_entry = par_entry->
findLeaf( p_path );
270 if ( !p_entry )
return Status::INVALID_PARENT;
274 return status.
isSuccess() ? status : Status::DOUBL_OBJ_PATH;
279 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
285 if ( !
checkRoot() )
return Status::INVALID_ROOT;
287 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
290 auto sep = find( objPath,
SEPARATOR, 1 );
291 if ( sep == std::string_view::npos || objPath.substr( 0, sep ) !=
m_rootName.
value() ) {
292 return Status::INVALID_PARENT;
302 if ( sep > 0 && sep != std::string_view::npos ) {
309 return Status::INVALID_PARENT;
326 if ( !
checkRoot() )
return Status::INVALID_ROOT;
328 if ( !objPath.empty() ) {
330 auto sep = find( objPath,
SEPARATOR, 1 );
331 if ( sep != std::string_view::npos ) {
332 return registerObject( objPath.substr( 0, sep ), objPath.substr( sep ), pObject );
335 return Status::INVALID_OBJ_PATH;
340 auto sep = find( objPath,
SEPARATOR, 1 );
341 if ( sep != std::string_view::npos ) {
342 auto p_path = objPath.substr( 0, sep );
343 auto o_path = objPath.substr( sep );
351 par_entry = node_entry->
findLeaf( p_path );
352 }
else if ( par_entry && !par_entry->
object() ) {
358 par_entry = node_entry->
findLeaf( p_path );
361 node_entry = par_entry;
374 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
383 status = Status::DOUBL_OBJ_PATH;
389 return Status::INVALID_PARENT;
398 if ( !pEntry )
return Status::INVALID_ROOT;
399 if ( !pEntry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
401 if ( !pParent )
return Status::INVALID_PARENT;
402 if ( pObject ) pObject->
addRef();
403 pParent->
remove( pEntry );
409 if ( !
checkRoot() )
return Status::INVALID_ROOT;
411 if ( !entry )
return Status::INVALID_OBJECT;
413 if ( !parent )
return Status::INVALID_PARENT;
414 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
416 if ( parent ) parent->
remove( entry );
422 if ( !
checkRoot() )
return Status::INVALID_ROOT;
427 if ( !entry )
return Status::INVALID_OBJECT;
428 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
434 return Status::INVALID_PARENT;
442 if ( pReg &&
path.empty() ) {
461 if ( pLeaf )
return pLeaf->
object();
485 return Status::NO_DATA_LOADER;
491 return Status::INVALID_OBJ_ADDR;
508 return Status::INVALID_OBJ_ADDR;
511 status = pLoader->
createObj( pAddress, pObject );
520 status = pLoader->
fillObjRefs( pAddress, pObject );
555 if ( sep == std::string_view::npos )
return Status::INVALID_OBJ_PATH;
559 if ( !status.
isSuccess() )
return status;
563 if ( sep != std::string_view::npos ) {
564 auto p_path =
path.substr( 0, sep );
565 auto o_path =
path.substr( sep );
566 if ( !parentObj->
object() ) {
568 if ( !status.
isSuccess() )
return status;
575 root_entry = parentObj->
findLeaf( p_path );
582 if ( !status.
isSuccess() )
return status;
587 return Status::INVALID_OBJ_PATH;
588 }
else if (
path.empty() ) {
591 if ( !parentObj->
object() ) {
593 if ( !status.
isSuccess() )
return status;
605 status = Status::INVALID_OBJ_PATH;
606 }
else if ( !pEntry->
object() ) {
640 if ( !pReg )
return Status::INVALID_OBJ_PATH;
643 return pObject ? Status::IDataProviderSvc_NO_ERROR : Status::OBJ_NOT_LOADED;
650 if ( !
checkRoot() )
return Status::INVALID_ROOT;
653 return !pObject ? Status::OBJ_NOT_LOADED : Status::IDataProviderSvc_NO_ERROR;
660 if ( !pRegistry )
return Status::INVALID_OBJ_ADDR;
668 if ( !toUpdate )
return Status::INVALID_OBJECT;
670 if ( !pRegistry )
return Status::INVALID_OBJECT;
672 if ( !pAddress )
return Status::INVALID_OBJ_ADDR;
675 if ( !pLoader )
return Status::NO_DATA_LOADER;
682 status = pLoader->updateObj( pAddress, toUpdate );
683 if ( status.
isSuccess() ) { status = pLoader->updateObjRefs( pAddress, toUpdate ); }
687 throw GaudiException(
"std::exception in updateObject() " + pRegistry->
name() +
": " +
699 if ( !
checkRoot() )
return Status::INVALID_ROOT;
705 if ( !to_entry )
return Status::INVALID_OBJECT;
707 if ( sep > 0 && sep != std::string_view::npos ) {
714 return status.
isSuccess() ? Status::IDataProviderSvc_NO_ERROR : Status::DOUBL_OBJ_PATH;
717 return Status::INVALID_PARENT;
722 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
725 return linkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ), to );
734 if ( !
checkRoot() )
return Status::INVALID_ROOT;
739 if ( sep > 0 && sep != std::string_view::npos ) {
745 return status.
isSuccess() ? status : Status::INVALID_OBJ_PATH;
748 return Status::INVALID_PARENT;
753 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
756 return unlinkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ) );
761 if ( !
checkRoot() )
return Status::INVALID_ROOT;
788 if ( pObject && depth++ < load_depth ) {
791 for (
const auto& i : *dir ) {
806 int load_depth = i.depth();
818 if ( !sc.
isSuccess() ) { error() <<
"Failed to access incident service." <<
endmsg; }
836 error() <<
"Unable to reinitialize base class" <<
endmsg;
842 error() <<
"Failed to access incident service." <<
endmsg;
virtual StatusCode loadObject(IRegistry *pNode)
Invoke Persistency service to create transient object from its persistent representation.
std::vector< DataStoreItem > m_preLoads
Items to be pre-loaded.
Gaudi::Property< std::vector< std::string > > m_inhibitPathes
#define CAST_REGENTRY(x, y)
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
std::unique_ptr< DataSvcHelpers::RegistryEntry > m_root
Pointer to root entry.
void setRegistry(IRegistry *pRegistry)
Set pointer to Registry.
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
StatusCode initialize() override
void setAddress(IOpaqueAddress *pAddress) override
Set/Update Opaque address.
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
StatusCode setDataLoader(IConversionSvc *svc, IDataProviderSvc *dpsvc=nullptr) override
IDataManagerSvc: IDataManagerSvc: Pass a default data loader to the service and optionally a data pro...
RegistryEntry * findLeaf(std::string_view path) const
Find identified leaf in this registry node.
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
bool isSoft() const
Is the link soft or hard.
StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *to) override
Add a link to another object.
StatusCode preLoad() override
load all preload items of the list
virtual unsigned long release()
release reference to object
virtual IConversionSvc * getDataLoader(IRegistry *pReg)
Retrieve customizable data loader according to registry entry to be retrieved.
bool checkRoot()
Check if root path is valid.
#define STD_LOCK_GUARD_MACRO
StatusCode finalize() override
Service initialization.
Gaudi::Property< bool > m_enableFaultHdlr
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
void makeHard(DataObject *pObject)
Initialize link as hard link.
virtual StatusCode i_setRoot(std::string root_name, DataObject *pRootObj)
Initialize data store for new event by giving new event path and root object.
DataObject * handleDataFault(IRegistry *pReg, std::string_view path={})
Invoke data fault handling if enabled.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
StatusCode registerObject(std::string_view parentPath, std::string_view objPath, DataObject *pObject) override
Register object with the data store.
StatusCode initialize() override
Service initialization.
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
StatusCode finalize() override
Gaudi::Property< bool > m_forceLeaves
StatusCode setRoot(std::string root_name, DataObject *pRootObj) override
Initialize data store for new event by giving new event path and root object.
virtual DataObject * createDefaultObject() const
Create default objects in case forced creation of leaves is requested.
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
IOpaqueAddress * address() const override
Retrieve opaque storage address.
virtual const name_type & name() const =0
Name of the directory (or key)
Gaudi::Property< std::string > m_rootName
const Store & leaves() const
Access the leaves of the object.
DataObject * object() const override
Retrive object behind the link.
StatusCode reinitialize() override
Service initialization.
const std::string & name() const override
Retrieve name of the service
StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode remove(std::string_view name)
Remove an entry from the store.
void setObject(DataObject *obj)
Set/Update object address.
const ValueType & value() const
StatusCode traverseSubTree(std::string_view sub_tree_path, IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects below the sub tree identified by its full pat...
DataSvcHelpers::RegistryEntry RegEntry
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
bool isEmpty() const
Simple check if the Container is empty.
unsigned int CLID
Class ID definition.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Gaudi::Property< std::string > m_faultName
IRegistry * parent() const
Pointer to parent directory entry.
void setDataSvc(IDataProviderSvc *s)
Set the transient data store.
StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress) override
IDataManagerSvc: Register object address with the data store.
StatusCode retrieveEntry(DataSvcHelpers::RegistryEntry *pNode, std::string_view path, DataSvcHelpers::RegistryEntry *&pEntry)
Retrieve registry entry from store.
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
StatusCode traverseTree(IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
const std::string & rootName() const override
IDataManagerSvc: Accessor for root event name.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
StatusCode unregisterAddress(std::string_view fullPath) override
IDataManagerSvc: Unregister object address from the data store.
StatusCode resetPreLoad() override
Clear the preload list.
constexpr static const auto SUCCESS
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Gaudi::Property< std::string > m_accessName
IConversionSvc * m_dataLoader
Pointer to data loader service.
StatusCode unlinkObject(IRegistry *from, std::string_view objPath) override
Remove a link to another object.
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
virtual DataObject * object() const =0
Retrieve object behind the link.
StatusCode add(std::string name, DataObject *pObject, bool is_soft=false)
Add entry to data store.
virtual const id_type & identifier() const =0
Full identifier (or key)
StatusCode reinitialize() override
IIncidentSvc * m_incidentSvc
Pointer to incident service.
StatusCode unregisterObject(std::string_view fullPath) override
Unregister object from the data store.
const std::string & identifier() const override
Full identifier (or key)
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves) override
IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object.
constexpr static const auto FAILURE
virtual unsigned long release()=0
Release Interface instance.
StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject) override
Retrieve object from data store.
StatusCode traverseTree(IDataStoreAgent *pAgent, int level=0)
traverse data tree
decltype(auto) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
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.
IRegistry * registry() const
Get pointer to Registry.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
virtual unsigned long addRef()
Add reference to object.
Gaudi::Property< CLID > m_rootCLID
Gaudi::Property< bool > m_enableAccessHdlr
StatusCode clearSubTree(std::string_view sub_tree_path) override
IDataManagerSvc: Remove all data objects below the sub tree identified by its full path name.
RegistryEntry * parentEntry()
Pointer to parent registry entry.