20 #define TSDATASVC_DATASVC_CPP 46 #define STD_LOCK_GUARD_MACRO std::lock_guard<tsDataSvcMutex> lock( m_accessMutex ); 57 s.append( sr.data(), sr.size() );
61 boost::string_ref::size_type find( boost::string_ref
s,
char c,
size_t o )
63 if ( !s.empty() ) s.remove_prefix( o );
65 return r == boost::string_ref::npos ? r : ( r + o );
76 #define CAST_REGENTRY( x, y ) dynamic_cast<x>( y ) 80 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) 81 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) ) 83 #define DEBMSG ON_DEBUG debug() 84 #define VERMSG ON_VERBOSE verbose() 95 if ( !node_entry )
return INVALID_OBJECT;
97 if ( !parent )
return INVALID_PARENT;
98 parent->
remove( node_entry );
109 if ( !entry )
return INVALID_OBJECT;
111 if ( !parent )
return INVALID_PARENT;
142 if ( !entry )
return INVALID_OBJECT;
209 if ( pDataLoader ) pDataLoader->
addRef();
222 if ( !pObject )
return INVALID_OBJECT;
231 if ( !node_entry )
return INVALID_OBJECT;
232 refpParent = node_entry->
parent();
240 if ( !pObject )
return INVALID_OBJECT;
252 if ( !node_entry )
return INVALID_OBJECT;
261 if ( fullPath.empty() )
return INVALID_OBJ_PATH;
280 if ( objPath.empty() )
return INVALID_OBJ_PATH;
285 auto sep = find( objPath,
SEPARATOR, 1 );
286 if ( sep == boost::string_ref::npos || objPath.substr( 0, sep ) !=
m_rootName.value() ) {
287 return INVALID_PARENT;
295 if ( !par_entry )
return INVALID_PARENT;
297 if ( sep > 0 && sep != boost::string_ref::npos ) {
298 auto p_path = objPath.substr( 0, sep );
299 auto o_path = objPath.substr( sep );
307 p_entry = par_entry->
findLeaf( p_path );
309 if ( !p_entry )
return INVALID_PARENT;
313 return status.
isSuccess() ? status : DOUBL_OBJ_PATH;
319 if ( fullPath.empty() )
return INVALID_OBJ_PATH;
339 if ( objPath.empty() )
return INVALID_OBJ_PATH;
344 auto sep = find( objPath,
SEPARATOR, 1 );
345 if ( sep == boost::string_ref::npos || objPath.substr( 0, sep ) !=
m_rootName.value() ) {
346 return INVALID_PARENT;
358 if ( sep > 0 && sep != boost::string_ref::npos ) {
362 if ( status.isSuccess() )
return status;
365 return INVALID_PARENT;
404 if ( !objPath.empty() ) {
408 auto sep = find( objPath,
SEPARATOR, 1 );
409 if ( sep != boost::string_ref::npos ) {
410 return registerObject( objPath.substr( 0, sep ), objPath.substr( sep ), pObject );
413 return INVALID_OBJ_PATH;
418 auto sep = find( objPath,
SEPARATOR, 1 );
419 if ( sep != boost::string_ref::npos ) {
420 auto p_path = objPath.substr( 0, sep );
421 auto o_path = objPath.substr( sep );
429 par_entry = node_entry->
findLeaf( p_path );
430 }
else if ( par_entry && !par_entry->
object() ) {
436 par_entry = node_entry->
findLeaf( p_path );
439 node_entry = par_entry;
447 status = node_entry->
add(
to_string( objPath ), pObject );
452 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
461 status = DOUBL_OBJ_PATH;
467 return INVALID_PARENT;
477 if ( !pEntry )
return INVALID_ROOT;
478 if ( !pEntry->
isEmpty() )
return DIR_NOT_EMPTY;
480 if ( !pParent )
return INVALID_PARENT;
481 if ( pObject ) pObject->
addRef();
482 pParent->
remove( pEntry );
505 if ( !entry )
return INVALID_OBJECT;
507 if ( !parent )
return INVALID_PARENT;
508 if ( !entry->
isEmpty() )
return DIR_NOT_EMPTY;
510 if ( parent ) parent->
remove( entry );
522 if ( !entry )
return INVALID_OBJECT;
523 if ( !entry->
isEmpty() )
return DIR_NOT_EMPTY;
530 return INVALID_PARENT;
545 if ( pReg && path.empty() ) {
552 p.
append( path.data(), path.size() );
559 p.
append( path.data(), path.size() );
564 if ( pLeaf )
return pLeaf->
object();
590 return NO_DATA_LOADER;
596 return INVALID_OBJ_ADDR;
613 return INVALID_OBJ_ADDR;
616 status = pLoader->
createObj( pAddress, pObject );
617 if ( status.isSuccess() ) {
625 status = pLoader->
fillObjRefs( pAddress, pObject );
640 if ( !status.isSuccess() ) {
662 if ( sep == boost::string_ref::npos )
return INVALID_OBJ_PATH;
666 if ( !status.
isSuccess() )
return status;
670 if ( sep != boost::string_ref::npos ) {
671 auto p_path = path.substr( 0, sep );
672 auto o_path = path.substr( sep );
673 if ( !parentObj->
object() ) {
675 if ( !status.
isSuccess() )
return status;
682 root_entry = parentObj->
findLeaf( p_path );
689 if ( !status.
isSuccess() )
return status;
691 if ( root_entry->
isSoft() ) {
697 }
else if ( path.empty() ) {
700 if ( !parentObj->
object() ) {
702 if ( !status.
isSuccess() )
return status;
705 pEntry = parentObj->
findLeaf( path );
709 pEntry = ( path.empty() ? parentObj : parentObj->
findLeaf( path ) );
714 status = INVALID_OBJ_PATH;
715 }
else if ( !pEntry->
object() ) {
785 if ( !path.empty() ) pReg = root_entry->
find( path );
786 if ( !pReg )
return INVALID_OBJ_PATH;
789 return pObject ? IDataProviderSvc_NO_ERROR : OBJ_NOT_LOADED;
800 return !pObject ? OBJ_NOT_LOADED : IDataProviderSvc_NO_ERROR;
805 return findObject( static_cast<IRegistry*>(
nullptr ), path, pObject );
819 return findObject( parentPath, itemToPath( item ), pObject );
825 return findObject( parentObj, itemToPath( item ), pObject );
846 return INVALID_OBJ_ADDR;
861 return INVALID_OBJECT;
865 return INVALID_OBJECT;
869 return INVALID_OBJ_ADDR;
873 return NO_DATA_LOADER;
881 status = pLoader->
updateObj( pAddress, toUpdate );
882 if ( status.isSuccess() ) {
888 throw GaudiException(
"std::exception in updateObject() " + pRegistry->
name() +
": " +
923 if ( !to_entry )
return INVALID_OBJECT;
925 if ( sep > 0 && sep != boost::string_ref::npos ) {
932 return status.
isSuccess() ? IDataProviderSvc_NO_ERROR : DOUBL_OBJ_PATH;
936 return INVALID_PARENT;
943 if ( fullPath.empty() )
return INVALID_OBJ_PATH;
946 return linkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ), to );
964 if ( from_entry )
return linkObject( from_entry, objPath, to );
966 return INVALID_PARENT;
978 if ( sep > 0 && sep != boost::string_ref::npos ) {
984 return status.
isSuccess() ? status : INVALID_OBJ_PATH;
988 return INVALID_PARENT;
994 if ( fullPath.empty() )
return INVALID_OBJ_PATH;
999 return unlinkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ) );
1013 if ( !
checkRoot() )
return INVALID_ROOT;
1056 if ( pObject && depth++ < load_depth ) {
1059 for (
const auto& i : *dir ) {
1062 if ( status.
isSuccess() && depth < load_depth ) {
1077 int load_depth = i.depth();
1078 if ( sc.
isSuccess() && load_depth > 1 ) {
1093 error() <<
"Failed to access incident service." <<
endmsg;
1113 error() <<
"Unable to reinitialize base class" <<
endmsg;
1119 error() <<
"Failed to access incident service." <<
endmsg;
StatusCode initialize() override
string to_string(const T &value)
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.
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
StatusCode setRoot(std::string root_name, DataObject *pRootObj) override
Initialize data store for new event by giving new event path and root object.
StatusCode finalize() override
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
StatusCode linkObject(IRegistry *from, boost::string_ref objPath, DataObject *to) override
Add a link to another object.
StatusCode unregisterObject(boost::string_ref fullPath) override
Unregister object from the data store.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
StatusCode traverseTree(IDataStoreAgent *pAgent, int level=0)
traverse data tree
StatusCode traverseTree(IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
bool isSuccess() const
Test for a status code of SUCCESS.
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
StatusCode unregisterAddress(boost::string_ref fullPath) override
IDataManagerSvc: Unregister object address from the data store.
Gaudi::Property< std::string > m_accessName
Gaudi::Property< CLID > m_rootCLID
StatusCode retrieveObject(IRegistry *pDirectory, boost::string_ref path, DataObject *&pObject) override
Retrieve object from data store.
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
~TsDataSvc() override
Standard Destructor.
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 initialize() override
Service initialization.
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
virtual IConversionSvc * getDataLoader(IRegistry *pReg)
Retrieve customizable data loader according to registry entry to be retrieved.
const Store & leaves() const
Access the leaves of the object.
bool isSoft() const
Is the link soft or hard.
IConversionSvc * m_dataLoader
Pointer to data loader service.
StatusCode setDataLoader(IConversionSvc *svc, IDataProviderSvc *dpsvc=nullptr) override
IDataManagerSvc: IDataManagerSvc: Pass a default data loader to the service and optionally a data pro...
Data provider interface definition.
void setAddress(IOpaqueAddress *pAddress) override
Set/Update Opaque address.
Description of the DataStoreItem class.
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.
StatusCode resetPreLoad() override
Clear the preload list.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode registerAddress(boost::string_ref fullPath, IOpaqueAddress *pAddress) override
IDataManagerSvc: Register object address with the data store.
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 preLoad() override
load all preload items of the list
StatusCode findObject(boost::string_ref fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
IIncidentSvc * m_incidentSvc
Pointer to incident service.
virtual const id_type & identifier() const =0
Full identifier (or key)
DataSvcHelpers::RegistryEntry * m_root
Pointer to root entry.
This class is used for returning status codes from appropriate routines.
LoadItems m_preLoads
Items to be pre-loaded.
IRegistry * parent() const
Pointer to parent directory entry.
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
DataSvcHelpers::RegistryEntry RegEntry
void setDataSvc(IDataProviderSvc *s)
Set the transient data store.
const std::string & rootName() const override
IDataManagerSvc: Accessor for root event name.
Gaudi::Property< bool > m_enableAccessHdlr
StatusCode reinitialize() override
Service initialization.
StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves) override
IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
StatusCode unlinkObject(IRegistry *from, boost::string_ref objPath) override
Remove a link to another object.
StatusCode reinitialize() override
unsigned int CLID
Class ID definition.
IOpaqueAddress * address() const override
Retrieve opaque storage address.
StatusCode retrieveEntry(DataSvcHelpers::RegistryEntry *pNode, boost::string_ref path, DataSvcHelpers::RegistryEntry *&pEntry)
Retrieve registry entry from store.
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
StatusCode add(std::string name, DataObject *pObject, bool is_soft=false)
Add entry to data store.
virtual DataObject * createDefaultObject() const
Create default objects in case forced creation of leaves is requested.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
virtual unsigned long release()=0
Release Interface instance.
StatusCode finalize() override
Service initialization.
Generic data agent interface.
StatusCode clearSubTree(boost::string_ref sub_tree_path) override
IDataManagerSvc: Remove all data objects below the sub tree identified by its full path name...
RegistryEntry * parentEntry()
Pointer to parent registry entry.
virtual StatusCode i_setRoot(std::string root_name, DataObject *pRootObj)
Initialize data store for new event by giving new event path and root object.
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
bool checkRoot()
Check if root path is valid.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
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...
Gaudi::Property< bool > m_forceLeaves
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)
StatusCode remove(boost::string_ref name)
Remove an entry from the store.
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
bool isEmpty() const
Simple check if the Container is empty.
Data service incident class.
Opaque address interface definition.
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
Gaudi::Property< std::vector< std::string > > m_inhibitPathes
DataObject * handleDataFault(IRegistry *pReg, boost::string_ref path={})
Invoke data fault handling if enabled.
A DataObject is the base class of any identifiable object on any data store.
#define STD_LOCK_GUARD_MACRO
#define CAST_REGENTRY(x, y)
virtual StatusCode loadObject(IRegistry *pNode)
Invoke Persistency service to create transient object from its persistent representation.
StatusCode registerObject(boost::string_ref fullPath, DataObject *pObject) override
Register object with the data store.
StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
decltype(std::declval< TP >()+std::declval< T >()) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
Gaudi::Property< bool > m_enableFaultHdlr
Gaudi::Property< std::string > m_faultName
Gaudi::Property< std::string > m_rootName
void makeHard(DataObject *pObject)
Initialize link as hard link.