Go to the documentation of this file.
29 #define DATASVC_DATASVC_CPP
54 s.append(
sr.data(),
sr.size() );
58 std::string_view::size_type find( std::string_view
s,
char c,
size_t o ) {
59 if ( !
s.empty() )
s.remove_prefix( o );
61 return r == std::string_view::npos ? r : ( r + o );
72 #define CAST_REGENTRY( x, y ) dynamic_cast<x>( y )
76 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
77 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
79 #define DEBMSG ON_DEBUG debug()
80 #define VERMSG ON_VERBOSE verbose()
90 if ( !node_entry )
return Status::INVALID_OBJECT;
92 if ( !parent )
return Status::INVALID_PARENT;
93 parent->
remove( node_entry );
101 if ( !
checkRoot() )
return Status::INVALID_ROOT;
103 if ( !entry )
return Status::INVALID_OBJECT;
105 if ( !parent )
return Status::INVALID_PARENT;
128 return entry ? entry->
traverseTree( pAgent ) : Status::INVALID_OBJECT;
133 if ( !
checkRoot() )
return Status::INVALID_ROOT;
194 if ( !pObject )
return Status::INVALID_OBJECT;
199 if ( !
checkRoot() )
return Status::INVALID_ROOT;
201 if ( !node_entry )
return Status::INVALID_OBJECT;
202 refpParent = node_entry->
parent();
208 if ( !pObject )
return Status::INVALID_OBJECT;
216 if ( !
checkRoot() )
return Status::INVALID_ROOT;
218 if ( !node_entry )
return Status::INVALID_OBJECT;
219 leaves = node_entry->
leaves();
225 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
231 if ( !
checkRoot() )
return Status::INVALID_ROOT;
232 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
236 auto sep = find( objPath,
SEPARATOR, 1 );
237 if ( sep == std::string_view::npos || objPath.substr( 0, sep ) !=
m_rootName.
value() ) {
238 return Status::INVALID_PARENT;
244 if ( !par_entry )
return Status::INVALID_PARENT;
247 if ( sep > 0 && sep != std::string_view::npos ) {
248 auto p_path = objPath.substr( 0, sep );
249 auto o_path = objPath.substr( sep );
257 p_entry = par_entry->
findLeaf( p_path );
259 if ( !p_entry )
return Status::INVALID_PARENT;
262 StatusCode status = par_entry->
add( to_string( objPath ), pAddress );
263 return status.
isSuccess() ? status : Status::DOUBL_OBJ_PATH;
268 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
274 if ( !
checkRoot() )
return Status::INVALID_ROOT;
275 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
279 auto sep = find( objPath,
SEPARATOR, 1 );
280 if ( sep != std::string_view::npos && objPath.substr( 0, sep ) ==
m_rootName.
value() ) {
283 return Status::INVALID_PARENT;
291 if ( sep > 0 && sep != std::string_view::npos ) {
298 return Status::INVALID_PARENT;
315 if ( !
checkRoot() )
return Status::INVALID_ROOT;
318 if ( !objPath.empty() ) {
320 auto sep = find( objPath,
SEPARATOR, 1 );
321 if ( sep != std::string_view::npos ) {
322 return registerObject( objPath.substr( 0, sep ), objPath.substr( sep ), pObject );
325 return Status::INVALID_OBJ_PATH;
330 auto sep = find( objPath,
SEPARATOR, 1 );
331 if ( sep != std::string_view::npos ) {
332 auto p_path = objPath.substr( 0, sep );
333 auto o_path = objPath.substr( sep );
341 par_entry = node_entry->
findLeaf( p_path );
342 }
else if ( par_entry && !par_entry->
object() ) {
348 par_entry = node_entry->
findLeaf( p_path );
351 node_entry = par_entry;
359 status = node_entry->
add( to_string( objPath ), pObject );
364 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
372 status = Status::DOUBL_OBJ_PATH;
378 return Status::INVALID_PARENT;
387 if ( !pEntry )
return Status::INVALID_ROOT;
388 if ( !pEntry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
390 if ( !pParent )
return Status::INVALID_PARENT;
392 pParent->
remove( pEntry );
398 if ( !
checkRoot() )
return Status::INVALID_ROOT;
400 if ( !entry )
return Status::INVALID_OBJECT;
402 if ( !parent )
return Status::INVALID_PARENT;
403 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
405 if ( parent ) parent->
remove( entry );
422 return Status::DIR_NOT_EMPTY;
424 return Status::INVALID_OBJECT;
427 return Status::INVALID_PARENT;
429 return Status::INVALID_ROOT;
441 if ( pReg &&
path.empty() ) {
461 if ( pLeaf ) {
return pLeaf->
object(); }
500 return Status::INVALID_OBJ_ADDR;
503 status = pLoader->
createObj( pAddress, pObject );
512 status = pLoader->
fillObjRefs( pAddress, pObject );
543 if ( !
checkRoot() )
return Status::INVALID_ROOT;
545 static constexpr
auto empty = std::string_view{};
555 }
else if ( sep != std::string_view::npos ) {
559 if ( !status.isSuccess() )
return status;
564 return Status::INVALID_OBJ_PATH;
570 if ( sep != std::string_view::npos ) {
571 if ( !parentObj->
object() ) {
573 if ( !status.isSuccess() )
return status;
575 auto p_path =
path.substr( 0, sep );
581 root_entry = parentObj->
findLeaf( p_path );
588 if ( !status.isSuccess() )
return status;
593 return Status::INVALID_OBJ_PATH;
594 }
else if (
path.empty() ) {
597 if ( !parentObj->
object() ) {
599 if ( !status.isSuccess() )
return status;
611 if ( !pEntry )
return Status::INVALID_OBJ_PATH;
642 if ( !pReg )
return Status::INVALID_OBJ_PATH;
645 return ( !pObject ) ? Status::OBJ_NOT_LOADED : Status::IDataProviderSvc_NO_ERROR;
651 if ( !
checkRoot() )
return Status::INVALID_ROOT;
654 return !pObject ? Status::OBJ_NOT_LOADED : Status::IDataProviderSvc_NO_ERROR;
662 return Status::INVALID_OBJ_ADDR;
675 return Status::INVALID_OBJECT;
679 return Status::INVALID_OBJECT;
683 return Status::INVALID_OBJ_ADDR;
687 return Status::NO_DATA_LOADER;
694 status = pLoader->
updateObj( pAddress, toUpdate );
699 throw GaudiException(
"std::exception in updateObject() " + pRegistry->
name() +
": " +
710 if ( !
checkRoot() )
return Status::INVALID_ROOT;
716 if ( !to_entry )
return Status::INVALID_OBJECT;
718 if ( sep > 0 && sep != std::string_view::npos ) {
724 StatusCode status = from_entry->
add( to_string( objPath ), to,
true );
725 return status.
isSuccess() ? Status::IDataProviderSvc_NO_ERROR : Status::DOUBL_OBJ_PATH;
728 return Status::INVALID_PARENT;
733 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
736 return linkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ), to );
741 if ( !
checkRoot() )
return Status::INVALID_ROOT;
746 if ( sep > 0 && sep != std::string_view::npos ) {
753 return Status::INVALID_OBJ_PATH;
756 return Status::INVALID_PARENT;
761 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
764 return unlinkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ) );
769 if ( !
checkRoot() )
return Status::INVALID_ROOT;
796 if ( pObject && depth++ < load_depth ) {
799 for (
const auto& i : *dir ) {
814 int load_depth = i.depth();
840 error() <<
"Unable to reinitialize base class" <<
endmsg;
846 error() <<
"Failed to access incident service." <<
endmsg;
StatusCode reinitialize() override
Service initialization.
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
void setRegistry(IRegistry *pRegistry)
Set pointer to Registry.
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.
RegistryEntry * findLeaf(std::string_view path) const
Find identified leaf in this registry node.
bool isSoft() const
Is the link soft or hard.
StatusCode resetPreLoad() override
Clear the preload list.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
#define CAST_REGENTRY(x, y)
virtual unsigned long release()
release reference to object
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
StatusCode setDataLoader(IConversionSvc *svc, IDataProviderSvc *dpsvc=nullptr) override
IDataManagerSvc: IDataManagerSvc: Pass a default data loader to the service and optionally a data pro...
StatusCode unlinkObject(IRegistry *from, std::string_view objPath) override
Remove a link to another object.
StatusCode i_retrieveEntry(DataSvcHelpers::RegistryEntry *parentObj, std::string_view path, DataSvcHelpers::RegistryEntry *&pEntry)
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
void makeHard(DataObject *pObject)
Initialize link as hard link.
DataSvcHelpers::RegistryEntry RegEntry
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject) override
Retrieve object from data store.
StatusCode finalize() override
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
DataObject * i_handleDataFault(IRegistry *pReg, std::string_view path=std::string_view{})
SmartIF< IConversionSvc > m_dataLoader
Pointer to data loader service.
StatusCode traverseTree(IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
IOpaqueAddress * address() const override
Retrieve opaque storage address.
virtual const name_type & name() const =0
Name of the directory (or key)
const Store & leaves() const
Access the leaves of the object.
AttribStringParser::Iterator begin(const AttribStringParser &parser)
virtual DataObject * createDefaultObject() const
Create default objects in case forced creation of leaves is requested.
DataObject * object() const override
Retrive object behind the link.
const std::string & name() const override
Retrieve name of the service
DataObject * handleDataFault(IRegistry *pReg, std::string_view path="")
Invoke data fault handling if enabled.
Gaudi::Property< std::string > m_rootName
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...
StatusCode retrieveEntry(DataSvcHelpers::RegistryEntry *pNode, std::string_view path, DataSvcHelpers::RegistryEntry *&pEntry)
Retrieve registry entry from store.
StatusCode remove(std::string_view name)
Remove an entry from the store.
void setObject(DataObject *obj)
Set/Update object address.
virtual StatusCode i_setRoot(std::string root_name, DataObject *pRootObj)
Initialize data store for new event by giving new event path and root object.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
Gaudi::Property< bool > m_enableFaultHdlr
const ValueType & value() const
StatusCode clearSubTree(std::string_view sub_tree_path) override
IDataManagerSvc: Remove all data objects below the sub tree identified by its full path name.
bool isEmpty() const
Simple check if the Container is empty.
const std::string & rootName() const override
IDataManagerSvc: Accessor for root event name.
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
unsigned int CLID
Class ID definition.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
IRegistry * parent() const
Pointer to parent directory entry.
void setDataSvc(IDataProviderSvc *s)
Set the transient data store.
StatusCode unregisterAddress(std::string_view fullPath) override
IDataManagerSvc: Unregister object address from the data store.
Gaudi::Property< std::string > m_faultName
Gaudi::Property< std::vector< std::string > > m_inhibitPathes
StatusCode preLoad() override
load all preload items of the list
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
std::unique_ptr< DataSvcHelpers::RegistryEntry > m_root
Pointer to root entry.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
bool checkRoot()
Check if root path is valid.
SmartIF< IIncidentSvc > m_incidentSvc
Pointer to incident service.
Gaudi::Property< bool > m_forceLeaves
constexpr static const auto SUCCESS
StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves) override
IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object.
TYPE * get() const
Get interface pointer.
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
virtual IConversionSvc * getDataLoader(IRegistry *pReg)
Retrieve customizable data loader according to registry entry to be retrieved.
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 * object() const =0
Retrieve object behind the link.
StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *to) override
Add a link to another object.
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 objectParent(const DataObject *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode reinitialize() override
StatusCode registerObject(std::string_view parentPath, std::string_view objPath, DataObject *pObject) override
Register object with the data store.
const std::string & identifier() const override
Full identifier (or key)
StatusCode initialize() override
Service initialization.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
Gaudi::Property< std::string > m_accessName
StatusCode unregisterObject(std::string_view fullPath) override
Unregister object from the data store.
constexpr static const auto FAILURE
Gaudi::Property< CLID > m_rootCLID
Gaudi::Property< bool > m_enableAccessHdlr
StatusCode traverseTree(IDataStoreAgent *pAgent, int level=0)
traverse data tree
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
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.
std::vector< DataStoreItem > m_preLoads
Items to be pre-loaded.
StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress) override
IDataManagerSvc: Register object address with the data store.
virtual unsigned long addRef()
Add reference to object.
virtual StatusCode loadObject(IRegistry *pNode)
Invoke Persistency service to create transient object from its persistent representation.
RegistryEntry * parentEntry()
Pointer to parent registry entry.
StatusCode finalize() override
Service initialization.