Go to the documentation of this file.
30 #define TSDATASVC_DATASVC_CPP
53 #define STD_LOCK_GUARD_MACRO std::scoped_lock lock{ m_accessMutex };
58 s.append(
sr.data(),
sr.size() );
62 std::string_view::size_type find( std::string_view
s,
char c,
size_t o ) {
63 if ( !
s.empty() )
s.remove_prefix( o );
65 return r == std::string_view::npos ? r : ( r + o );
74 #define CAST_REGENTRY( x, y ) dynamic_cast<x>( y )
78 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
79 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
81 #define DEBMSG ON_DEBUG debug()
82 #define VERMSG ON_VERBOSE verbose()
96 if ( !node_entry )
return Status::INVALID_OBJECT;
98 if ( !parent )
return Status::INVALID_PARENT;
99 parent->
remove( node_entry );
107 if ( !
checkRoot() )
return Status::INVALID_ROOT;
109 if ( !entry )
return Status::INVALID_OBJECT;
111 if ( !parent )
return Status::INVALID_PARENT;
118 if ( !
checkRoot() )
return Status::INVALID_ROOT;
135 if ( !
checkRoot() )
return Status::INVALID_ROOT;
137 if ( !entry )
return Status::INVALID_OBJECT;
144 if ( !
checkRoot() )
return Status::INVALID_ROOT;
198 if ( pDataLoader ) pDataLoader->
addRef();
207 if ( !pObject )
return Status::INVALID_OBJECT;
213 if ( !
checkRoot() )
return Status::INVALID_ROOT;
215 if ( !node_entry )
return Status::INVALID_OBJECT;
216 refpParent = node_entry->
parent();
222 if ( !pObject )
return Status::INVALID_OBJECT;
230 if ( !pRegistry )
return Status::INVALID_OBJECT;
232 if ( !node_entry )
return Status::INVALID_OBJECT;
241 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
247 if ( !
checkRoot() )
return Status::INVALID_ROOT;
248 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
251 auto sep = find( objPath,
SEPARATOR, 1 );
252 if ( sep == std::string_view::npos || objPath.substr( 0, sep ) !=
m_rootName.
value() ) {
253 return Status::INVALID_PARENT;
259 if ( !par_entry )
return Status::INVALID_PARENT;
261 if ( sep > 0 && sep != std::string_view::npos ) {
262 auto p_path = objPath.substr( 0, sep );
263 auto o_path = objPath.substr( sep );
271 p_entry = par_entry->
findLeaf( p_path );
273 if ( !p_entry )
return Status::INVALID_PARENT;
277 return status.
isSuccess() ? status : Status::DOUBL_OBJ_PATH;
282 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
288 if ( !
checkRoot() )
return Status::INVALID_ROOT;
290 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
293 auto sep = find( objPath,
SEPARATOR, 1 );
294 if ( sep == std::string_view::npos || objPath.substr( 0, sep ) !=
m_rootName.
value() ) {
295 return Status::INVALID_PARENT;
305 if ( sep > 0 && sep != std::string_view::npos ) {
312 return Status::INVALID_PARENT;
329 if ( !
checkRoot() )
return Status::INVALID_ROOT;
331 if ( !objPath.empty() ) {
333 auto sep = find( objPath,
SEPARATOR, 1 );
334 if ( sep != std::string_view::npos ) {
335 return registerObject( objPath.substr( 0, sep ), objPath.substr( sep ), pObject );
338 return Status::INVALID_OBJ_PATH;
343 auto sep = find( objPath,
SEPARATOR, 1 );
344 if ( sep != std::string_view::npos ) {
345 auto p_path = objPath.substr( 0, sep );
346 auto o_path = objPath.substr( sep );
354 par_entry = node_entry->
findLeaf( p_path );
355 }
else if ( par_entry && !par_entry->
object() ) {
361 par_entry = node_entry->
findLeaf( p_path );
364 node_entry = par_entry;
377 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
386 status = Status::DOUBL_OBJ_PATH;
392 return Status::INVALID_PARENT;
401 if ( !pEntry )
return Status::INVALID_ROOT;
402 if ( !pEntry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
404 if ( !pParent )
return Status::INVALID_PARENT;
406 pParent->
remove( pEntry );
412 if ( !
checkRoot() )
return Status::INVALID_ROOT;
414 if ( !entry )
return Status::INVALID_OBJECT;
416 if ( !parent )
return Status::INVALID_PARENT;
417 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
419 if ( parent ) parent->
remove( entry );
425 if ( !
checkRoot() )
return Status::INVALID_ROOT;
430 if ( !entry )
return Status::INVALID_OBJECT;
431 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
437 return Status::INVALID_PARENT;
445 if ( pReg &&
path.empty() ) {
464 if ( pLeaf )
return pLeaf->
object();
488 return Status::NO_DATA_LOADER;
494 return Status::INVALID_OBJ_ADDR;
511 return Status::INVALID_OBJ_ADDR;
514 status = pLoader->
createObj( pAddress, pObject );
523 status = pLoader->
fillObjRefs( pAddress, pObject );
558 if ( sep == std::string_view::npos )
return Status::INVALID_OBJ_PATH;
562 if ( !status.
isSuccess() )
return status;
566 if ( sep != std::string_view::npos ) {
567 auto p_path =
path.substr( 0, sep );
568 auto o_path =
path.substr( sep );
569 if ( !parentObj->
object() ) {
571 if ( !status.
isSuccess() )
return status;
578 root_entry = parentObj->
findLeaf( p_path );
585 if ( !status.
isSuccess() )
return status;
590 return Status::INVALID_OBJ_PATH;
591 }
else if (
path.empty() ) {
594 if ( !parentObj->
object() ) {
596 if ( !status.
isSuccess() )
return status;
608 status = Status::INVALID_OBJ_PATH;
609 }
else if ( !pEntry->
object() ) {
643 if ( !pReg )
return Status::INVALID_OBJ_PATH;
646 return pObject ? Status::IDataProviderSvc_NO_ERROR : Status::OBJ_NOT_LOADED;
653 if ( !
checkRoot() )
return Status::INVALID_ROOT;
656 return !pObject ? Status::OBJ_NOT_LOADED : Status::IDataProviderSvc_NO_ERROR;
663 if ( !pRegistry )
return Status::INVALID_OBJ_ADDR;
671 if ( !toUpdate )
return Status::INVALID_OBJECT;
673 if ( !pRegistry )
return Status::INVALID_OBJECT;
675 if ( !pAddress )
return Status::INVALID_OBJ_ADDR;
678 if ( !pLoader )
return Status::NO_DATA_LOADER;
685 status = pLoader->updateObj( pAddress, toUpdate );
686 if ( status.
isSuccess() ) { status = pLoader->updateObjRefs( pAddress, toUpdate ); }
690 throw GaudiException(
"std::exception in updateObject() " + pRegistry->
name() +
": " +
702 if ( !
checkRoot() )
return Status::INVALID_ROOT;
708 if ( !to_entry )
return Status::INVALID_OBJECT;
710 if ( sep > 0 && sep != std::string_view::npos ) {
717 return status.
isSuccess() ? Status::IDataProviderSvc_NO_ERROR : Status::DOUBL_OBJ_PATH;
720 return Status::INVALID_PARENT;
725 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
728 return linkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ), to );
737 if ( !
checkRoot() )
return Status::INVALID_ROOT;
742 if ( sep > 0 && sep != std::string_view::npos ) {
748 return status.
isSuccess() ? status : Status::INVALID_OBJ_PATH;
751 return Status::INVALID_PARENT;
756 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
759 return unlinkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ) );
764 if ( !
checkRoot() )
return Status::INVALID_ROOT;
791 if ( pObject && depth++ < load_depth ) {
794 for (
const auto& i : *dir ) {
809 int load_depth = i.depth();
821 if ( !sc.
isSuccess() ) { error() <<
"Failed to access incident service." <<
endmsg; }
835 error() <<
"Unable to reinitialize base class" <<
endmsg;
841 error() <<
"Failed to access incident service." <<
endmsg;
virtual StatusCode loadObject(IRegistry *pNode)
Invoke Persistency service to create transient object from its persistent representation.
std::vector< DataStoreItem > m_preLoads
Items to be pre-loaded.
Gaudi::Property< std::vector< std::string > > m_inhibitPathes
#define CAST_REGENTRY(x, y)
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
std::unique_ptr< DataSvcHelpers::RegistryEntry > m_root
Pointer to root entry.
void setRegistry(IRegistry *pRegistry)
Set pointer to Registry.
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
StatusCode initialize() override
void setAddress(IOpaqueAddress *pAddress) override
Set/Update Opaque address.
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
StatusCode setDataLoader(IConversionSvc *svc, IDataProviderSvc *dpsvc=nullptr) override
IDataManagerSvc: IDataManagerSvc: Pass a default data loader to the service and optionally a data pro...
RegistryEntry * findLeaf(std::string_view path) const
Find identified leaf in this registry node.
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
bool isSoft() const
Is the link soft or hard.
StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *to) override
Add a link to another object.
StatusCode preLoad() override
load all preload items of the list
virtual unsigned long release()
release reference to object
virtual IConversionSvc * getDataLoader(IRegistry *pReg)
Retrieve customizable data loader according to registry entry to be retrieved.
bool checkRoot()
Check if root path is valid.
#define STD_LOCK_GUARD_MACRO
StatusCode finalize() override
Service initialization.
Gaudi::Property< bool > m_enableFaultHdlr
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
void makeHard(DataObject *pObject)
Initialize link as hard link.
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, std::string_view path={})
Invoke data fault handling if enabled.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
StatusCode registerObject(std::string_view parentPath, std::string_view objPath, DataObject *pObject) override
Register object with the data store.
StatusCode initialize() override
Service initialization.
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
ServiceHandle< IIncidentSvc > m_incidentSvc
Handle to incident service.
StatusCode finalize() override
Gaudi::Property< bool > m_forceLeaves
StatusCode setRoot(std::string root_name, DataObject *pRootObj) override
Initialize data store for new event by giving new event path and root object.
virtual DataObject * createDefaultObject() const
Create default objects in case forced creation of leaves is requested.
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
IOpaqueAddress * address() const override
Retrieve opaque storage address.
virtual const name_type & name() const =0
Name of the directory (or key)
Gaudi::Property< std::string > m_rootName
const Store & leaves() const
Access the leaves of the object.
DataObject * object() const override
Retrive object behind the link.
StatusCode reinitialize() override
Service initialization.
const std::string & name() const override
Retrieve name of the service
StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode remove(std::string_view name)
Remove an entry from the store.
void setObject(DataObject *obj)
Set/Update object address.
const ValueType & value() const
StatusCode traverseSubTree(std::string_view sub_tree_path, IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects below the sub tree identified by its full pat...
DataSvcHelpers::RegistryEntry RegEntry
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
bool isEmpty() const
Simple check if the Container is empty.
TsDataSvc(const std::string &name, ISvcLocator *svc)
constructor
unsigned int CLID
Class ID definition.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Gaudi::Property< std::string > m_faultName
IRegistry * parent() const
Pointer to parent directory entry.
void setDataSvc(IDataProviderSvc *s)
Set the transient data store.
StatusCode retrieve(T *&service) const override
Do the real retrieval of the Service.
StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress) override
IDataManagerSvc: Register object address with the data store.
StatusCode retrieveEntry(DataSvcHelpers::RegistryEntry *pNode, std::string_view path, DataSvcHelpers::RegistryEntry *&pEntry)
Retrieve registry entry from store.
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
StatusCode traverseTree(IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
const std::string & rootName() const override
IDataManagerSvc: Accessor for root event name.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
StatusCode unregisterAddress(std::string_view fullPath) override
IDataManagerSvc: Unregister object address from the data store.
StatusCode resetPreLoad() override
Clear the preload list.
constexpr static const auto SUCCESS
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Gaudi::Property< std::string > m_accessName
IConversionSvc * m_dataLoader
Pointer to data loader service.
StatusCode unlinkObject(IRegistry *from, std::string_view objPath) override
Remove a link to another object.
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
virtual DataObject * object() const =0
Retrieve object behind the link.
StatusCode add(std::string name, DataObject *pObject, bool is_soft=false)
Add entry to data store.
virtual const id_type & identifier() const =0
Full identifier (or key)
StatusCode reinitialize() override
StatusCode unregisterObject(std::string_view fullPath) override
Unregister object from the data store.
const std::string & identifier() const override
Full identifier (or key)
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves) override
IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object.
constexpr static const auto FAILURE
virtual unsigned long release()=0
Release Interface instance.
StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject) override
Retrieve object from data store.
StatusCode traverseTree(IDataStoreAgent *pAgent, int level=0)
traverse data tree
decltype(auto) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
IRegistry * registry() const
Get pointer to Registry.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
virtual unsigned long addRef()
Add reference to object.
Gaudi::Property< CLID > m_rootCLID
Gaudi::Property< bool > m_enableAccessHdlr
StatusCode clearSubTree(std::string_view 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.