19 #define DATASVC_DATASVC_CPP 41 #include "boost/utility/string_ref.hpp" 48 s.append( sr.data(), sr.size() );
52 boost::string_ref::size_type find( boost::string_ref
s,
char c,
size_t o )
54 if ( !s.empty() ) s.remove_prefix( o );
56 return r == boost::string_ref::npos ? r : ( r + o );
59 std::string to_string( boost::string_ref sr ) {
return {sr.data(), sr.size()}; }
67 #define CAST_REGENTRY( x, y ) dynamic_cast<x>( y ) 71 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) 72 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) ) 74 #define DEBMSG ON_DEBUG debug() 75 #define VERMSG ON_VERBOSE verbose() 86 if ( !node_entry )
return Status::INVALID_OBJECT;
88 if ( !parent )
return Status::INVALID_PARENT;
89 parent->
remove( node_entry );
98 if ( !
checkRoot() )
return Status::INVALID_ROOT;
100 if ( !entry )
return Status::INVALID_OBJECT;
102 if ( !parent )
return Status::INVALID_PARENT;
110 if ( !
checkRoot() )
return Status::INVALID_ROOT;
129 return entry ? entry->
traverseTree( pAgent ) : Status::INVALID_OBJECT;
135 if ( !
checkRoot() )
return Status::INVALID_ROOT;
202 if ( !pObject )
return Status::INVALID_OBJECT;
208 if ( !
checkRoot() )
return Status::INVALID_ROOT;
210 if ( !node_entry )
return Status::INVALID_OBJECT;
211 refpParent = node_entry->
parent();
218 if ( !pObject )
return Status::INVALID_OBJECT;
227 if ( !
checkRoot() )
return Status::INVALID_ROOT;
229 if ( !node_entry )
return Status::INVALID_OBJECT;
230 leaves = node_entry->
leaves();
237 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
244 if ( !
checkRoot() )
return Status::INVALID_ROOT;
245 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
251 auto sep = find( objPath,
SEPARATOR, 1 );
252 if ( sep == boost::string_ref::npos || objPath.substr( 0, sep ) !=
m_rootName.value() ) {
253 return Status::INVALID_PARENT;
261 if ( !par_entry )
return Status::INVALID_PARENT;
264 if ( sep > 0 && sep != boost::string_ref::npos ) {
265 auto p_path = objPath.substr( 0, sep );
266 auto o_path = objPath.substr( sep );
274 p_entry = par_entry->
findLeaf( p_path );
276 if ( !p_entry )
return Status::INVALID_PARENT;
279 StatusCode status = par_entry->
add( to_string( objPath ), pAddress );
280 return status.
isSuccess() ? status : Status::DOUBL_OBJ_PATH;
286 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
293 if ( !
checkRoot() )
return Status::INVALID_ROOT;
294 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
298 auto sep = find( objPath,
SEPARATOR, 1 );
299 if ( sep != boost::string_ref::npos && objPath.substr( 0, sep ) ==
m_rootName.value() ) {
302 return Status::INVALID_PARENT;
312 if ( sep > 0 && sep != boost::string_ref::npos ) {
316 if ( status.isSuccess() )
return status;
319 return Status::INVALID_PARENT;
338 if ( !
checkRoot() )
return Status::INVALID_ROOT;
341 if ( !objPath.empty() ) {
345 auto sep = find( objPath,
SEPARATOR, 1 );
346 if ( sep != boost::string_ref::npos ) {
347 return registerObject( objPath.substr( 0, sep ), objPath.substr( sep ), pObject );
350 return Status::INVALID_OBJ_PATH;
355 auto sep = find( objPath,
SEPARATOR, 1 );
356 if ( sep != boost::string_ref::npos ) {
357 auto p_path = objPath.substr( 0, sep );
358 auto o_path = objPath.substr( sep );
366 par_entry = node_entry->
findLeaf( p_path );
367 }
else if ( par_entry && !par_entry->
object() ) {
373 par_entry = node_entry->
findLeaf( p_path );
376 node_entry = par_entry;
384 status = node_entry->
add( to_string( objPath ), pObject );
389 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
397 status = Status::DOUBL_OBJ_PATH;
403 return Status::INVALID_PARENT;
413 if ( !pEntry )
return Status::INVALID_ROOT;
414 if ( !pEntry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
416 if ( !pParent )
return Status::INVALID_PARENT;
417 if ( pObject ) pObject->
addRef();
418 pParent->
remove( pEntry );
425 if ( !
checkRoot() )
return Status::INVALID_ROOT;
427 if ( !entry )
return Status::INVALID_OBJECT;
429 if ( !parent )
return Status::INVALID_PARENT;
430 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
432 if ( parent ) parent->
remove( entry );
452 return Status::DIR_NOT_EMPTY;
454 return Status::INVALID_OBJECT;
458 return Status::INVALID_PARENT;
460 return Status::INVALID_ROOT;
474 if ( pReg && path.empty() ) {
482 p.
append( path.data(), path.size() );
489 p.
append( path.data(), path.size() );
534 return Status::NO_ACCESS;
539 return Status::INVALID_OBJ_ADDR;
542 status = pLoader->
createObj( pAddress, pObject );
551 status = pLoader->
fillObjRefs( pAddress, pObject );
595 static constexpr
auto empty = boost::string_ref{};
600 if ( path.empty() || path ==
m_rootName.value() ) {
603 }
else if ( path.front() !=
SEPARATOR ) {
605 }
else if ( sep != boost::string_ref::npos ) {
609 if ( !status.isSuccess() )
return status;
612 path = path.substr( sep );
614 return Status::INVALID_OBJ_PATH;
620 if ( sep != boost::string_ref::npos ) {
621 if ( !parentObj->
object() ) {
623 if ( !status.
isSuccess() )
return status;
625 auto p_path = path.substr( 0, sep );
631 root_entry = parentObj->
findLeaf( p_path );
638 if ( !status.
isSuccess() )
return status;
640 if ( root_entry->
isSoft() ) {
646 }
else if ( path.empty() ) {
649 if ( !parentObj->
object() ) {
651 if ( !status.
isSuccess() )
return status;
654 pEntry = parentObj->
findLeaf( path );
658 pEntry = ( path.empty() ? parentObj : parentObj->
findLeaf( path ) );
663 if ( !pEntry )
return Status::INVALID_OBJ_PATH;
695 if ( !path.empty() ) pReg = root_entry->
find( path );
696 if ( !pReg )
return Status::INVALID_OBJ_PATH;
699 return ( !pObject ) ? Status::OBJ_NOT_LOADED : Status::IDataProviderSvc_NO_ERROR;
706 if ( !
checkRoot() )
return Status::INVALID_ROOT;
707 if ( path.empty() || path ==
m_rootName.value() ) {
709 return !pObject ? Status::OBJ_NOT_LOADED : Status::IDataProviderSvc_NO_ERROR;
718 return Status::INVALID_OBJ_ADDR;
732 return Status::INVALID_OBJECT;
736 return Status::INVALID_OBJECT;
740 return Status::INVALID_OBJ_ADDR;
744 return Status::NO_DATA_LOADER;
749 return Status::NO_ACCESS;
753 status = pLoader->
updateObj( pAddress, toUpdate );
760 throw GaudiException(
"std::exception in updateObject() " + pRegistry->
name() +
": " +
772 if ( !
checkRoot() )
return Status::INVALID_ROOT;
778 if ( !to_entry )
return Status::INVALID_OBJECT;
780 if ( sep > 0 && sep != boost::string_ref::npos ) {
786 StatusCode status = from_entry->
add( to_string( objPath ), to,
true );
787 return status.
isSuccess() ? Status::IDataProviderSvc_NO_ERROR : Status::DOUBL_OBJ_PATH;
791 return Status::INVALID_PARENT;
797 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
802 return linkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ), to );
808 if ( !
checkRoot() )
return Status::INVALID_ROOT;
813 if ( sep > 0 && sep != boost::string_ref::npos ) {
819 if ( status.isSuccess() )
return status;
820 return Status::INVALID_OBJ_PATH;
824 return Status::INVALID_PARENT;
830 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
833 return unlinkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ) );
839 if ( !
checkRoot() )
return Status::INVALID_ROOT;
870 if ( pObject && depth++ < load_depth ) {
873 for (
const auto& i : *dir ) {
876 if ( status.
isSuccess() && depth < load_depth ) {
891 int load_depth = i.depth();
892 if ( sc.
isSuccess() && load_depth > 1 ) {
907 error() <<
"Failed to access incident service." <<
endmsg;
923 error() <<
"Unable to reinitialize base class" <<
endmsg;
929 error() <<
"Failed to access incident service." <<
endmsg;
StatusCode registerAddress(boost::string_ref fullPath, IOpaqueAddress *pAddress) override
IDataManagerSvc: Register object address with the data store.
StatusCode unregisterAddress(boost::string_ref fullPath) override
IDataManagerSvc: Unregister object address from the data store.
Gaudi::Property< CLID > m_rootCLID
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
StatusCode unregisterObject(boost::string_ref fullPath) override
Unregister object from the data store.
constexpr static const auto FAILURE
StatusCode initialize() override
StatusCode linkObject(IRegistry *from, boost::string_ref objPath, DataObject *to) override
Add a link to another object.
std::unique_ptr< DataSvcHelpers::RegistryEntry > m_root
Pointer to root entry.
RegistryEntry * findLeaf(boost::string_ref path) const
Find identified leaf in this registry node.
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
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...
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.
Gaudi::Property< bool > m_forceLeaves
void setRegistry(IRegistry *pRegistry)
Set pointer to Registry.
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 retrieveEntry(DataSvcHelpers::RegistryEntry *pNode, boost::string_ref path, DataSvcHelpers::RegistryEntry *&pEntry)
Retrieve registry entry from store.
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
const Store & leaves() const
Access the leaves of the object.
bool isSoft() const
Is the link soft or hard.
Data provider interface definition.
void setAddress(IOpaqueAddress *pAddress) override
Set/Update Opaque address.
Description of the DataStoreItem class.
StatusCode registerObject(boost::string_ref parentPath, boost::string_ref objPath, DataObject *pObject) override
Register object with the data store.
StatusCode clearSubTree(boost::string_ref sub_tree_path) override
IDataManagerSvc: Remove all data objects below the sub tree identified by its full path name...
IRegistry * registry() const
Get pointer to Registry.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
TYPE * get() const
Get interface pointer.
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.
IRegistry * parent() const
Pointer to parent directory entry.
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 unlinkObject(IRegistry *from, boost::string_ref objPath) override
Remove a link to another object.
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...
StatusCode finalize() override
Service initialization.
StatusCode reinitialize() override
unsigned int CLID
Class ID definition.
IOpaqueAddress * address() const override
Retrieve opaque storage address.
#define CAST_REGENTRY(x, y)
constexpr static const auto SUCCESS
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
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.
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.
const StatusCode & ignore() const
Ignore/check StatusCode.
decltype(auto) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
StatusCode traverseSubTree(boost::string_ref sub_tree_path, IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects below the sub tree identified by its full pat...
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
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.
StatusCode remove(boost::string_ref name)
Remove an entry from the store.
bool isEmpty() const
Simple check if the Container is empty.
Data service incident class.
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Opaque address interface definition.
StatusCode retrieveObject(IRegistry *pDirectory, boost::string_ref path, DataObject *&pObject) override
Retrieve object from data store.
virtual IConversionSvc * getDataLoader(IRegistry *pReg)
Retrieve customizable data loader according to registry entry to be retrieved.
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.
StatusCode findObject(boost::string_ref fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
std::vector< DataStoreItem > m_preLoads
Items to be pre-loaded.
virtual DataObject * createDefaultObject() const
Create default objects in case forced creation of leaves is requested.
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
DataObject * handleDataFault(IRegistry *pReg, boost::string_ref path="")
Invoke data fault handling if enabled.
void makeHard(DataObject *pObject)
Initialize link as hard link.