19 #define DATASVC_DATASVC_CPP 44 s.append(
sr.data(),
sr.size() );
48 std::string_view::size_type find( std::string_view
s,
char c,
size_t o ) {
49 if ( !
s.empty() )
s.remove_prefix( o );
51 return r == std::string_view::npos ? r : ( r + o );
62 #define CAST_REGENTRY( x, y ) dynamic_cast<x>( y ) 66 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) 67 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) ) 69 #define DEBMSG ON_DEBUG debug() 70 #define VERMSG ON_VERBOSE verbose() 80 if ( !node_entry )
return Status::INVALID_OBJECT;
82 if ( !parent )
return Status::INVALID_PARENT;
83 parent->
remove( node_entry );
91 if ( !
checkRoot() )
return Status::INVALID_ROOT;
93 if ( !entry )
return Status::INVALID_OBJECT;
95 if ( !parent )
return Status::INVALID_PARENT;
102 if ( !
checkRoot() )
return Status::INVALID_ROOT;
119 return entry ? entry->
traverseTree( pAgent ) : Status::INVALID_OBJECT;
124 if ( !
checkRoot() )
return Status::INVALID_ROOT;
185 if ( !pObject )
return Status::INVALID_OBJECT;
190 if ( !
checkRoot() )
return Status::INVALID_ROOT;
192 if ( !node_entry )
return Status::INVALID_OBJECT;
193 refpParent = node_entry->
parent();
199 if ( !pObject )
return Status::INVALID_OBJECT;
207 if ( !
checkRoot() )
return Status::INVALID_ROOT;
209 if ( !node_entry )
return Status::INVALID_OBJECT;
210 leaves = node_entry->
leaves();
216 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
222 if ( !
checkRoot() )
return Status::INVALID_ROOT;
223 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
227 auto sep = find( objPath,
SEPARATOR, 1 );
228 if ( sep == std::string_view::npos || objPath.substr( 0, sep ) !=
m_rootName.value() ) {
229 return Status::INVALID_PARENT;
235 if ( !par_entry )
return Status::INVALID_PARENT;
238 if ( sep > 0 && sep != std::string_view::npos ) {
239 auto p_path = objPath.substr( 0, sep );
240 auto o_path = objPath.substr( sep );
248 p_entry = par_entry->
findLeaf( p_path );
250 if ( !p_entry )
return Status::INVALID_PARENT;
253 StatusCode status = par_entry->
add( to_string( objPath ), pAddress );
254 return status.
isSuccess() ? status : Status::DOUBL_OBJ_PATH;
259 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
265 if ( !
checkRoot() )
return Status::INVALID_ROOT;
266 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
270 auto sep = find( objPath,
SEPARATOR, 1 );
271 if ( sep != std::string_view::npos && objPath.substr( 0, sep ) ==
m_rootName.value() ) {
274 return Status::INVALID_PARENT;
282 if ( sep > 0 && sep != std::string_view::npos ) {
289 return Status::INVALID_PARENT;
306 if ( !
checkRoot() )
return Status::INVALID_ROOT;
309 if ( !objPath.empty() ) {
311 auto sep = find( objPath,
SEPARATOR, 1 );
312 if ( sep != std::string_view::npos ) {
313 return registerObject( objPath.substr( 0, sep ), objPath.substr( sep ), pObject );
316 return Status::INVALID_OBJ_PATH;
321 auto sep = find( objPath,
SEPARATOR, 1 );
322 if ( sep != std::string_view::npos ) {
323 auto p_path = objPath.substr( 0, sep );
324 auto o_path = objPath.substr( sep );
332 par_entry = node_entry->
findLeaf( p_path );
333 }
else if ( par_entry && !par_entry->
object() ) {
339 par_entry = node_entry->
findLeaf( p_path );
342 node_entry = par_entry;
350 status = node_entry->
add( to_string( objPath ), pObject );
355 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
363 status = Status::DOUBL_OBJ_PATH;
369 return Status::INVALID_PARENT;
378 if ( !pEntry )
return Status::INVALID_ROOT;
379 if ( !pEntry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
381 if ( !pParent )
return Status::INVALID_PARENT;
382 if ( pObject ) pObject->
addRef();
383 pParent->
remove( pEntry );
389 if ( !
checkRoot() )
return Status::INVALID_ROOT;
391 if ( !entry )
return Status::INVALID_OBJECT;
393 if ( !parent )
return Status::INVALID_PARENT;
394 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
396 if ( parent ) parent->
remove( entry );
413 return Status::DIR_NOT_EMPTY;
415 return Status::INVALID_OBJECT;
418 return Status::INVALID_PARENT;
420 return Status::INVALID_ROOT;
432 if ( pReg &&
path.empty() ) {
452 if ( pLeaf ) {
return pLeaf->
object(); }
491 return Status::INVALID_OBJ_ADDR;
494 status = pLoader->
createObj( pAddress, pObject );
503 status = pLoader->
fillObjRefs( pAddress, pObject );
536 static constexpr
auto empty = std::string_view{};
546 }
else if ( sep != std::string_view::npos ) {
550 if ( !status.isSuccess() )
return status;
555 return Status::INVALID_OBJ_PATH;
561 if ( sep != std::string_view::npos ) {
562 if ( !parentObj->
object() ) {
564 if ( !status.
isSuccess() )
return status;
566 auto p_path =
path.substr( 0, sep );
572 root_entry = parentObj->
findLeaf( p_path );
579 if ( !status.
isSuccess() )
return status;
585 }
else if (
path.empty() ) {
588 if ( !parentObj->
object() ) {
590 if ( !status.
isSuccess() )
return status;
602 if ( !pEntry )
return Status::INVALID_OBJ_PATH;
633 if ( !pReg )
return Status::INVALID_OBJ_PATH;
636 return ( !pObject ) ? Status::OBJ_NOT_LOADED : Status::IDataProviderSvc_NO_ERROR;
642 if ( !
checkRoot() )
return Status::INVALID_ROOT;
645 return !pObject ? Status::OBJ_NOT_LOADED : Status::IDataProviderSvc_NO_ERROR;
653 return Status::INVALID_OBJ_ADDR;
666 return Status::INVALID_OBJECT;
670 return Status::INVALID_OBJECT;
674 return Status::INVALID_OBJ_ADDR;
678 return Status::NO_DATA_LOADER;
685 status = pLoader->
updateObj( pAddress, toUpdate );
690 throw GaudiException(
"std::exception in updateObject() " + pRegistry->
name() +
": " +
701 if ( !
checkRoot() )
return Status::INVALID_ROOT;
707 if ( !to_entry )
return Status::INVALID_OBJECT;
709 if ( sep > 0 && sep != std::string_view::npos ) {
715 StatusCode status = from_entry->
add( to_string( objPath ), to,
true );
716 return status.
isSuccess() ? Status::IDataProviderSvc_NO_ERROR : Status::DOUBL_OBJ_PATH;
719 return Status::INVALID_PARENT;
724 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
727 return linkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ), to );
732 if ( !
checkRoot() )
return Status::INVALID_ROOT;
737 if ( sep > 0 && sep != std::string_view::npos ) {
744 return Status::INVALID_OBJ_PATH;
747 return Status::INVALID_PARENT;
752 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
755 return unlinkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ) );
760 if ( !
checkRoot() )
return Status::INVALID_ROOT;
787 if ( pObject && depth++ < load_depth ) {
790 for (
const auto& i : *dir ) {
805 int load_depth = i.depth();
831 error() <<
"Unable to reinitialize base class" <<
endmsg;
837 error() <<
"Failed to access incident service." <<
endmsg;
Gaudi::Property< CLID > m_rootCLID
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
StatusCode initialize() override
std::unique_ptr< DataSvcHelpers::RegistryEntry > m_root
Pointer to root entry.
Define general base for Gaudi exception.
StatusCode retrieveEntry(DataSvcHelpers::RegistryEntry *pNode, std::string_view path, DataSvcHelpers::RegistryEntry *&pEntry)
Retrieve registry entry from store.
IRegistry * registry() const
Get pointer to Registry.
StatusCode preLoad() override
load all preload items of the list
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
StatusCode finalize() override
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Gaudi::Property< std::string > m_accessName
StatusCode traverseTree(IDataStoreAgent *pAgent, int level=0)
traverse data tree
StatusCode setRoot(std::string root_name, DataObject *pRootObj) override
Initialize data store for new event by giving new event path and root object.
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.
Gaudi::Property< std::string > m_rootName
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
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...
virtual StatusCode loadObject(IRegistry *pNode)
Invoke Persistency service to create transient object from its persistent representation.
constexpr static const auto SUCCESS
bool isEmpty() const
Simple check if the Container is empty.
Gaudi::Property< bool > m_forceLeaves
void setRegistry(IRegistry *pRegistry)
Set pointer to Registry.
virtual DataObject * createDefaultObject() const
Create default objects in case forced creation of leaves is requested.
Gaudi::Property< bool > m_enableFaultHdlr
virtual const name_type & name() const =0
Name of the directory (or key)
StatusCode traverseTree(IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
bool checkRoot()
Check if root path is valid.
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
Data provider interface definition.
void setAddress(IOpaqueAddress *pAddress) override
Set/Update Opaque address.
Description of the DataStoreItem class.
TYPE * get() const
Get interface pointer.
IRegistry * parent() const
Pointer to parent directory entry.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
DataObject * i_handleDataFault(IRegistry *pReg, std::string_view path=std::string_view{})
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.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
virtual unsigned long addRef()
Add reference to object.
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
void setObject(DataObject *obj)
Set/Update object address.
Gaudi::Property< std::string > m_faultName
IOpaqueAddress * address() const override
Retrieve opaque storage address.
StatusCode unregisterObject(std::string_view fullPath) override
Unregister object from the data store.
StatusCode unregisterAddress(std::string_view fullPath) override
IDataManagerSvc: Unregister object address from the data store.
StatusCode unlinkObject(IRegistry *from, std::string_view objPath) override
Remove a link to another object.
This class is used for returning status codes from appropriate routines.
StatusCode i_retrieveEntry(DataSvcHelpers::RegistryEntry *parentObj, std::string_view path, DataSvcHelpers::RegistryEntry *&pEntry)
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
SmartIF< IIncidentSvc > m_incidentSvc
Pointer to incident service.
const Store & leaves() const
Access the leaves of the object.
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves) override
IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object.
void setDataSvc(IDataProviderSvc *s)
Set the transient data store.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
const std::string & identifier() const override
Full identifier (or key)
StatusCode finalize() override
Service initialization.
StatusCode reinitialize() override
unsigned int CLID
Class ID definition.
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
StatusCode remove(std::string_view name)
Remove an entry from the store.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual DataObject * object() const =0
Retrieve object behind the link.
#define CAST_REGENTRY(x, y)
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress) override
IDataManagerSvc: Register object address with the data store.
Definition of an entry in the transient data store.
virtual unsigned long release()
release reference to object
Gaudi::Property< std::vector< std::string > > m_inhibitPathes
StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *to) override
Add a link to another object.
const StatusCode & ignore() const
Ignore/check StatusCode.
StatusCode add(std::string name, DataObject *pObject, bool is_soft=false)
Add entry to data store.
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 * object() const override
Retrive object behind the link.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
StatusCode reinitialize() override
Service initialization.
SmartIF< IConversionSvc > m_dataLoader
Pointer to data loader service.
Generic data agent interface.
StatusCode initialize() override
Service initialization.
RegistryEntry * parentEntry()
Pointer to parent registry entry.
decltype(auto) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
constexpr static const auto FAILURE
StatusCode registerObject(std::string_view parentPath, std::string_view objPath, DataObject *pObject) override
Register object with the data store.
Gaudi::Property< bool > m_enableAccessHdlr
StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
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.
bool isSoft() const
Is the link soft or hard.
virtual const id_type & identifier() const =0
Full identifier (or key)
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Data service incident class.
AttribStringParser::Iterator begin(const AttribStringParser &parser)
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Opaque address interface definition.
virtual IConversionSvc * getDataLoader(IRegistry *pReg)
Retrieve customizable data loader according to registry entry to be retrieved.
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
A DataObject is the base class of any identifiable object on any data store.
StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject) override
Retrieve object from data store.
StatusCode resetPreLoad() override
Clear the preload list.
std::vector< DataStoreItem > m_preLoads
Items to be pre-loaded.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
StatusCode clearSubTree(std::string_view sub_tree_path) override
IDataManagerSvc: Remove all data objects below the sub tree identified by its full path name.
DataSvcHelpers::RegistryEntry RegEntry
const std::string & rootName() const override
IDataManagerSvc: Accessor for root event name.
void makeHard(DataObject *pObject)
Initialize link as hard link.