20 #define DATASVC_REGISTRYENTRY_CPP
26 #include "GaudiKernel/IDataStoreAgent.h"
27 #include "GaudiKernel/IOpaqueAddress.h"
30 #include "GaudiKernel/DataObject.h"
31 #include "GaudiKernel/RegistryEntry.h"
40 #define CAST_REGENTRY(x,y) dynamic_cast<x>(y)
45 inline std::string
operator+(std::string
s, boost::string_ref p) {
46 return s.append(p.data(),p.size());
53 m_path(
std::move(path)),
57 m_pDataProviderSvc(nullptr)
61 if ( sep != std::string::npos )
m_path.erase(0,sep);
70 if ( !m_isSoft ) m_pObject->setRegistry(
nullptr);
74 if ( !m_isSoft ) m_pAddress->setRegistry(
nullptr);
75 m_pAddress->release();
81 unsigned long cnt = --m_refCount;
82 if ( !m_refCount )
delete this;
90 assemblePath(m_fullpath);
105 setAddress(pAddress);
112 if ( m_pObject ) m_pObject->setRegistry(
this);
113 if ( m_pAddress ) m_pAddress->setRegistry(
this);
119 setAddress(pAddress);
128 if ( m_pAddress ) m_pAddress->release();
129 m_pAddress = pAddress;
138 if ( m_pObject ) m_pObject->release();
153 return m_store.size();
160 for (
auto&
i : m_store ) {
161 if ( nam ==
i->name() ) {
173 auto not_present = std::none_of( std::begin(m_store),
std::end(m_store),
176 return not_present ?
new RegistryEntry( std::move(nam),
this ) :
nullptr;
182 return i_add(pEntry);
196 m_store.push_back(pEntry);
204 return m_store.size();
227 for (
auto&
i : m_store ) {
234 m_store.erase(m_store.begin(), m_store.end());
240 auto i = std::find(m_store.begin(),m_store.end(),obj);
241 return (
i!=m_store.end()) ? (*
i) :
nullptr;
246 if ( path.front() ==
SEPARATOR ) path.remove_prefix(1);
247 while (!path.empty()) {
252 auto cpath = path.substr(0,loc1);
253 if (loc1 != boost::string_ref::npos) {
254 path.remove_prefix(loc1+1);
258 auto i = std::find_if( std::begin(m_store),
std::end(m_store),
259 [&](decltype(m_store)::const_reference reg) {
260 return cpath == boost::string_ref{reg->name()}.substr(1);
264 return path.empty() ? regEnt : regEnt->
i_find(path);
268 if ( cpath != boost::string_ref{m_path}.substr(1) )
break;
276 if ( key == m_pObject ) {
281 if ( result )
return result;
283 for (
const auto&
i : m_store) {
286 result = entry->
i_find(key);
287 if( result )
return result;
297 bool go_down = pAgent->
analyse(
this, level);
300 for (
auto&
i : m_store ) {
315 if ( m_pParent ) m_pParent->assemblePath(buffer);
virtual unsigned long addRef()
IInterface implementation: Dereference the object.
virtual long deleteElements()
Delete all contained elements.
virtual bool analyse(IRegistry *pObject, int level)=0
Analyse the data object.
virtual long add(const std::string &name, DataObject *pObject, bool is_soft=false)
Add entry to data store.
virtual long traverseTree(IDataStoreAgent *pAgent, int level=0)
traverse data tree
void setRegistry(IRegistry *pRegistry)
Set pointer to Registry.
#define CAST_REGENTRY(x, y)
virtual const name_type & name() const =0
Name of the directory (or key)
RegistryEntry(std::string path, RegistryEntry *parent=0)
Standard Constructor.
virtual long remove(const std::string &name)
Remove an entry from the store.
virtual unsigned long release()
IInterface implementation: Reference the object.
IRegistry * registry() const
Get pointer to Registry.
long i_add(RegistryEntry *entry)
Internal method to add entries.
std::string m_fullpath
String containing full path of the object (volatile)
void assemblePath(std::string &buffer) const
The following entries serve two aspects: 1) They are faster for recursive calls, because they are non...
virtual bool isSoft() const
Is the link soft or hard.
void setParent(RegistryEntry *pParent)
Set new parent pointer.
virtual unsigned long addRef()
Add reference to object.
void setObject(DataObject *obj)
Set/Update object address.
virtual IOpaqueAddress * address() const
Retrieve opaque storage address.
GAUDI_API Stat operator+(const Stat &stat, const double value)
external operator for addition of Stat and a number
void setDataSvc(IDataProviderSvc *s)
Set the transient data store.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
void makeSoft(DataObject *pObject)
Initialize link as soft link.
RegistryEntry * i_create(std::string name)
Internal method to create entries.
void setAddress(IOpaqueAddress *pAddress)
Set/Update Opaque address.
Definition of an entry in the transient data store.
Generic data agent interface.
std::string m_path
Path name.
virtual ~RegistryEntry()
Standard Destructor.
virtual void setRegistry(IRegistry *r)=0
Update directory pointer.
Opaque address interface definition.
A DataObject is the base class of any identifiable object on any data store.
IRegistry * i_find(const IRegistry *pDirectory) const
Internal method to retrieve data directory.
virtual unsigned long addRef()=0
Add reference to object.
void makeHard(DataObject *pObject)
Initialize link as hard link.