19 #define DATASVC_DATASVC_CPP 41 #include "boost/utility/string_ref.hpp" 51 inline boost::string_ref::size_type find( boost::string_ref
s,
char c,
size_t o ) {
52 if (!s.empty()) s.remove_prefix(o);
54 return r==boost::string_ref::npos ? r : ( r + o ) ;
63 #define CAST_REGENTRY(x,y) dynamic_cast<x>(y) 67 #define ON_DEBUG if (msgLevel(MSG::DEBUG)) 68 #define ON_VERBOSE if (msgLevel(MSG::VERBOSE)) 70 #define DEBMSG ON_DEBUG debug() 71 #define VERMSG ON_VERBOSE verbose() 84 parent->
remove(node_entry);
87 return INVALID_PARENT;
89 return INVALID_OBJECT;
106 return INVALID_PARENT;
108 return INVALID_OBJECT;
139 if ( !entry )
return INVALID_OBJECT;
211 if ( !pObject )
return INVALID_OBJECT;
219 if ( !node_entry )
return INVALID_OBJECT;
220 refpParent = node_entry->
parent();
227 if ( !pObject )
return INVALID_OBJECT;
238 if ( !node_entry )
return INVALID_OBJECT;
239 leaves = node_entry->
leaves();
246 if ( fullPath.
empty() )
return INVALID_OBJ_PATH;
264 if ( objPath.
empty() )
return INVALID_OBJ_PATH;
271 if ( sep == std::string::npos ) {
272 return INVALID_PARENT;
282 if ( !par_entry )
return INVALID_PARENT;
285 if ( sep > 0 && sep != std::string::npos ) {
286 auto p_path = objPath.
substr( 0, sep);
287 auto o_path = objPath.
substr( sep );
297 p_entry = par_entry->
findLeaf(p_path);
299 if ( !p_entry )
return INVALID_PARENT;
303 return status.
isSuccess() ? status : DOUBL_OBJ_PATH;
308 if ( fullPath.
empty() )
return INVALID_OBJ_PATH;
324 if ( objPath.
empty() )
return INVALID_OBJ_PATH;
331 if ( sep != std::string::npos &&
335 return INVALID_PARENT;
345 if ( sep > 0 && sep != std::string::npos ) {
349 if ( status.isSuccess() )
return status;
352 return INVALID_PARENT;
398 if ( !objPath.
empty() ) {
401 if ( sep != std::string::npos ) {
408 return INVALID_OBJ_PATH;
414 if ( sep != std::string::npos ) {
415 auto p_path = objPath.
substr( 0, sep );
416 auto o_path = objPath.
substr( sep );
424 par_entry = node_entry->
findLeaf(p_path);
426 else if ( par_entry && !par_entry->
object() ) {
432 par_entry = node_entry->
findLeaf(p_path);
435 node_entry = par_entry;
446 status = node_entry->
add( objPath, pObject );
452 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
461 status = DOUBL_OBJ_PATH;
467 return INVALID_PARENT;
476 if ( !pEntry )
return INVALID_ROOT;
477 if ( !pEntry->
isEmpty() )
return DIR_NOT_EMPTY;
479 if ( !pParent )
return INVALID_PARENT;
480 if ( pObject ) pObject->
addRef();
502 if ( !entry )
return INVALID_OBJECT;
504 if ( !parent )
return INVALID_PARENT;
505 if ( !entry->
isEmpty() )
return DIR_NOT_EMPTY;
507 if ( parent ) parent->
remove(entry);
527 return DIR_NOT_EMPTY;
529 return INVALID_OBJECT;
534 return INVALID_PARENT;
554 if ( pReg && path.empty() ) {
562 p.
append(path.data(),path.size());
569 p.
append(path.data(),path.size());
618 return INVALID_OBJ_ADDR;
621 status = pLoader->
createObj(pAddress, pObject);
674 boost::string_ref
path,
679 static const auto empty = boost::string_ref{};
687 }
else if ( path.front() !=
SEPARATOR ) {
689 }
else if ( sep != boost::string_ref::npos ) {
693 if ( !status.isSuccess() )
return status;
696 path = path.substr(sep);
698 return INVALID_OBJ_PATH;
704 if ( sep != boost::string_ref::npos ) {
705 if (!parentObj->
object()) {
707 if ( !status.
isSuccess() )
return status;
709 auto p_path = path.substr(0,sep);
715 root_entry = parentObj->
findLeaf(p_path);
722 if ( !status.
isSuccess() )
return status;
724 if ( root_entry->
isSoft() ) {
730 }
else if ( path.empty() ) {
733 if (!parentObj->
object()) {
735 if ( !status.
isSuccess() )
return status;
742 pEntry = (path.empty() ? parentObj : parentObj->
findLeaf(path) );
747 if ( !pEntry )
return INVALID_OBJ_PATH;
820 if ( !path.
empty() ) pReg = root_entry->
find(path);
821 if ( !pReg )
return INVALID_OBJ_PATH;
824 return (!pObject) ? OBJ_NOT_LOADED : IDataProviderSvc_NO_ERROR;
834 return !pObject ? OBJ_NOT_LOADED : IDataProviderSvc_NO_ERROR;
857 return findObject(parentPath, itemToPath(item), pObject);
864 return findObject(parentObj, itemToPath(item), pObject);
886 return INVALID_OBJ_ADDR;
899 return INVALID_OBJECT;
903 return INVALID_OBJECT;
907 return INVALID_OBJ_ADDR;
911 return NO_DATA_LOADER;
921 status = pLoader->
updateObj(pAddress, toUpdate);
934 pRegistry->
name() +
": " +
975 return INVALID_OBJECT;
978 if ( sep > 0 && sep != std::string::npos ) {
988 return status.
isSuccess() ? IDataProviderSvc_NO_ERROR : DOUBL_OBJ_PATH;
993 return INVALID_PARENT;
1001 if ( !fullPath.
empty() ) {
1008 return INVALID_OBJ_PATH;
1031 return INVALID_PARENT;
1042 if ( sep > 0 && sep != std::string::npos ) {
1051 if ( status.
isSuccess() )
return status;
1052 return INVALID_OBJ_PATH;
1057 return INVALID_PARENT;
1059 return INVALID_ROOT;
1064 if ( fullPath.
empty() )
return INVALID_OBJ_PATH;
1084 if ( !
checkRoot() )
return INVALID_ROOT;
1124 if ( pObject && depth++ < load_depth ) {
1127 for (
const auto& i : *dir) {
1130 if ( status.
isSuccess() && depth < load_depth ) {
1144 int load_depth = i.depth();
1145 if ( sc.
isSuccess() && load_depth > 1 ) {
1159 error() <<
"Failed to access incident service." <<
endmsg;
1174 error() <<
"Unable to reinitialize base class" <<
endmsg;
1180 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.