The Gaudi Framework  master (37c0b60a)
RegistryEntry.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_REGISTRYENTRY_H
12 #define GAUDIKERNEL_REGISTRYENTRY_H
13 
14 // Framework include files
15 #include <GaudiKernel/IRegistry.h>
16 #include <GaudiKernel/Kernel.h>
17 #include <GaudiKernel/StatusCode.h>
18 
19 // STL include files
20 #include <string_view>
21 #include <vector>
22 
23 // Forward declarations
24 class DataSvc;
25 // DP add this fwd decl for thread safety
26 class TsDataSvc;
27 class DataObject;
28 class IDataProviderSvc;
29 class IOpaqueAddress;
30 class IDataStoreAgent;
31 
32 namespace DataSvcHelpers {
46  class GAUDI_API RegistryEntry final : public IRegistry {
47  private:
50 
51  public:
52  friend class ::DataSvc;
53  // DP add friend class: the thread safe version of the DataSvc
54  friend class ::TsDataSvc;
56  typedef Store::const_iterator Iterator;
57 
58  private:
60  unsigned long m_refCount = 0;
62  bool m_isSoft = false;
68  RegistryEntry* m_pParent = nullptr;
70  IOpaqueAddress* m_pAddress = nullptr;
72  DataObject* m_pObject = nullptr;
74  IDataProviderSvc* m_pDataProviderSvc = nullptr;
77 
78  private:
84  void assemblePath( std::string& buffer ) const;
87  IRegistry* i_find( const IRegistry* pDirectory ) const;
89  RegistryEntry* i_find( std::string_view path ) const;
91  RegistryEntry* i_find( const DataObject* pObject ) const;
93  RegistryEntry* i_create( std::string name );
95  long i_add( RegistryEntry* entry );
97  void setParent( RegistryEntry* pParent );
99  void setDataSvc( IDataProviderSvc* s ) { m_pDataProviderSvc = s; }
101  RegistryEntry* parentEntry() { return m_pParent; }
103  RegistryEntry* findLeaf( std::string_view path ) const { return i_find( path ); }
105  RegistryEntry* findLeaf( const DataObject* key ) const { return i_find( key ); }
107  void makeHard( DataObject* pObject );
109  void makeHard( IOpaqueAddress* pAddress );
111  void makeSoft( DataObject* pObject );
113  void makeSoft( IOpaqueAddress* pAddress );
114 
115  public:
117  RegistryEntry( std::string path, RegistryEntry* parent = nullptr );
119  ~RegistryEntry() override;
121  unsigned long release() override;
123  unsigned long addRef() override { return ++m_refCount; }
125  const std::string& name() const override { return m_path; }
127  const std::string& identifier() const override { return m_fullpath; }
129  IDataProviderSvc* dataSvc() const override { return m_pDataProviderSvc; }
131  DataObject* object() const override { return m_pObject; }
133  IOpaqueAddress* address() const override { return m_pAddress; }
135  IRegistry* parent() const { return m_pParent; }
137  bool isSoft() const { return m_isSoft; }
139  const Store& leaves() const { return m_store; }
141  size_t size() const { return m_store.size(); }
143  bool isEmpty() const { return m_store.size() == 0; }
145  Iterator begin() const { return m_store.begin(); }
147  Iterator end() const { return m_store.end(); }
149  IRegistry* find( const IRegistry* obj ) const { return i_find( obj ); }
151  IRegistry* find( std::string_view path ) const { return i_find( path ); }
153  void setAddress( IOpaqueAddress* pAddress ) override;
155  void setObject( DataObject* obj );
156 
158  StatusCode add( std::string name, DataObject* pObject, bool is_soft = false );
160  StatusCode add( std::string name, IOpaqueAddress* pAddress, bool is_soft = false );
162  StatusCode remove( std::string_view name );
164  long add( IRegistry* obj );
166  long remove( IRegistry* obj );
168  long deleteElements();
170  StatusCode traverseTree( IDataStoreAgent* pAgent, int level = 0 );
171  };
172 } // namespace DataSvcHelpers
173 #endif // GAUDIKERNEL_REGISTRYENTRY_H
DataSvcHelpers::RegistryEntry::find
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
Definition: RegistryEntry.h:149
std::string
STL class.
DataSvcHelpers::RegistryEntry::m_path
std::string m_path
Path name.
Definition: RegistryEntry.h:66
DataSvcHelpers::RegistryEntry::findLeaf
RegistryEntry * findLeaf(std::string_view path) const
Find identified leaf in this registry node.
Definition: RegistryEntry.h:103
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
DataSvcHelpers::RegistryEntry::isSoft
bool isSoft() const
Is the link soft or hard.
Definition: RegistryEntry.h:137
gaudirun.s
string s
Definition: gaudirun.py:346
IOpaqueAddress
Definition: IOpaqueAddress.h:33
std::vector< IRegistry * >
std::vector::size
T size(T... args)
DataSvcHelpers::RegistryEntry::begin
Iterator begin() const
Return starting point for container iteration.
Definition: RegistryEntry.h:145
DataSvcHelpers::RegistryEntry::findLeaf
RegistryEntry * findLeaf(const DataObject *key) const
Find identified leaf in this registry node.
Definition: RegistryEntry.h:105
conf.release
string release
Definition: conf.py:27
DataSvcHelpers::RegistryEntry::size
size_t size() const
Return the size of the container(=number of objects)
Definition: RegistryEntry.h:141
IRegistry
Definition: IRegistry.h:32
DataSvcHelpers::RegistryEntry::m_fullpath
std::string m_fullpath
String containing full path of the object (volatile)
Definition: RegistryEntry.h:64
DataSvcHelpers::RegistryEntry::Store
std::vector< IRegistry * > Store
Definition of datastore type.
Definition: RegistryEntry.h:49
DataSvcHelpers::RegistryEntry::addRef
unsigned long addRef() override
IInterface implementation: Dereference the object.
Definition: RegistryEntry.h:123
DataSvcHelpers::RegistryEntry::find
IRegistry * find(std::string_view path) const
Try to find an object identified by its relative name to the directory.
Definition: RegistryEntry.h:151
StatusCode.h
DataSvcHelpers::RegistryEntry::address
IOpaqueAddress * address() const override
Retrieve opaque storage address.
Definition: RegistryEntry.h:133
DataSvcHelpers::RegistryEntry::leaves
const Store & leaves() const
Access the leaves of the object.
Definition: RegistryEntry.h:139
DataSvcHelpers::RegistryEntry::object
DataObject * object() const override
Retrive object behind the link.
Definition: RegistryEntry.h:131
StatusCode
Definition: StatusCode.h:65
DataSvcHelpers::RegistryEntry::m_store
Store m_store
Store of leaves.
Definition: RegistryEntry.h:76
DataSvcHelpers::RegistryEntry::name
const std::string & name() const override
Retrieve name of the entry.
Definition: RegistryEntry.h:125
DataSvcHelpers::RegistryEntry::isEmpty
bool isEmpty() const
Simple check if the Container is empty.
Definition: RegistryEntry.h:143
DataSvcHelpers::RegistryEntry::parent
IRegistry * parent() const
Pointer to parent directory entry.
Definition: RegistryEntry.h:135
DataSvcHelpers::RegistryEntry::setDataSvc
void setDataSvc(IDataProviderSvc *s)
Set the transient data store.
Definition: RegistryEntry.h:99
gaudirun.level
level
Definition: gaudirun.py:364
IRegistry.h
DataSvcHelpers::RegistryEntry::end
Iterator end() const
Return end elemtn if the container.
Definition: RegistryEntry.h:147
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
DataSvc
Definition: DataSvc.h:52
DataSvcHelpers::RegistryEntry
Definition: RegistryEntry.h:46
std::vector::begin
T begin(T... args)
DataSvcHelpers::RegistryEntry::dataSvc
IDataProviderSvc * dataSvc() const override
Retrieve pointer to Transient Store.
Definition: RegistryEntry.h:129
Kernel.h
DataObject
Definition: DataObject.h:36
DataSvcHelpers::RegistryEntry::identifier
const std::string & identifier() const override
Full identifier (or key)
Definition: RegistryEntry.h:127
std::vector::end
T end(T... args)
IDataProviderSvc
Definition: IDataProviderSvc.h:53
TsDataSvc
Definition: TsDataSvc.h:65
DataSvcHelpers::RegistryEntry::Iterator
Store::const_iterator Iterator
Iterator definition.
Definition: RegistryEntry.h:56
ProduceConsume.key
key
Definition: ProduceConsume.py:84
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
GaudiPython.Persistency.add
def add(instance)
Definition: Persistency.py:50
DataSvcHelpers
Definition: DataSvc.h:37
IDataStoreAgent
Definition: IDataStoreAgent.h:27
DataSvcHelpers::RegistryEntry::parentEntry
RegistryEntry * parentEntry()
Pointer to parent registry entry.
Definition: RegistryEntry.h:101