20 #define TSDATASVC_DATASVC_CPP 44 #define STD_LOCK_GUARD_MACRO std::lock_guard<tsDataSvcMutex> lock( m_accessMutex ); 51 s.append( sr.data(), sr.size() );
55 boost::string_ref::size_type find( boost::string_ref
s,
char c,
size_t o )
57 if ( !s.empty() ) s.remove_prefix( o );
59 return r == boost::string_ref::npos ? r : ( r + o );
68 #define CAST_REGENTRY( x, y ) dynamic_cast<x>( y ) 72 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) 73 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) ) 75 #define DEBMSG ON_DEBUG debug() 76 #define VERMSG ON_VERBOSE verbose() 87 if ( !node_entry )
return Status::INVALID_OBJECT;
89 if ( !parent )
return Status::INVALID_PARENT;
90 parent->
remove( node_entry );
99 if ( !
checkRoot() )
return Status::INVALID_ROOT;
101 if ( !entry )
return Status::INVALID_OBJECT;
103 if ( !parent )
return Status::INVALID_PARENT;
111 if ( !
checkRoot() )
return Status::INVALID_ROOT;
130 if ( !
checkRoot() )
return Status::INVALID_ROOT;
132 if ( !entry )
return Status::INVALID_OBJECT;
140 if ( !
checkRoot() )
return Status::INVALID_ROOT;
199 if ( pDataLoader ) pDataLoader->
addRef();
211 if ( !pObject )
return Status::INVALID_OBJECT;
218 if ( !
checkRoot() )
return Status::INVALID_ROOT;
220 if ( !node_entry )
return Status::INVALID_OBJECT;
221 refpParent = node_entry->
parent();
228 if ( !pObject )
return Status::INVALID_OBJECT;
237 if ( !pRegistry )
return Status::INVALID_OBJECT;
239 if ( !node_entry )
return Status::INVALID_OBJECT;
249 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
256 if ( !
checkRoot() )
return Status::INVALID_ROOT;
257 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
262 auto sep = find( objPath,
SEPARATOR, 1 );
263 if ( sep == boost::string_ref::npos || objPath.substr( 0, sep ) !=
m_rootName.value() ) {
264 return Status::INVALID_PARENT;
272 if ( !par_entry )
return Status::INVALID_PARENT;
274 if ( sep > 0 && sep != boost::string_ref::npos ) {
275 auto p_path = objPath.substr( 0, sep );
276 auto o_path = objPath.substr( sep );
284 p_entry = par_entry->
findLeaf( p_path );
286 if ( !p_entry )
return Status::INVALID_PARENT;
289 StatusCode status = par_entry->
add( objPath.to_string(), pAddress );
290 return status.
isSuccess() ? status : Status::DOUBL_OBJ_PATH;
296 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
303 if ( !
checkRoot() )
return Status::INVALID_ROOT;
305 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
310 auto sep = find( objPath,
SEPARATOR, 1 );
311 if ( sep == boost::string_ref::npos || objPath.substr( 0, sep ) !=
m_rootName.value() ) {
312 return Status::INVALID_PARENT;
324 if ( sep > 0 && sep != boost::string_ref::npos ) {
328 if ( status.isSuccess() )
return status;
331 return Status::INVALID_PARENT;
350 if ( !
checkRoot() )
return Status::INVALID_ROOT;
352 if ( !objPath.empty() ) {
356 auto sep = find( objPath,
SEPARATOR, 1 );
357 if ( sep != boost::string_ref::npos ) {
358 return registerObject( objPath.substr( 0, sep ), objPath.substr( sep ), pObject );
361 return Status::INVALID_OBJ_PATH;
366 auto sep = find( objPath,
SEPARATOR, 1 );
367 if ( sep != boost::string_ref::npos ) {
368 auto p_path = objPath.substr( 0, sep );
369 auto o_path = objPath.substr( sep );
377 par_entry = node_entry->
findLeaf( p_path );
378 }
else if ( par_entry && !par_entry->
object() ) {
384 par_entry = node_entry->
findLeaf( p_path );
387 node_entry = par_entry;
395 status = node_entry->
add( objPath.to_string(), pObject );
400 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
409 status = Status::DOUBL_OBJ_PATH;
415 return Status::INVALID_PARENT;
425 if ( !pEntry )
return Status::INVALID_ROOT;
426 if ( !pEntry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
428 if ( !pParent )
return Status::INVALID_PARENT;
429 if ( pObject ) pObject->
addRef();
430 pParent->
remove( pEntry );
437 if ( !
checkRoot() )
return Status::INVALID_ROOT;
439 if ( !entry )
return Status::INVALID_OBJECT;
441 if ( !parent )
return Status::INVALID_PARENT;
442 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
444 if ( parent ) parent->
remove( entry );
451 if ( !
checkRoot() )
return Status::INVALID_ROOT;
456 if ( !entry )
return Status::INVALID_OBJECT;
457 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
464 return Status::INVALID_PARENT;
473 if ( pReg && path.empty() ) {
480 p.
append( path.data(), path.size() );
487 p.
append( path.data(), path.size() );
492 if ( pLeaf )
return pLeaf->
object();
518 return Status::NO_DATA_LOADER;
524 return Status::INVALID_OBJ_ADDR;
541 return Status::INVALID_OBJ_ADDR;
544 status = pLoader->
createObj( pAddress, pObject );
553 status = pLoader->
fillObjRefs( pAddress, pObject );
590 if ( sep == boost::string_ref::npos )
return Status::INVALID_OBJ_PATH;
594 if ( !status.
isSuccess() )
return status;
598 if ( sep != boost::string_ref::npos ) {
599 auto p_path = path.substr( 0, sep );
600 auto o_path = path.substr( sep );
601 if ( !parentObj->
object() ) {
603 if ( !status.
isSuccess() )
return status;
610 root_entry = parentObj->
findLeaf( p_path );
617 if ( !status.
isSuccess() )
return status;
619 if ( root_entry->
isSoft() ) {
625 }
else if ( path.empty() ) {
628 if ( !parentObj->
object() ) {
630 if ( !status.
isSuccess() )
return status;
633 pEntry = parentObj->
findLeaf( path );
637 pEntry = ( path.empty() ? parentObj : parentObj->
findLeaf( path ) );
642 status = Status::INVALID_OBJ_PATH;
643 }
else if ( !pEntry->
object() ) {
678 if ( !path.empty() ) pReg = root_entry->
find( path );
679 if ( !pReg )
return Status::INVALID_OBJ_PATH;
682 return pObject ? Status::IDataProviderSvc_NO_ERROR : Status::OBJ_NOT_LOADED;
690 if ( !
checkRoot() )
return Status::INVALID_ROOT;
693 return !pObject ? Status::OBJ_NOT_LOADED : Status::IDataProviderSvc_NO_ERROR;
701 if ( !pRegistry )
return Status::INVALID_OBJ_ADDR;
710 if ( !toUpdate )
return Status::INVALID_OBJECT;
712 if ( !pRegistry )
return Status::INVALID_OBJECT;
714 if ( !pAddress )
return Status::INVALID_OBJ_ADDR;
717 if ( !pLoader )
return Status::NO_DATA_LOADER;
724 status = pLoader->updateObj( pAddress, toUpdate );
726 status = pLoader->updateObjRefs( pAddress, toUpdate );
731 throw GaudiException(
"std::exception in updateObject() " + pRegistry->
name() +
": " +
744 if ( !
checkRoot() )
return Status::INVALID_ROOT;
750 if ( !to_entry )
return Status::INVALID_OBJECT;
752 if ( sep > 0 && sep != boost::string_ref::npos ) {
758 StatusCode status = from_entry->
add( objPath.to_string(), to, true );
759 return status.
isSuccess() ? Status::IDataProviderSvc_NO_ERROR : Status::DOUBL_OBJ_PATH;
763 return Status::INVALID_PARENT;
769 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
772 return linkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ), to );
782 if ( !
checkRoot() )
return Status::INVALID_ROOT;
787 if ( sep > 0 && sep != boost::string_ref::npos ) {
793 return status.
isSuccess() ? status : Status::INVALID_OBJ_PATH;
797 return Status::INVALID_PARENT;
803 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
808 return unlinkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ) );
814 if ( !
checkRoot() )
return Status::INVALID_ROOT;
845 if ( pObject && depth++ < load_depth ) {
848 for (
const auto& i : *dir ) {
851 if ( status.
isSuccess() && depth < load_depth ) {
866 int load_depth = i.depth();
867 if ( sc.
isSuccess() && load_depth > 1 ) {
882 error() <<
"Failed to access incident service." <<
endmsg;
902 error() <<
"Unable to reinitialize base class" <<
endmsg;
908 error() <<
"Failed to access incident service." <<
endmsg;
constexpr static const auto FAILURE
StatusCode initialize() override
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.
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.
void setRegistry(IRegistry *pRegistry)
Set pointer to Registry.
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.
IRegistry * registry() const
Get pointer to Registry.
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)
This class is used for returning status codes from appropriate routines.
IRegistry * parent() const
Pointer to parent directory entry.
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.
constexpr static const auto SUCCESS
virtual DataObject * object() const =0
Retrieve object behind the link.
Definition of an entry in the transient data store.
std::unique_ptr< DataSvcHelpers::RegistryEntry > m_root
Pointer to root entry.
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...
std::vector< DataStoreItem > m_preLoads
Items to be pre-loaded.
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.
const StatusCode & ignore() const
Ignore/check StatusCode.
decltype(auto) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
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.
StatusCode registerObject(boost::string_ref parentPath, boost::string_ref objPath, DataObject *pObject) override
Register object with the data store.
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 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.
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.