Loading [MathJax]/extensions/tex2jax.js
Go to the documentation of this file.
22 #include <string_view>
25 #define STD_LOCK_GUARD_MACRO std::scoped_lock lock{ m_accessMutex };
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;
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;
231 if ( !par_entry )
return Status::INVALID_PARENT;
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;
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() ) {
424 p.append(
path.data(),
path.size() );
427 pLeaf =
m_root->findLeaf( p );
429 std::string p =
m_root->identifier();
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 ) {
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;
580 status = Status::INVALID_OBJ_PATH;
581 }
else if ( !pEntry->
object() ) {
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;
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;
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;
700 return linkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ), to );
709 if ( !
checkRoot() )
return Status::INVALID_ROOT;
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;
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();
793 if ( !sc.
isSuccess() ) { error() <<
"Failed to access incident service." <<
endmsg; }
807 error() <<
"Unable to reinitialize base class" <<
endmsg;
813 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.
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.
virtual unsigned long addRef() const =0
Increment the reference count of Interface instance.
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.
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
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 release() const =0
Release 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.