Loading [MathJax]/jax/output/HTML-CSS/config.js
Go to the documentation of this file.
11 #define DATASVC_DATASVC_CPP
28 s.append(
sr.data(),
sr.size() );
32 std::string_view::size_type find( std::string_view
s,
char c,
size_t o ) {
33 if ( !
s.empty() )
s.remove_prefix( o );
35 return r == std::string_view::npos ? r : ( r + o );
38 std::string to_string( std::string_view
sr ) {
return {
sr.data(),
sr.size() }; }
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()
64 if ( !node_entry )
return Status::INVALID_OBJECT;
66 if ( !parent )
return Status::INVALID_PARENT;
67 parent->
remove( node_entry );
75 if ( !
checkRoot() )
return Status::INVALID_ROOT;
77 if ( !entry )
return Status::INVALID_OBJECT;
79 if ( !parent )
return Status::INVALID_PARENT;
102 return entry ? entry->
traverseTree( pAgent ) : Status::INVALID_OBJECT;
107 if ( !
checkRoot() )
return Status::INVALID_ROOT;
108 return m_root->traverseTree( pAgent );
117 return i_setRoot( std::move( root_path ), pRootObj );
127 m_root = std::make_unique<RegEntry>( std::move( root_path ) );
128 m_root->makeHard( pRootObj );
129 m_root->setDataSvc(
this );
141 return i_setRoot( std::move( root_path ), pRootAddr );
151 m_root = std::make_unique<RegEntry>( std::move( root_path ) );
152 m_root->makeHard( pRootAddr );
153 m_root->setDataSvc(
this );
168 if ( !pObject )
return Status::INVALID_OBJECT;
173 if ( !
checkRoot() )
return Status::INVALID_ROOT;
175 if ( !node_entry )
return Status::INVALID_OBJECT;
176 refpParent = node_entry->
parent();
182 if ( !pObject )
return Status::INVALID_OBJECT;
190 if ( !
checkRoot() )
return Status::INVALID_ROOT;
192 if ( !node_entry )
return Status::INVALID_OBJECT;
193 leaves = node_entry->
leaves();
199 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
205 if ( !
checkRoot() )
return Status::INVALID_ROOT;
206 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
210 auto sep = find( objPath,
SEPARATOR, 1 );
211 if ( sep == std::string_view::npos || objPath.substr( 0, sep ) !=
m_rootName.
value() ) {
212 return Status::INVALID_PARENT;
218 if ( !par_entry )
return Status::INVALID_PARENT;
221 if ( sep > 0 && sep != std::string_view::npos ) {
222 auto p_path = objPath.substr( 0, sep );
223 auto o_path = objPath.substr( sep );
231 p_entry = par_entry->
findLeaf( p_path );
233 if ( !p_entry )
return Status::INVALID_PARENT;
236 StatusCode status = par_entry->
add( to_string( objPath ), pAddress );
237 return status.
isSuccess() ? status : Status::DOUBL_OBJ_PATH;
242 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
248 if ( !
checkRoot() )
return Status::INVALID_ROOT;
249 if ( objPath.empty() )
return Status::INVALID_OBJ_PATH;
253 auto sep = find( objPath,
SEPARATOR, 1 );
254 if ( sep != std::string_view::npos && objPath.substr( 0, sep ) ==
m_rootName.
value() ) {
257 return Status::INVALID_PARENT;
265 if ( sep > 0 && sep != std::string_view::npos ) {
272 return Status::INVALID_PARENT;
289 if ( !
checkRoot() )
return Status::INVALID_ROOT;
292 if ( !objPath.empty() ) {
294 auto sep = find( objPath,
SEPARATOR, 1 );
295 if ( sep != std::string_view::npos ) {
296 return registerObject( objPath.substr( 0, sep ), objPath.substr( sep ), pObject );
299 return Status::INVALID_OBJ_PATH;
304 auto sep = find( objPath,
SEPARATOR, 1 );
305 if ( sep != std::string_view::npos ) {
306 auto p_path = objPath.substr( 0, sep );
307 auto o_path = objPath.substr( sep );
315 par_entry = node_entry->
findLeaf( p_path );
316 }
else if ( par_entry && !par_entry->
object() ) {
322 par_entry = node_entry->
findLeaf( p_path );
325 node_entry = par_entry;
333 status = node_entry->
add( to_string( objPath ), pObject );
338 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
346 status = Status::DOUBL_OBJ_PATH;
352 return Status::INVALID_PARENT;
361 if ( !pEntry )
return Status::INVALID_ROOT;
362 if ( !pEntry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
364 if ( !pParent )
return Status::INVALID_PARENT;
366 pParent->
remove( pEntry );
372 if ( !
checkRoot() )
return Status::INVALID_ROOT;
374 if ( !entry )
return Status::INVALID_OBJECT;
376 if ( !parent )
return Status::INVALID_PARENT;
377 if ( !entry->
isEmpty() )
return Status::DIR_NOT_EMPTY;
379 if ( parent ) parent->
remove( entry );
396 return Status::DIR_NOT_EMPTY;
398 return Status::INVALID_OBJECT;
401 return Status::INVALID_PARENT;
403 return Status::INVALID_ROOT;
415 if ( pReg &&
path.empty() ) {
423 p.append(
path.data(),
path.size() );
426 pLeaf =
m_root->findLeaf( p );
428 std::string p =
m_root->identifier();
430 p.append(
path.data(),
path.size() );
433 pLeaf =
m_root->findLeaf( p );
435 if ( pLeaf ) {
return pLeaf->
object(); }
474 return Status::INVALID_OBJ_ADDR;
477 status = pLoader->
createObj( pAddress, pObject );
486 status = pLoader->
fillObjRefs( pAddress, pObject );
492 }
catch (
const std::exception& x ) {
517 if ( !
checkRoot() )
return Status::INVALID_ROOT;
519 static constexpr
auto empty = std::string_view{};
529 }
else if ( sep != std::string_view::npos ) {
530 if ( !
m_root->object() ) {
533 if ( !status.isSuccess() )
return status;
538 return Status::INVALID_OBJ_PATH;
544 if ( sep != std::string_view::npos ) {
545 if ( !parentObj->
object() ) {
547 if ( !status.isSuccess() )
return status;
549 auto p_path =
path.substr( 0, sep );
555 root_entry = parentObj->
findLeaf( p_path );
562 if ( !status.isSuccess() )
return status;
567 return Status::INVALID_OBJ_PATH;
568 }
else if (
path.empty() ) {
571 if ( !parentObj->
object() ) {
573 if ( !status.isSuccess() )
return status;
585 if ( !pEntry )
return Status::INVALID_OBJ_PATH;
616 if ( !pReg )
return Status::INVALID_OBJ_PATH;
619 return ( !pObject ) ? Status::OBJ_NOT_LOADED : Status::IDataProviderSvc_NO_ERROR;
625 if ( !
checkRoot() )
return Status::INVALID_ROOT;
627 pObject =
m_root->object();
628 return !pObject ? Status::OBJ_NOT_LOADED : Status::IDataProviderSvc_NO_ERROR;
636 return Status::INVALID_OBJ_ADDR;
649 return Status::INVALID_OBJECT;
653 return Status::INVALID_OBJECT;
657 return Status::INVALID_OBJ_ADDR;
661 return Status::NO_DATA_LOADER;
668 status = pLoader->
updateObj( pAddress, toUpdate );
672 }
catch (
const std::exception& x ) {
673 throw GaudiException(
"std::exception in updateObject() " + pRegistry->
name() +
": " +
684 if ( !
checkRoot() )
return Status::INVALID_ROOT;
690 if ( !to_entry )
return Status::INVALID_OBJECT;
692 if ( sep > 0 && sep != std::string_view::npos ) {
698 StatusCode status = from_entry->
add( to_string( objPath ), to,
true );
699 return status.
isSuccess() ? Status::IDataProviderSvc_NO_ERROR : Status::DOUBL_OBJ_PATH;
702 return Status::INVALID_PARENT;
707 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
710 return linkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ), to );
715 if ( !
checkRoot() )
return Status::INVALID_ROOT;
720 if ( sep > 0 && sep != std::string_view::npos ) {
727 return Status::INVALID_OBJ_PATH;
730 return Status::INVALID_PARENT;
735 if ( fullPath.empty() )
return Status::INVALID_OBJ_PATH;
738 return unlinkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ) );
743 if ( !
checkRoot() )
return Status::INVALID_ROOT;
770 if ( pObject && depth++ < load_depth ) {
773 for (
const auto& i : *dir ) {
788 int load_depth = i.depth();
814 error() <<
"Unable to reinitialize base class" <<
endmsg;
820 error() <<
"Failed to access incident service." <<
endmsg;
StatusCode reinitialize() override
Service initialization.
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
void setRegistry(IRegistry *pRegistry)
Set pointer to Registry.
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.
RegistryEntry * findLeaf(std::string_view path) const
Find identified leaf in this registry node.
bool isSoft() const
Is the link soft or hard.
StatusCode resetPreLoad() override
Clear the preload list.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
#define CAST_REGENTRY(x, y)
virtual unsigned long release()
release reference to object
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
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.
StatusCode i_retrieveEntry(DataSvcHelpers::RegistryEntry *parentObj, std::string_view path, DataSvcHelpers::RegistryEntry *&pEntry)
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
SmartIF< IFace > service(const std::string &name, bool createIf=true) const
DataSvcHelpers::RegistryEntry RegEntry
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject) override
Retrieve object from data store.
StatusCode finalize() override
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
DataObject * i_handleDataFault(IRegistry *pReg, std::string_view path=std::string_view{})
SmartIF< IConversionSvc > m_dataLoader
Pointer to data loader service.
StatusCode traverseTree(IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
IOpaqueAddress * address() const override
Retrieve opaque storage address.
virtual const name_type & name() const =0
Name of the directory (or key)
const Store & leaves() const
Access the leaves of the object.
AttribStringParser::Iterator begin(const AttribStringParser &parser)
virtual DataObject * createDefaultObject() const
Create default objects in case forced creation of leaves is requested.
DataObject * object() const override
Retrive object behind the link.
const std::string & name() const override
Retrieve name of the service
DataObject * handleDataFault(IRegistry *pReg, std::string_view path="")
Invoke data fault handling if enabled.
Gaudi::Property< std::string > m_rootName
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 retrieveEntry(DataSvcHelpers::RegistryEntry *pNode, std::string_view path, DataSvcHelpers::RegistryEntry *&pEntry)
Retrieve registry entry from store.
StatusCode remove(std::string_view name)
Remove an entry from the store.
void setObject(DataObject *obj)
Set/Update object address.
virtual StatusCode i_setRoot(std::string root_name, DataObject *pRootObj)
Initialize data store for new event by giving new event path and root object.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
Gaudi::Property< bool > m_enableFaultHdlr
const ValueType & value() const
StatusCode clearSubTree(std::string_view sub_tree_path) override
IDataManagerSvc: Remove all data objects below the sub tree identified by its full path name.
bool isEmpty() const
Simple check if the Container is empty.
const std::string & rootName() const override
IDataManagerSvc: Accessor for root event name.
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
unsigned int CLID
Class ID definition.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
IRegistry * parent() const
Pointer to parent directory entry.
StatusCode unregisterAddress(std::string_view fullPath) override
IDataManagerSvc: Unregister object address from the data store.
Gaudi::Property< std::string > m_faultName
Gaudi::Property< std::vector< std::string > > m_inhibitPathes
StatusCode preLoad() override
load all preload items of the list
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
std::unique_ptr< DataSvcHelpers::RegistryEntry > m_root
Pointer to root entry.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
bool checkRoot()
Check if root path is valid.
SmartIF< IIncidentSvc > m_incidentSvc
Pointer to incident service.
Gaudi::Property< bool > m_forceLeaves
constexpr static const auto SUCCESS
StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves) override
IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object.
TYPE * get() const
Get interface pointer.
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
virtual IConversionSvc * getDataLoader(IRegistry *pReg)
Retrieve customizable data loader according to registry entry to be retrieved.
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 * object() const =0
Retrieve object behind the link.
StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *to) override
Add a link to another object.
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 objectParent(const DataObject *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode reinitialize() override
StatusCode registerObject(std::string_view parentPath, std::string_view objPath, DataObject *pObject) override
Register object with the data store.
const std::string & identifier() const override
Full identifier (or key)
StatusCode initialize() override
Service initialization.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
Gaudi::Property< std::string > m_accessName
StatusCode unregisterObject(std::string_view fullPath) override
Unregister object from the data store.
constexpr static const auto FAILURE
Gaudi::Property< CLID > m_rootCLID
Gaudi::Property< bool > m_enableAccessHdlr
StatusCode traverseTree(IDataStoreAgent *pAgent, int level=0)
traverse data tree
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
decltype(auto) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
IRegistry * registry() const
Get pointer to Registry.
std::vector< DataStoreItem > m_preLoads
Items to be pre-loaded.
StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress) override
IDataManagerSvc: Register object address with the data store.
virtual unsigned long addRef()
Add reference to object.
virtual StatusCode loadObject(IRegistry *pNode)
Invoke Persistency service to create transient object from its persistent representation.
RegistryEntry * parentEntry()
Pointer to parent registry entry.
StatusCode finalize() override
Service initialization.