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 ) {
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.
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
StatusCode initialize() override
bool m_enableAccessHdlr
Flag to enable interrupts on data access requests.
RegistryEntry * findLeaf(boost::string_ref path) const
Find identified leaf in this registry node.
~DataSvc() override
Standard Destructor.
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
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
bool m_enableFaultHdlr
Flag to enable interrupts on data creation requests.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
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.
std::string m_rootName
Name of root event.
virtual long traverseTree(IDataStoreAgent *pAgent, int level=0)
traverse data tree
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
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.
std::string m_accessName
Name of the data access incident.
void setRegistry(IRegistry *pRegistry)
Set pointer to Registry.
unsigned long release() override
IInterface implementation: Reference the object.
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.
DataSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
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.
const std::string & name() const override
Retrieve name of the service.
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)
IOpaqueAddress * address() const override
Retrieve opaque storage address.
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...
const std::string & identifier() const override
Full identifier (or key)
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...
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject) override
Retrieve object from data store.
bool m_forceLeaves
Allow forced creation of default leaves on registerObject.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual DataObject * object() const =0
Retrieve object behind the link.
StatusCode linkObject(IRegistry *from, const std::string &objPath, DataObject *to) override
Add a link to another object.
#define CAST_REGENTRY(x, y)
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
Definition of an entry in the transient data store.
virtual unsigned long release()
release reference to object
std::string m_faultName
Name of the data fault incident.
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.
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.
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.
std::vector< std::string > m_inhibitPathes
Property for the inhibited leaves.
CLID m_rootCLID
Integer Property corresponding to CLID of root entry.
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.
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.
Opaque address interface definition.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
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...
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
const std::string & rootName() const override
IDataManagerSvc: Accessor for root event name.
void makeHard(DataObject *pObject)
Initialize link as hard link.