19 #define DATASVC_DATASVC_CPP 41 #include "boost/utility/string_ref.hpp" 49 inline boost::string_ref::size_type find( boost::string_ref
s,
char c,
size_t o )
51 if ( !s.empty() ) s.remove_prefix( o );
53 return r == boost::string_ref::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() 84 parent->
remove( node_entry );
87 return INVALID_PARENT;
89 return INVALID_OBJECT;
107 return INVALID_PARENT;
109 return INVALID_OBJECT;
141 if ( !entry )
return INVALID_OBJECT;
215 if ( !pObject )
return INVALID_OBJECT;
223 if ( !node_entry )
return INVALID_OBJECT;
224 refpParent = node_entry->
parent();
231 if ( !pObject )
return INVALID_OBJECT;
242 if ( !node_entry )
return INVALID_OBJECT;
243 leaves = node_entry->
leaves();
250 if ( fullPath.
empty() )
return INVALID_OBJ_PATH;
265 if ( objPath.
empty() )
return INVALID_OBJ_PATH;
272 if ( sep == std::string::npos ) {
273 return INVALID_PARENT;
283 if ( !par_entry )
return INVALID_PARENT;
286 if ( sep > 0 && sep != std::string::npos ) {
287 auto p_path = objPath.
substr( 0, sep );
288 auto o_path = objPath.
substr( sep );
296 p_entry = par_entry->
findLeaf( p_path );
298 if ( !p_entry )
return INVALID_PARENT;
302 return status.
isSuccess() ? status : DOUBL_OBJ_PATH;
308 if ( fullPath.
empty() )
return INVALID_OBJ_PATH;
322 if ( objPath.
empty() )
return INVALID_OBJ_PATH;
332 return INVALID_PARENT;
342 if ( sep > 0 && sep != std::string::npos ) {
346 if ( status.isSuccess() )
return status;
349 return INVALID_PARENT;
390 if ( !objPath.
empty() ) {
393 if ( sep != std::string::npos ) {
400 return INVALID_OBJ_PATH;
406 if ( sep != std::string::npos ) {
407 auto p_path = objPath.
substr( 0, sep );
408 auto o_path = objPath.
substr( sep );
416 par_entry = node_entry->
findLeaf( p_path );
417 }
else if ( par_entry && !par_entry->
object() ) {
423 par_entry = node_entry->
findLeaf( p_path );
426 node_entry = par_entry;
436 status = node_entry->
add( objPath, pObject );
441 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
449 status = DOUBL_OBJ_PATH;
455 return INVALID_PARENT;
465 if ( !pEntry )
return INVALID_ROOT;
466 if ( !pEntry->
isEmpty() )
return DIR_NOT_EMPTY;
468 if ( !pParent )
return INVALID_PARENT;
469 if ( pObject ) pObject->
addRef();
470 pParent->
remove( pEntry );
493 if ( !entry )
return INVALID_OBJECT;
495 if ( !parent )
return INVALID_PARENT;
496 if ( !entry->
isEmpty() )
return DIR_NOT_EMPTY;
498 if ( parent ) parent->
remove( entry );
518 return DIR_NOT_EMPTY;
520 return INVALID_OBJECT;
524 return INVALID_PARENT;
546 if ( pReg && path.empty() ) {
554 p.
append( path.data(), path.size() );
561 p.
append( path.data(), path.size() );
611 return INVALID_OBJ_ADDR;
614 status = pLoader->
createObj( pAddress, pObject );
623 status = pLoader->
fillObjRefs( pAddress, pObject );
667 static const auto empty = boost::string_ref{};
675 }
else if ( path.front() !=
SEPARATOR ) {
677 }
else if ( sep != boost::string_ref::npos ) {
681 if ( !status.isSuccess() )
return status;
684 path = path.substr( sep );
686 return INVALID_OBJ_PATH;
692 if ( sep != boost::string_ref::npos ) {
693 if ( !parentObj->
object() ) {
695 if ( !status.
isSuccess() )
return status;
697 auto p_path = path.substr( 0, sep );
703 root_entry = parentObj->
findLeaf( p_path );
710 if ( !status.
isSuccess() )
return status;
712 if ( root_entry->
isSoft() ) {
718 }
else if ( path.empty() ) {
721 if ( !parentObj->
object() ) {
723 if ( !status.
isSuccess() )
return status;
726 pEntry = parentObj->
findLeaf( path );
730 pEntry = ( path.empty() ? parentObj : parentObj->
findLeaf( path ) );
735 if ( !pEntry )
return INVALID_OBJ_PATH;
801 if ( !path.
empty() ) pReg = root_entry->
find( path );
802 if ( !pReg )
return INVALID_OBJ_PATH;
805 return ( !pObject ) ? OBJ_NOT_LOADED : IDataProviderSvc_NO_ERROR;
815 return !pObject ? OBJ_NOT_LOADED : IDataProviderSvc_NO_ERROR;
835 return findObject( parentPath, itemToPath( item ), pObject );
841 return findObject( parentObj, itemToPath( item ), pObject );
863 return INVALID_OBJ_ADDR;
877 return INVALID_OBJECT;
881 return INVALID_OBJECT;
885 return INVALID_OBJ_ADDR;
889 return NO_DATA_LOADER;
898 status = pLoader->
updateObj( pAddress, toUpdate );
905 throw GaudiException(
"std::exception in updateObject() " + pRegistry->
name() +
": " +
940 return INVALID_OBJECT;
943 if ( sep > 0 && sep != std::string::npos ) {
953 return status.
isSuccess() ? IDataProviderSvc_NO_ERROR : DOUBL_OBJ_PATH;
957 return INVALID_PARENT;
965 if ( !fullPath.
empty() ) {
972 return INVALID_OBJ_PATH;
992 return INVALID_PARENT;
1003 if ( sep > 0 && sep != std::string::npos ) {
1012 if ( status.
isSuccess() )
return status;
1013 return INVALID_OBJ_PATH;
1017 return INVALID_PARENT;
1019 return INVALID_ROOT;
1025 if ( fullPath.
empty() )
return INVALID_OBJ_PATH;
1044 if ( !
checkRoot() )
return INVALID_ROOT;
1089 if ( pObject && depth++ < load_depth ) {
1092 for (
const auto& i : *dir ) {
1095 if ( status.
isSuccess() && depth < load_depth ) {
1110 int load_depth = i.depth();
1111 if ( sc.
isSuccess() && load_depth > 1 ) {
1126 error() <<
"Failed to access incident service." <<
endmsg;
1142 error() <<
"Unable to reinitialize base class" <<
endmsg;
1148 error() <<
"Failed to access incident service." <<
endmsg;
StatusCode unregisterObject(const std::string &fullPath) override
Unregister object from the data store.
Gaudi::Property< CLID > m_rootCLID
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
StatusCode initialize() override
RegistryEntry * findLeaf(boost::string_ref path) const
Find identified leaf in this registry node.
~DataSvc() override
Standard Destructor.
Define general base for Gaudi exception.
DataObject * object() const override
Retrive object behind the link.
const std::string & name() const override
Retrieve name of the service.
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
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Gaudi::Property< std::string > m_accessName
bool isSuccess() const
Test for a status code of SUCCESS.
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...
virtual long add(const std::string &name, DataObject *pObject, bool is_soft=false)
Add entry to data store.
virtual long traverseTree(IDataStoreAgent *pAgent, int level=0)
traverse data tree
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Gaudi::Property< std::string > m_rootName
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
virtual StatusCode loadObject(IRegistry *pNode)
Invoke Persistency service to create transient object from its persistent representation.
LoadItems m_preLoads
Items to be pre-loaded.
Gaudi::Property< bool > m_forceLeaves
void setRegistry(IRegistry *pRegistry)
Set pointer to Registry.
unsigned long release() override
IInterface implementation: Reference the object.
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.
DataObject * i_handleDataFault(IRegistry *pReg, boost::string_ref path=boost::string_ref{})
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
virtual long remove(const std::string &name)
Remove an entry from the store.
const Store & leaves() const
Access the leaves of the object.
StatusCode registerObject(const std::string &fullPath, DataObject *pObject) override
Register object with the data store.
Data provider interface definition.
DataSvcHelpers::RegistryEntry * m_root
Pointer to root entry.
void setAddress(IOpaqueAddress *pAddress) override
Set/Update Opaque address.
Description of the DataStoreItem class.
StatusCode registerAddress(const std::string &fullPath, IOpaqueAddress *pAddress) override
IDataManagerSvc: Register object address with the data store.
bool isFailure() const
Test for a status code of FAILURE.
IRegistry * registry() const
Get pointer to Registry.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
virtual RegistryEntry * parentEntry()
Pointer to parent registry entry.
TYPE * get() const
Get interface pointer.
virtual bool isSoft() const
Is the link soft or hard.
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.
StatusCode i_retrieveEntry(DataSvcHelpers::RegistryEntry *parentObj, boost::string_ref path, DataSvcHelpers::RegistryEntry *&pEntry)
Gaudi::Property< std::string > m_faultName
virtual const id_type & identifier() const =0
Full identifier (or key)
This class is used for returning status codes from appropriate routines.
StatusCode retrieveEntry(DataSvcHelpers::RegistryEntry *pNode, const std::string &path, DataSvcHelpers::RegistryEntry *&pEntry)
Retrieve registry entry from store.
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
SmartIF< IIncidentSvc > m_incidentSvc
Pointer to incident service.
StatusCode findObject(const std::string &fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
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.
StatusCode unregisterAddress(const std::string &fullPath) override
IDataManagerSvc: Unregister object address from the data store.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
StatusCode finalize() override
Service initialization.
virtual bool isEmpty() const
Simple check if the Container is empty.
StatusCode reinitialize() override
unsigned int CLID
Class ID definition.
StatusCode clearSubTree(const std::string &sub_tree_path) override
IDataManagerSvc: Remove all data objects below the sub tree identified by its full path name...
IOpaqueAddress * address() const override
Retrieve opaque storage address.
StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject) override
Retrieve object from data store.
StatusCode linkObject(IRegistry *from, const std::string &objPath, DataObject *to) override
Add a link to another object.
#define CAST_REGENTRY(x, y)
virtual DataObject * object() const =0
Retrieve object behind the link.
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
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, const std::string &path="")
Invoke data fault handling if enabled.
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.
virtual IRegistry * parent() const
Pointer to parent directory entry.
Generic data agent interface.
StatusCode initialize() override
Service initialization.
StatusCode unlinkObject(IRegistry *from, const std::string &objPath) override
Remove a link to another object.
Gaudi::Property< bool > m_enableAccessHdlr
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
const std::string & rootName() const override
IDataManagerSvc: Accessor for root event name.
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.
const std::string & identifier() const override
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.
Opaque address interface definition.
virtual IConversionSvc * getDataLoader(IRegistry *pReg)
Retrieve customizable data loader according to registry entry to be retrieved.
StatusCode traverseSubTree(const std::string &sub_tree_path, IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects below the sub tree identified by its full pat...
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
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 resetPreLoad() override
Clear the preload list.
virtual DataObject * createDefaultObject() const
Create default objects in case forced creation of leaves is requested.
virtual IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
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.
DataSvcHelpers::RegistryEntry RegEntry
void makeHard(DataObject *pObject)
Initialize link as hard link.