20 #define TSDATASVC_DATASVC_CPP 44 #define STD_LOCK_GUARD_MACRO std::lock_guard<tsDataSvcMutex> lock( m_accessMutex ); 49 s.append(
sr.data(),
sr.size() );
53 std::string_view::size_type find( std::string_view
s,
char c,
size_t o ) {
54 if ( !
s.empty() )
s.remove_prefix( o );
56 return r == std::string_view::npos ? r : ( r + o );
65 #define CAST_REGENTRY( x, y ) dynamic_cast<x>( y ) 69 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) 70 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) ) 72 #define DEBMSG ON_DEBUG debug() 73 #define VERMSG ON_VERBOSE verbose() 83 if ( !node_entry )
return Status::INVALID_OBJECT;
85 if ( !parent )
return Status::INVALID_PARENT;
86 parent->
remove( node_entry );
94 if ( !
checkRoot() )
return Status::INVALID_ROOT;
96 if ( !entry )
return Status::INVALID_OBJECT;
98 if ( !parent )
return Status::INVALID_PARENT;
105 if ( !
checkRoot() )
return Status::INVALID_ROOT;
122 if ( !
checkRoot() )
return Status::INVALID_ROOT;
124 if ( !entry )
return Status::INVALID_OBJECT;
131 if ( !
checkRoot() )
return Status::INVALID_ROOT;
185 if ( pDataLoader ) pDataLoader->
addRef();
194 if ( !pObject )
return Status::INVALID_OBJECT;
200 if ( !
checkRoot() )
return Status::INVALID_ROOT;
202 if ( !node_entry )
return Status::INVALID_OBJECT;
203 refpParent = node_entry->
parent();
209 if ( !pObject )
return Status::INVALID_OBJECT;
217 if ( !pRegistry )
return Status::INVALID_OBJECT;
219 if ( !node_entry )
return Status::INVALID_OBJECT;
228 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
234 if ( !
checkRoot() )
return Status::INVALID_ROOT;
235 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
238 auto sep = find( objPath,
SEPARATOR, 1 );
239 if ( sep == std::string_view::npos || objPath.substr( 0, sep ) !=
m_rootName.value() ) {
240 return Status::INVALID_PARENT;
246 if ( !par_entry )
return Status::INVALID_PARENT;
248 if ( sep > 0 && sep != std::string_view::npos ) {
249 auto p_path = objPath.substr( 0, sep );
250 auto o_path = objPath.substr( sep );
258 p_entry = par_entry->
findLeaf( p_path );
260 if ( !p_entry )
return Status::INVALID_PARENT;
264 return status.
isSuccess() ? status : Status::DOUBL_OBJ_PATH;
269 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
275 if ( !
checkRoot() )
return Status::INVALID_ROOT;
277 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
280 auto sep = find( objPath,
SEPARATOR, 1 );
281 if ( sep == std::string_view::npos || objPath.substr( 0, sep ) !=
m_rootName.value() ) {
282 return Status::INVALID_PARENT;
292 if ( sep > 0 && sep != std::string_view::npos ) {
299 return Status::INVALID_PARENT;
316 if ( !
checkRoot() )
return Status::INVALID_ROOT;
318 if ( !objPath.empty() ) {
320 auto sep = find( objPath,
SEPARATOR, 1 );
321 if ( sep != std::string_view::npos ) {
322 return registerObject( objPath.substr( 0, sep ), objPath.substr( sep ), pObject );
325 return Status::INVALID_OBJ_PATH;
330 auto sep = find( objPath,
SEPARATOR, 1 );
331 if ( sep != std::string_view::npos ) {
332 auto p_path = objPath.substr( 0, sep );
333 auto o_path = objPath.substr( sep );
341 par_entry = node_entry->
findLeaf( p_path );
342 }
else if ( par_entry && !par_entry->
object() ) {
348 par_entry = node_entry->
findLeaf( p_path );
351 node_entry = par_entry;
364 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
373 status = Status::DOUBL_OBJ_PATH;
379 return Status::INVALID_PARENT;
388 if ( !pEntry )
return Status::INVALID_ROOT;
389 if ( !pEntry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
391 if ( !pParent )
return Status::INVALID_PARENT;
392 if ( pObject ) pObject->
addRef();
393 pParent->
remove( pEntry );
399 if ( !
checkRoot() )
return Status::INVALID_ROOT;
401 if ( !entry )
return Status::INVALID_OBJECT;
403 if ( !parent )
return Status::INVALID_PARENT;
404 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
406 if ( parent ) parent->
remove( entry );
412 if ( !
checkRoot() )
return Status::INVALID_ROOT;
417 if ( !entry )
return Status::INVALID_OBJECT;
418 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
424 return Status::INVALID_PARENT;
432 if ( pReg &&
path.empty() ) {
451 if ( pLeaf )
return pLeaf->
object();
475 return Status::NO_DATA_LOADER;
481 return Status::INVALID_OBJ_ADDR;
498 return Status::INVALID_OBJ_ADDR;
501 status = pLoader->
createObj( pAddress, pObject );
510 status = pLoader->
fillObjRefs( pAddress, pObject );
545 if ( sep == std::string_view::npos )
return Status::INVALID_OBJ_PATH;
549 if ( !status.
isSuccess() )
return status;
553 if ( sep != std::string_view::npos ) {
554 auto p_path =
path.substr( 0, sep );
555 auto o_path =
path.substr( sep );
556 if ( !parentObj->
object() ) {
558 if ( !status.
isSuccess() )
return status;
565 root_entry = parentObj->
findLeaf( p_path );
572 if ( !status.
isSuccess() )
return status;
578 }
else if (
path.empty() ) {
581 if ( !parentObj->
object() ) {
583 if ( !status.
isSuccess() )
return status;
595 status = Status::INVALID_OBJ_PATH;
596 }
else if ( !pEntry->
object() ) {
630 if ( !pReg )
return Status::INVALID_OBJ_PATH;
633 return pObject ? Status::IDataProviderSvc_NO_ERROR : Status::OBJ_NOT_LOADED;
640 if ( !
checkRoot() )
return Status::INVALID_ROOT;
643 return !pObject ? Status::OBJ_NOT_LOADED : Status::IDataProviderSvc_NO_ERROR;
650 if ( !pRegistry )
return Status::INVALID_OBJ_ADDR;
658 if ( !toUpdate )
return Status::INVALID_OBJECT;
660 if ( !pRegistry )
return Status::INVALID_OBJECT;
662 if ( !pAddress )
return Status::INVALID_OBJ_ADDR;
665 if ( !pLoader )
return Status::NO_DATA_LOADER;
672 status = pLoader->updateObj( pAddress, toUpdate );
673 if ( status.
isSuccess() ) { status = pLoader->updateObjRefs( pAddress, toUpdate ); }
677 throw GaudiException(
"std::exception in updateObject() " + pRegistry->
name() +
": " +
689 if ( !
checkRoot() )
return Status::INVALID_ROOT;
695 if ( !to_entry )
return Status::INVALID_OBJECT;
697 if ( sep > 0 && sep != std::string_view::npos ) {
704 return status.
isSuccess() ? Status::IDataProviderSvc_NO_ERROR : Status::DOUBL_OBJ_PATH;
707 return Status::INVALID_PARENT;
712 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
715 return linkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ), to );
724 if ( !
checkRoot() )
return Status::INVALID_ROOT;
729 if ( sep > 0 && sep != std::string_view::npos ) {
735 return status.
isSuccess() ? status : Status::INVALID_OBJ_PATH;
738 return Status::INVALID_PARENT;
743 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
746 return unlinkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ) );
751 if ( !
checkRoot() )
return Status::INVALID_ROOT;
778 if ( pObject && depth++ < load_depth ) {
781 for (
const auto& i : *dir ) {
796 int load_depth = i.depth();
826 error() <<
"Unable to reinitialize base class" <<
endmsg;
832 error() <<
"Failed to access incident service." <<
endmsg;
StatusCode initialize() override
Define general base for Gaudi exception.
IRegistry * registry() const
Get pointer to Registry.
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.
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 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
DataObject * handleDataFault(IRegistry *pReg, std::string_view path={})
Invoke data fault handling if enabled.
Gaudi::Property< CLID > m_rootCLID
RegistryEntry * findLeaf(std::string_view path) const
Find identified leaf in this registry node.
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject) override
Retrieve object from data store.
constexpr static const auto SUCCESS
bool isEmpty() const
Simple check if the Container is empty.
StatusCode unregisterAddress(std::string_view fullPath) override
IDataManagerSvc: Unregister object address from the data store.
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.
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
virtual IConversionSvc * getDataLoader(IRegistry *pReg)
Retrieve customizable data loader according to registry entry to be retrieved.
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...
StatusCode unlinkObject(IRegistry *from, std::string_view objPath) override
Remove a link to another object.
Data provider interface definition.
void setAddress(IOpaqueAddress *pAddress) override
Set/Update Opaque address.
Description of the DataStoreItem class.
IRegistry * parent() const
Pointer to parent directory entry.
StatusCode registerObject(std::string_view parentPath, std::string_view objPath, DataObject *pObject) override
Register object with the data store.
StatusCode resetPreLoad() override
Clear the preload list.
virtual DataObject * createDefaultObject() const
Create default objects in case forced creation of leaves is requested.
StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress) override
IDataManagerSvc: Register object address with the data store.
const std::string & name() const override
Retrieve name of the service.
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 preLoad() override
load all preload items of the list
StatusCode clearSubTree(std::string_view sub_tree_path) override
IDataManagerSvc: Remove all data objects below the sub tree identified by its full path name.
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
IOpaqueAddress * address() const override
Retrieve opaque storage address.
IIncidentSvc * m_incidentSvc
Pointer to incident service.
StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *to) override
Add a link to another object.
This class is used for returning status codes from appropriate routines.
DataSvcHelpers::RegistryEntry RegEntry
const Store & leaves() const
Access the leaves of the object.
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
const std::string & rootName() const override
IDataManagerSvc: Accessor for root event name.
void setDataSvc(IDataProviderSvc *s)
Set the transient data store.
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...
const std::string & identifier() const override
Full identifier (or key)
StatusCode reinitialize() override
StatusCode unregisterObject(std::string_view fullPath) override
Unregister object from the data store.
unsigned int CLID
Class ID definition.
StatusCode remove(std::string_view name)
Remove an entry from the store.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual DataObject * object() const =0
Retrieve object behind the link.
StatusCode retrieveEntry(DataSvcHelpers::RegistryEntry *pNode, std::string_view path, DataSvcHelpers::RegistryEntry *&pEntry)
Retrieve registry entry from store.
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
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
const StatusCode & ignore() const
Ignore/check StatusCode.
StatusCode add(std::string name, DataObject *pObject, bool is_soft=false)
Add entry to data store.
DataObject * object() const override
Retrive object behind the link.
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.
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.
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...
decltype(auto) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
constexpr static const auto FAILURE
bool checkRoot()
Check if root path is valid.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
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.
bool isSoft() const
Is the link soft or hard.
virtual const id_type & identifier() const =0
Full identifier (or key)
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
Data service incident class.
Opaque address interface definition.
Gaudi::Property< std::vector< std::string > > m_inhibitPathes
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.