The Gaudi Framework  v30r3 (a5ef0a68)
RegistryEntry.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_REGISTRYENTRY_H
2 #define GAUDIKERNEL_REGISTRYENTRY_H
3 
4 // STL include files
5 #include <vector>
6 
7 // Framework include files
9 #include "GaudiKernel/Kernel.h"
10 #include "GaudiKernel/StatusCode.h"
11 #include <boost/utility/string_ref.hpp>
12 
13 // Forward declarations
14 class DataSvc;
15 // DP add this fwd decl for thread safety
16 class TsDataSvc;
17 class DataObject;
18 class IDataProviderSvc;
19 class IOpaqueAddress;
20 class IDataStoreAgent;
21 
22 namespace DataSvcHelpers
23 {
37  class GAUDI_API RegistryEntry final : public IRegistry
38  {
39  private:
42 
43  public:
44  friend class ::DataSvc;
45  // DP add friend class: the thread safe version of the DataSvc
46  friend class ::TsDataSvc;
48  typedef Store::const_iterator Iterator;
49 
50  private:
52  unsigned long m_refCount = 0;
54  bool m_isSoft = false;
60  RegistryEntry* m_pParent = nullptr;
62  IOpaqueAddress* m_pAddress = nullptr;
64  DataObject* m_pObject = nullptr;
66  IDataProviderSvc* m_pDataProviderSvc = nullptr;
68  Store m_store;
69 
70  private:
76  void assemblePath( std::string& buffer ) const;
79  IRegistry* i_find( const IRegistry* pDirectory ) const;
81  RegistryEntry* i_find( boost::string_ref path ) const;
83  RegistryEntry* i_find( const DataObject* pObject ) const;
85  RegistryEntry* i_create( std::string name );
87  long i_add( RegistryEntry* entry );
89  void setParent( RegistryEntry* pParent );
91  void setDataSvc( IDataProviderSvc* s ) { m_pDataProviderSvc = s; }
93  RegistryEntry* parentEntry() { return m_pParent; }
95  RegistryEntry* findLeaf( boost::string_ref path ) const { return i_find( path ); }
97  RegistryEntry* findLeaf( const DataObject* key ) const { return i_find( key ); }
99  void makeHard( DataObject* pObject );
101  void makeHard( IOpaqueAddress* pAddress );
103  void makeSoft( DataObject* pObject );
105  void makeSoft( IOpaqueAddress* pAddress );
106 
107  public:
109  RegistryEntry( std::string path, RegistryEntry* parent = nullptr );
111  ~RegistryEntry() override;
113  unsigned long release() override;
115  unsigned long addRef() override { return ++m_refCount; }
117  const std::string& name() const override { return m_path; }
119  const std::string& identifier() const override { return m_fullpath; }
121  IDataProviderSvc* dataSvc() const override { return m_pDataProviderSvc; }
123  DataObject* object() const override { return m_pObject; }
125  IOpaqueAddress* address() const override { return m_pAddress; }
127  IRegistry* parent() const { return m_pParent; }
129  bool isSoft() const { return m_isSoft; }
131  const Store& leaves() const { return m_store; }
133  int size() const { return m_store.size(); }
135  bool isEmpty() const { return m_store.size() == 0; }
137  Iterator begin() const { return m_store.begin(); }
139  Iterator end() const { return m_store.end(); }
141  IRegistry* find( const IRegistry* obj ) const { return i_find( obj ); }
143  IRegistry* find( boost::string_ref path ) const { return i_find( path ); }
145  void setAddress( IOpaqueAddress* pAddress ) override;
147  void setObject( DataObject* obj );
148 
150  StatusCode add( std::string name, DataObject* pObject, bool is_soft = false );
152  StatusCode add( std::string name, IOpaqueAddress* pAddress, bool is_soft = false );
154  StatusCode remove( boost::string_ref name );
156  long add( IRegistry* obj );
158  long remove( IRegistry* obj );
160  long deleteElements();
162  StatusCode traverseTree( IDataStoreAgent* pAgent, int level = 0 );
163  };
164 }
165 #endif // GAUDIKERNEL_REGISTRYENTRY_H
RegistryEntry * findLeaf(boost::string_ref path) const
Find identified leaf in this registry node.
Definition: RegistryEntry.h:95
DataObject * object() const override
Retrive object behind the link.
const std::string & name() const override
Retrieve name of the entry.
Iterator end() const
Return end elemtn if the container.
unsigned long addRef() override
IInterface implementation: Dereference the object.
RegistryEntry * findLeaf(const DataObject *key) const
Find identified leaf in this registry node.
Definition: RegistryEntry.h:97
std::vector< IRegistry * > Store
Definition of datastore type.
Definition: RegistryEntry.h:41
T end(T...args)
const Store & leaves() const
Access the leaves of the object.
bool isSoft() const
Is the link soft or hard.
Data provider interface definition.
IRegistry * find(boost::string_ref path) const
Try to find an object identified by its relative name to the directory.
STL class.
std::string m_fullpath
String containing full path of the object (volatile)
Definition: RegistryEntry.h:56
IDataProviderSvc * dataSvc() const override
Retrieve pointer to Transient Store.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
IRegistry * parent() const
Pointer to parent directory entry.
void setDataSvc(IDataProviderSvc *s)
Set the transient data store.
Definition: RegistryEntry.h:91
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
Store::const_iterator Iterator
Iterator definition.
Definition: RegistryEntry.h:48
IOpaqueAddress * address() const override
Retrieve opaque storage address.
Definition of an entry in the transient data store.
Definition: RegistryEntry.h:37
T size(T...args)
Generic data agent interface.
T begin(T...args)
RegistryEntry * parentEntry()
Pointer to parent registry entry.
Definition: RegistryEntry.h:93
Data service base class.
Definition: TsDataSvc.h:58
Data service base class.
Definition: DataSvc.h:44
Store m_store
Store of leaves.
Definition: RegistryEntry.h:68
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
string s
Definition: gaudirun.py:253
std::string m_path
Path name.
Definition: RegistryEntry.h:58
const std::string & identifier() const override
Full identifier (or key)
bool isEmpty() const
Simple check if the Container is empty.
Opaque address interface definition.
#define GAUDI_API
Definition: Kernel.h:104
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
Iterator begin() const
Return starting point for container iteration.
int size() const
Return the size of the container(=number of objects)