19 #define DATASVC_DATASVC_CPP
42 #include "boost/utility/string_ref.hpp"
48 inline std::string itemToPath(
int item) {
49 return std::string{
'/'} + std::to_string(item);
52 inline boost::string_ref::size_type find( boost::string_ref
s,
char c,
size_t o ) {
53 if (!s.empty()) s.remove_prefix(o);
55 return r==boost::string_ref::npos ? r : ( r + o ) ;
64 #define CAST_REGENTRY(x,y) dynamic_cast<x>(y)
68 #define ON_DEBUG if (UNLIKELY(outputLevel() <= MSG::DEBUG))
69 #define ON_VERBOSE if (UNLIKELY(outputLevel() <= MSG::VERBOSE))
71 #define DEBMSG ON_DEBUG debug()
72 #define VERMSG ON_VERBOSE verbose()
85 parent->
remove(node_entry);
204 if ( pDataLoader ) pDataLoader->
addRef();
225 refpParent = node_entry->
parent();
231 std::vector<IRegistry*>& leaves) {
240 std::vector<IRegistry*>& leaves) {
244 leaves = node_entry->
leaves();
258 const std::string& objectPath,
266 const std::string& objPath,
275 std::string::size_type sep = objPath.find(
SEPARATOR,1);
276 if ( sep == std::string::npos ) {
279 if ( objPath.compare(0,sep,
m_rootName) == 0 ) {
289 std::string::size_type sep = objPath.rfind(
SEPARATOR);
290 if ( sep > 0 && sep != std::string::npos ) {
291 auto p_path = objPath.substr( 0, sep);
292 auto o_path = objPath.substr( sep );
302 p_entry = par_entry->
findLeaf(p_path);
320 const std::string& objPath) {
327 const std::string& objPath) {
335 std::string::size_type sep = objPath.find(
SEPARATOR,1);
336 if ( sep != std::string::npos &&
349 std::string::size_type sep = objPath.rfind(
SEPARATOR);
350 if ( sep > 0 && sep != std::string::npos ) {
369 const std::string& objPath,
398 const std::string& objPath,
403 if ( !objPath.empty() ) {
405 std::string::size_type sep = objPath.find(
SEPARATOR,1);
406 if ( sep != std::string::npos ) {
407 return registerObject(objPath.substr( 0, sep), objPath.substr( sep ), pObject);
419 std::string::size_type sep = objPath.find(
SEPARATOR,1);
420 if ( sep != std::string::npos ) {
421 auto p_path = objPath.substr( 0, sep );
422 auto o_path = objPath.substr( sep );
432 par_entry = node_entry->
findLeaf(p_path);
434 else if ( 0 != par_entry && par_entry->
object() == 0 ) {
442 par_entry = node_entry->
findLeaf(p_path);
445 node_entry = par_entry;
456 status = node_entry->
add( objPath, pObject );
462 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
495 if ( pObject ) pObject->
addRef();
502 const std::string& objPath) {
523 if ( parent ) parent->
remove(entry);
529 const std::string& objectPath) {
570 if ( pReg && path.empty() ) {
578 p.append(path.data(),path.size());
586 p.append(path.data(),path.size());
640 status = pLoader->
createObj(pAddress, pObject);
659 catch(
const std::exception& x) {
687 const std::string&
path,
693 boost::string_ref
path,
698 static const auto empty = boost::string_ref{};
706 }
else if ( path.front() !=
SEPARATOR ) {
708 }
else if ( sep != boost::string_ref::npos ) {
712 if ( !status.isSuccess() )
return status;
715 path = path.substr(sep);
723 if ( sep != boost::string_ref::npos ) {
724 if (!parentObj->
object()) {
726 if ( !status.
isSuccess() )
return status;
728 auto p_path = path.substr(0,sep);
734 root_entry = parentObj->
findLeaf(p_path);
741 if ( !status.
isSuccess() )
return status;
743 if ( root_entry->
isSoft() ) {
749 }
else if ( path.empty() ) {
752 if (!parentObj->
object()) {
754 if ( !status.
isSuccess() )
return status;
761 pEntry = (path.empty() ? parentObj : parentObj->
findLeaf(path) );
783 const std::string&
path,
789 pObject = result->
object();
803 const std::string& objectPath,
822 const std::string&
path,
837 const std::string&
path,
843 if ( !path.empty() ) {
844 pReg = root_entry->
find(path);
873 const std::string& objectPath,
878 status =
findObject (parent, objectPath, pObject);
886 return findObject(parentPath, itemToPath(item), pObject);
893 return findObject(parentObj, itemToPath(item), pObject);
898 const std::string&
path,
952 status = pLoader->
updateObj(pAddress, toUpdate);
963 catch(
const std::exception& x) {
965 pRegistry->
name() +
": " +
980 const std::string& updatePath) {
991 const std::string& updatePath) {
1002 const std::string& objPath,
DataObject* to) {
1013 std::string::size_type sep = objPath.rfind(
SEPARATOR);
1014 if ( sep > 0 && sep != std::string::npos ) {
1039 if ( !fullPath.empty() ) {
1044 return linkObject( fullPath.substr( 0, sep), fullPath.substr(sep), to);
1051 const std::string& objPath,
1063 const std::string& objPath,
1076 const std::string& objPath) {
1081 std::string::size_type sep = objPath.rfind(
SEPARATOR);
1082 if ( sep > 0 && sep != std::string::npos ) {
1106 if ( !fullPath.empty() ) {
1111 return unlinkObject(fullPath.substr(0,sep), fullPath.substr(sep));
1118 const std::string& objPath) {
1129 const std::string& objPath) {
1172 if ( pObject && depth++ < load_depth ) {
1175 for (
const auto&
i : *dir) {
1178 if ( status.
isSuccess() && depth < load_depth ) {
1192 int load_depth =
i.depth();
1193 if ( sc.
isSuccess() && load_depth > 1 ) {
1209 error() <<
"Failed to access incident service." <<
endmsg;
1227 error() <<
"Unable to reinitialize base class" <<
endmsg;
1233 error() <<
"Failed to access incident service." <<
endmsg;
1278 m_rootName(
"/Event"), m_root(nullptr)
virtual StatusCode setDataLoader(IConversionSvc *svc)
IDataManagerSvc: IDataManagerSvc: Pass a default data loader to the service.
virtual StatusCode reinitialize()
Service initialization.
The path for this objects is already in use.
bool m_enableAccessHdlr
Flag to enable interrupts on data access requests.
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
RegistryEntry * findLeaf(boost::string_ref path) const
Find identified leaf in this registry node.
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
virtual StatusCode findObject(const std::string &fullPath, DataObject *&pObject)
Find object identified by its full path in the data store.
virtual StatusCode removePreLoadItem(const DataStoreItem &item)
Remove an item from the preload list.
virtual StatusCode registerObject(const std::string &fullPath, DataObject *pObject)
Register object with the data store.
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
virtual StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves)
IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object.
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.
Invalid root path object cannot be retrieved or stored.
Normal successful completion.
bool isSuccess() const
Test for a status code of SUCCESS.
No data loader available.
Sorry, the requested object is not loaded.
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 StatusCode traverseTree(IDataStoreAgent *pAgent)
IDataManagerSvc: Analyze by traversing all data objects in the data store.
virtual StatusCode updateObject(IRegistry *pDirectory)
Update object identified by its directory entry.
virtual StatusCode resetPreLoad()
Clear the preload list.
virtual long traverseTree(IDataStoreAgent *pAgent, int level=0)
traverse data tree
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.
Access to the requested leaf is inhibited.
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.
virtual const name_type & name() const =0
Name of the directory (or key)
virtual StatusCode i_setRoot(const std::string &root_name, DataObject *pRootObj)
Initialize data store for new event by giving new event path and root object.
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{})
virtual long remove(const std::string &name)
Remove an entry from the store.
const Store & leaves() const
Access the leaves of the object.
virtual StatusCode preLoad()
load all preload items of the list
DataSvcHelpers::RegistryEntry * m_root
Pointer to root entry.
virtual StatusCode registerAddress(const std::string &fullPath, IOpaqueAddress *pAddress)
IDataManagerSvc: Register object address with the data store.
virtual unsigned long release()
IInterface implementation: Reference the object.
Description of the DataStoreItem class.
bool isFailure() const
Test for a status code of FAILURE.
IRegistry * registry() const
Get pointer to Registry.
IIncidentSvc * m_incidentSvc
Pointer to incident service.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
virtual RegistryEntry * parentEntry()
Pointer to parent registry entry.
IConversionSvc * m_dataLoader
Pointer to data loader service.
virtual StatusCode setRoot(const std::string &root_name, DataObject *pRootObj)
Initialize data store for new event by giving new event path and root object.
Directory entry is NOT empty.
virtual bool isSoft() const
Is the link soft or hard.
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.
virtual IOpaqueAddress * address() const
Retrieve opaque storage address.
StatusCode i_retrieveEntry(DataSvcHelpers::RegistryEntry *parentObj, boost::string_ref path, DataSvcHelpers::RegistryEntry *&pEntry)
DataSvcHelpers::InhibitMap * m_inhibitMap
Map with object paths to be inhibited from loading.
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.
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...
virtual StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent)
IDataManagerSvc: Explore the object store: retrieve the object's parent.
virtual bool isEmpty() const
Simple check if the Container is empty.
virtual StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)
Retrieve object from data store.
unsigned int CLID
Class ID definition.
bool m_forceLeaves
Allow forced creation of default leaves on registerObject.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
void setAddress(IOpaqueAddress *pAddress)
Set/Update Opaque address.
virtual DataObject * object() const =0
Retrieve object behind the link.
#define CAST_REGENTRY(x, y)
virtual const std::string & name() const
Retrieve name of the service.
virtual StatusCode initialize()
Service initialization.
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
virtual StatusCode linkObject(IRegistry *from, const std::string &objPath, DataObject *to)
Add a link to another object.
Definition of an entry in the transient data store.
virtual StatusCode reinitialize()
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
virtual unsigned long release()
release reference to object
std::string m_faultName
Name of the data fault incident.
virtual const std::string & identifier() const
Full identifier (or key)
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.
Pointer to parent object is not valid.
virtual unsigned long release()=0
Release Interface instance.
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
virtual IRegistry * parent() const
Pointer to parent directory entry.
Generic data agent interface.
virtual StatusCode clearStore()
IDataManagerSvc: Remove all data objects in the data store.
virtual StatusCode unregisterObject(const std::string &fullPath)
Unregister object from the data store.
Object pointer is invalid.
virtual StatusCode unlinkObject(IRegistry *from, const std::string &objPath)
Remove a link to another object.
Templated class to add the standard messaging functionalities.
virtual StatusCode clearSubTree(const std::string &sub_tree_path)
IDataManagerSvc: Remove all data objects below the sub tree identified by its full path name...
std::vector< std::string > m_inhibitPathes
Property for the inhibited leaves.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
virtual ~DataSvc()
Standard Destructor.
CLID m_rootCLID
Integer Property corresponding to CLID of root entry.
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 StatusCode unregisterAddress(const std::string &fullPath)
IDataManagerSvc: Unregister object address from the data store.
virtual StatusCode traverseSubTree(const std::string &sub_tree_path, IDataStoreAgent *pAgent)
IDataManagerSvc: Analyze by traversing all data objects below the sub tree identified by its full pat...
virtual const id_type & identifier() const =0
Full identifier (or key)
Invalid path from root to object request failed.
Data service incident class.
virtual DataObject * object() const
Retrive object behind the link.
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.
A DataObject is the base class of any identifiable object on any data store.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
virtual StatusCode finalize()
Service initialization.
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
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.
virtual std::string rootName() const
IDataManagerSvc: Accessor for root event name.
DataSvcHelpers::RegistryEntry RegEntry
virtual StatusCode addPreLoadItem(const DataStoreItem &item)
Add an item to the preload list.
virtual CLID rootCLID() const
IDataManagerSvc: Accessor for root event CLID.
void makeHard(DataObject *pObject)
Initialize link as hard link.