25#define STD_LOCK_GUARD_MACRO std::scoped_lock lock{ m_accessMutex };
28 std::string
operator+(
char c, std::string_view sr ) {
30 s.append( sr.data(), sr.size() );
34 std::string_view::size_type find( std::string_view s,
char c,
size_t o ) {
35 if ( !s.empty() ) s.remove_prefix( o );
37 return r == std::string_view::npos ? r : ( r + o );
46#define CAST_REGENTRY( x, y ) dynamic_cast<x>( y )
50#define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
51#define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
53#define DEBMSG ON_DEBUG debug()
54#define VERMSG ON_VERBOSE verbose()
68 if ( !node_entry )
return Status::INVALID_OBJECT;
70 if ( !parent )
return Status::INVALID_PARENT;
71 parent->
remove( node_entry );
79 if ( !
checkRoot() )
return Status::INVALID_ROOT;
81 if ( !entry )
return Status::INVALID_OBJECT;
83 if ( !parent )
return Status::INVALID_PARENT;
90 if ( !
checkRoot() )
return Status::INVALID_ROOT;
107 if ( !
checkRoot() )
return Status::INVALID_ROOT;
109 if ( !entry )
return Status::INVALID_OBJECT;
116 if ( !
checkRoot() )
return Status::INVALID_ROOT;
117 return m_root->traverseTree( pAgent );
126 return i_setRoot( std::move( root_path ), pRootObj );
136 m_root = std::make_unique<RegEntry>( std::move( root_path ) );
137 m_root->makeHard( pRootObj );
138 m_root->setDataSvc(
this );
150 return i_setRoot( std::move( root_path ), pRootAddr );
160 m_root = std::make_unique<RegEntry>( std::move( root_path ) );
161 m_root->makeHard( pRootAddr );
162 m_root->setDataSvc(
this );
170 if ( pDataLoader ) pDataLoader->
addRef();
179 if ( !pObject )
return Status::INVALID_OBJECT;
185 if ( !
checkRoot() )
return Status::INVALID_ROOT;
187 if ( !node_entry )
return Status::INVALID_OBJECT;
188 refpParent = node_entry->
parent();
194 if ( !pObject )
return Status::INVALID_OBJECT;
202 if ( !pRegistry )
return Status::INVALID_OBJECT;
204 if ( !node_entry )
return Status::INVALID_OBJECT;
206 leaves.insert( leaves.end(), node_entry->
leaves().begin(), node_entry->
leaves().end() );
213 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
214 return registerAddress( fullPath.front() != SEPARATOR ?
m_root.get() :
nullptr, fullPath, pAddress );
219 if ( !
checkRoot() )
return Status::INVALID_ROOT;
220 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
223 auto sep = find( objPath, SEPARATOR, 1 );
224 if ( sep == std::string_view::npos || objPath.substr( 0, sep ) !=
m_rootName.value() ) {
225 return Status::INVALID_PARENT;
229 if ( objPath.front() != SEPARATOR ) {
return registerAddress( parentObj, SEPARATOR + objPath, pAddress ); }
231 if ( !par_entry )
return Status::INVALID_PARENT;
232 auto sep = objPath.rfind( SEPARATOR );
233 if ( sep > 0 && sep != std::string_view::npos ) {
234 auto p_path = objPath.substr( 0, sep );
235 auto o_path = objPath.substr( sep );
243 p_entry = par_entry->
findLeaf( p_path );
245 if ( !p_entry )
return Status::INVALID_PARENT;
248 StatusCode status = par_entry->
add( std::string{ objPath }, pAddress );
249 return status.
isSuccess() ? status : Status::DOUBL_OBJ_PATH;
254 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
260 if ( !
checkRoot() )
return Status::INVALID_ROOT;
262 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
265 auto sep = find( objPath, SEPARATOR, 1 );
266 if ( sep == std::string_view::npos || objPath.substr( 0, sep ) !=
m_rootName.value() ) {
267 return Status::INVALID_PARENT;
271 if ( objPath.front() != SEPARATOR ) {
return unregisterAddress( pParent, SEPARATOR + objPath ); }
276 auto sep = objPath.rfind( SEPARATOR );
277 if ( sep > 0 && sep != std::string_view::npos ) {
284 return Status::INVALID_PARENT;
301 if ( !
checkRoot() )
return Status::INVALID_ROOT;
303 if ( !objPath.empty() ) {
305 auto sep = find( objPath, SEPARATOR, 1 );
306 if ( sep != std::string_view::npos ) {
307 return registerObject( objPath.substr( 0, sep ), objPath.substr( sep ), pObject );
310 return Status::INVALID_OBJ_PATH;
315 auto sep = find( objPath, SEPARATOR, 1 );
316 if ( sep != std::string_view::npos ) {
317 auto p_path = objPath.substr( 0, sep );
318 auto o_path = objPath.substr( sep );
326 par_entry = node_entry->
findLeaf( p_path );
327 }
else if ( par_entry && !par_entry->
object() ) {
333 par_entry = node_entry->
findLeaf( p_path );
336 node_entry = par_entry;
344 status = node_entry->
add( std::string{ objPath }, pObject );
349 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
358 status = Status::DOUBL_OBJ_PATH;
364 return Status::INVALID_PARENT;
373 if ( !pEntry )
return Status::INVALID_ROOT;
374 if ( !pEntry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
376 if ( !pParent )
return Status::INVALID_PARENT;
378 pParent->
remove( pEntry );
384 if ( !
checkRoot() )
return Status::INVALID_ROOT;
386 if ( !entry )
return Status::INVALID_OBJECT;
388 if ( !parent )
return Status::INVALID_PARENT;
389 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
391 if ( parent ) parent->
remove( entry );
397 if ( !
checkRoot() )
return Status::INVALID_ROOT;
402 if ( !entry )
return Status::INVALID_OBJECT;
403 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
409 return Status::INVALID_PARENT;
417 if ( pReg && path.empty() ) {
423 if ( path.front() != SEPARATOR ) p += SEPARATOR;
424 p.append( path.data(), path.size() );
427 pLeaf =
m_root->findLeaf( p );
429 std::string p =
m_root->identifier();
430 if ( path.front() != SEPARATOR ) p += SEPARATOR;
431 p.append( path.data(), path.size() );
434 pLeaf =
m_root->findLeaf( p );
436 if ( pLeaf )
return pLeaf->
object();
460 return Status::NO_DATA_LOADER;
466 return Status::INVALID_OBJ_ADDR;
483 return Status::INVALID_OBJ_ADDR;
486 status = pLoader->
createObj( pAddress, pObject );
495 status = pLoader->
fillObjRefs( pAddress, pObject );
501 }
catch (
const std::exception& x ) {
521 auto sep = find( path, SEPARATOR, 1 );
530 if ( sep == std::string_view::npos )
return Status::INVALID_OBJ_PATH;
531 if ( !
m_root->object() ) {
534 if ( !status.
isSuccess() )
return status;
538 if ( sep != std::string_view::npos ) {
539 auto p_path = path.substr( 0, sep );
540 auto o_path = path.substr( sep );
541 if ( !parentObj->
object() ) {
543 if ( !status.
isSuccess() )
return status;
550 root_entry = parentObj->
findLeaf( p_path );
557 if ( !status.
isSuccess() )
return status;
562 return Status::INVALID_OBJ_PATH;
563 }
else if ( path.empty() ) {
566 if ( !parentObj->
object() ) {
568 if ( !status.
isSuccess() )
return status;
571 pEntry = parentObj->
findLeaf( path );
575 pEntry = ( path.empty() ? parentObj : parentObj->
findLeaf( path ) );
580 status = Status::INVALID_OBJ_PATH;
581 }
else if ( !pEntry->
object() ) {
614 if ( !path.empty() ) pReg = root_entry->
find( path );
615 if ( !pReg )
return Status::INVALID_OBJ_PATH;
618 return pObject ? Status::IDataProviderSvc_NO_ERROR : Status::OBJ_NOT_LOADED;
625 if ( !
checkRoot() )
return Status::INVALID_ROOT;
627 pObject =
m_root->object();
628 return !pObject ? Status::OBJ_NOT_LOADED : Status::IDataProviderSvc_NO_ERROR;
630 return findObject( path.front() != SEPARATOR ?
m_root.get() :
nullptr, path, pObject );
635 if ( !pRegistry )
return Status::INVALID_OBJ_ADDR;
643 if ( !toUpdate )
return Status::INVALID_OBJECT;
645 if ( !pRegistry )
return Status::INVALID_OBJECT;
647 if ( !pAddress )
return Status::INVALID_OBJ_ADDR;
650 if ( !pLoader )
return Status::NO_DATA_LOADER;
657 status = pLoader->updateObj( pAddress, toUpdate );
658 if ( status.
isSuccess() ) { status = pLoader->updateObjRefs( pAddress, toUpdate ); }
661 }
catch (
const std::exception& x ) {
662 throw GaudiException(
"std::exception in updateObject() " + pRegistry->
name() +
": " +
674 if ( !
checkRoot() )
return Status::INVALID_ROOT;
680 if ( !to_entry )
return Status::INVALID_OBJECT;
681 auto sep = objPath.rfind( SEPARATOR );
682 if ( sep > 0 && sep != std::string_view::npos ) {
688 StatusCode status = from_entry->
add( std::string{ objPath }, to, true );
689 return status.
isSuccess() ? Status::IDataProviderSvc_NO_ERROR : Status::DOUBL_OBJ_PATH;
692 return Status::INVALID_PARENT;
697 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
698 if ( fullPath.front() == SEPARATOR ) {
699 auto sep = fullPath.rfind( SEPARATOR );
700 return linkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ), to );
709 if ( !
checkRoot() )
return Status::INVALID_ROOT;
713 auto sep = objPath.rfind( SEPARATOR );
714 if ( sep > 0 && sep != std::string_view::npos ) {
720 return status.
isSuccess() ? status : Status::INVALID_OBJ_PATH;
723 return Status::INVALID_PARENT;
728 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
729 if ( fullPath.front() != SEPARATOR ) {
return unlinkObject(
m_root.get(), fullPath ); }
730 auto sep = fullPath.rfind( SEPARATOR );
731 return unlinkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ) );
736 if ( !
checkRoot() )
return Status::INVALID_ROOT;
763 if ( pObject && depth++ < load_depth ) {
766 for (
const auto& i : *dir ) {
781 int load_depth = i.depth();
807 error() <<
"Unable to reinitialize base class" <<
endmsg;
813 error() <<
"Failed to access incident service." <<
endmsg;
unsigned int CLID
Class ID definition.
DataSvcHelpers::RegistryEntry RegEntry
#define CAST_REGENTRY(x, y)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
GAUDI_API Stat operator+(const Stat &stat, const double value)
external operator for addition of Stat and a number
#define STD_LOCK_GUARD_MACRO
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Data service incident class.
A DataObject is the base class of any identifiable object on any data store.
virtual unsigned long addRef()
Add reference to object.
void setRegistry(IRegistry *pRegistry)
Set pointer to Registry.
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
IRegistry * registry() const
Get pointer to Registry.
virtual unsigned long release()
release reference to object
Description of the DataStoreItem class.
Definition of an entry in the transient data store.
void setObject(DataObject *obj)
Set/Update object address.
StatusCode traverseTree(IDataStoreAgent *pAgent, int level=0)
traverse data tree
void setAddress(IOpaqueAddress *pAddress) override
Set/Update Opaque address.
IRegistry * parent() const
Pointer to parent directory entry.
const Store & leaves() const
Access the leaves of the object.
bool isSoft() const
Is the link soft or hard.
const std::string & identifier() const override
Full identifier (or key)
RegistryEntry * findLeaf(std::string_view path) const
Find identified leaf in this registry node.
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
RegistryEntry * parentEntry()
Pointer to parent registry entry.
DataObject * object() const override
Retrive object behind the link.
bool isEmpty() const
Simple check if the Container is empty.
IOpaqueAddress * address() const override
Retrieve opaque storage address.
StatusCode remove(std::string_view name)
Remove an entry from the store.
StatusCode add(std::string name, DataObject *pObject, bool is_soft=false)
Add entry to data store.
Define general base for Gaudi exception.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
Data provider interface definition.
Generic data agent interface.
virtual unsigned long addRef() const =0
Increment the reference count of Interface instance.
Opaque address interface definition.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
virtual const name_type & name() const =0
Name of the directory (or key)
virtual const id_type & identifier() const =0
Full identifier (or key)
virtual DataObject * object() const =0
Retrieve object behind the link.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
StatusCode finalize() override
const std::string & name() const override
Retrieve name of the service.
StatusCode reinitialize() override
StatusCode initialize() override
This class is used for returning status codes from appropriate routines.
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
const std::string & rootName() const override
IDataManagerSvc: Accessor for root event name.
StatusCode retrieveEntry(DataSvcHelpers::RegistryEntry *pNode, std::string_view path, DataSvcHelpers::RegistryEntry *&pEntry)
Retrieve registry entry from store.
StatusCode setRoot(std::string root_name, DataObject *pRootObj) override
Initialize data store for new event by giving new event path and root object.
ServiceHandle< IIncidentSvc > m_incidentSvc
Handle to incident service.
Gaudi::Property< bool > m_forceLeaves
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 objectParent(const DataObject *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
Gaudi::Property< CLID > m_rootCLID
Gaudi::Property< bool > m_enableFaultHdlr
Gaudi::Property< std::string > m_faultName
virtual IConversionSvc * getDataLoader(IRegistry *pReg)
Retrieve customizable data loader according to registry entry to be retrieved.
bool checkRoot()
Check if root path is valid.
StatusCode finalize() override
Service initialization.
StatusCode resetPreLoad() override
Clear the preload list.
StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject) override
Retrieve object from data store.
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
std::vector< DataStoreItem > m_preLoads
Items to be pre-loaded.
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
StatusCode unregisterObject(std::string_view fullPath) override
Unregister object from the data store.
StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress) override
IDataManagerSvc: Register object address with the data store.
StatusCode initialize() override
Service initialization.
Gaudi::Property< std::string > m_accessName
Gaudi::Property< std::vector< std::string > > m_inhibitPathes
StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves) override
IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object.
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
Gaudi::Property< bool > m_enableAccessHdlr
StatusCode traverseTree(IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
StatusCode reinitialize() override
Service initialization.
StatusCode unlinkObject(IRegistry *from, std::string_view objPath) override
Remove a link to another object.
virtual StatusCode loadObject(IRegistry *pNode)
Invoke Persistency service to create transient object from its persistent representation.
StatusCode preLoad() override
load all preload items of the list
StatusCode unregisterAddress(std::string_view fullPath) override
IDataManagerSvc: Unregister object address from the data store.
StatusCode clearSubTree(std::string_view sub_tree_path) override
IDataManagerSvc: Remove all data objects below the sub tree identified by its full path name.
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
DataObject * handleDataFault(IRegistry *pReg, std::string_view path={})
Invoke data fault handling if enabled.
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
Gaudi::Property< std::string > m_rootName
virtual DataObject * createDefaultObject() const
Create default objects in case forced creation of leaves is requested.
StatusCode registerObject(std::string_view parentPath, std::string_view objPath, DataObject *pObject) override
Register object with the data store.
std::unique_ptr< DataSvcHelpers::RegistryEntry > m_root
Pointer to root entry.
StatusCode setDataLoader(IConversionSvc *svc, IDataProviderSvc *dpsvc=nullptr) override
IDataManagerSvc: IDataManagerSvc: Pass a default data loader to the service and optionally a data pro...
TsDataSvc(const std::string &name, ISvcLocator *svc)
constructor
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
IConversionSvc * m_dataLoader
Pointer to data loader service.
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...
StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *to) override
Add a link to another object.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.