The Gaudi Framework  master (d98a2936)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
RegistryEntry.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 #pragma once
12 
13 #include <GaudiKernel/IRegistry.h>
14 #include <GaudiKernel/Kernel.h>
15 #include <GaudiKernel/StatusCode.h>
16 #include <string_view>
17 #include <vector>
18 
19 class DataSvc;
20 // DP add this fwd decl for thread safety
21 class TsDataSvc;
22 class DataObject;
23 class IDataProviderSvc;
24 class IOpaqueAddress;
25 class IDataStoreAgent;
26 
27 namespace DataSvcHelpers {
41  class GAUDI_API RegistryEntry final : public IRegistry {
42  private:
44  typedef std::vector<IRegistry*> Store;
45 
46  public:
47  friend class ::DataSvc;
48  // DP add friend class: the thread safe version of the DataSvc
49  friend class ::TsDataSvc;
51  typedef Store::const_iterator Iterator;
52 
53  private:
55  unsigned long m_refCount = 0;
57  bool m_isSoft = false;
59  std::string m_fullpath;
61  std::string m_path;
63  RegistryEntry* m_pParent = nullptr;
65  IOpaqueAddress* m_pAddress = nullptr;
67  DataObject* m_pObject = nullptr;
69  IDataProviderSvc* m_pDataProviderSvc = nullptr;
72 
73  private:
79  void assemblePath( std::string& buffer ) const;
82  IRegistry* i_find( const IRegistry* pDirectory ) const;
84  RegistryEntry* i_find( std::string_view path ) const;
86  RegistryEntry* i_find( const DataObject* pObject ) const;
88  RegistryEntry* i_create( std::string name );
90  long i_add( RegistryEntry* entry );
92  void setParent( RegistryEntry* pParent );
94  void setDataSvc( IDataProviderSvc* s ) { m_pDataProviderSvc = s; }
96  RegistryEntry* parentEntry() { return m_pParent; }
98  RegistryEntry* findLeaf( std::string_view path ) const { return i_find( path ); }
100  RegistryEntry* findLeaf( const DataObject* key ) const { return i_find( key ); }
102  void makeHard( DataObject* pObject );
104  void makeHard( IOpaqueAddress* pAddress );
106  void makeSoft( DataObject* pObject );
108  void makeSoft( IOpaqueAddress* pAddress );
109 
110  public:
112  RegistryEntry( std::string path, RegistryEntry* parent = nullptr );
114  ~RegistryEntry() override;
116  unsigned long release() override;
118  unsigned long addRef() override { return ++m_refCount; }
120  const std::string& name() const override { return m_path; }
122  const std::string& identifier() const override { return m_fullpath; }
124  IDataProviderSvc* dataSvc() const override { return m_pDataProviderSvc; }
126  DataObject* object() const override { return m_pObject; }
128  IOpaqueAddress* address() const override { return m_pAddress; }
130  IRegistry* parent() const { return m_pParent; }
132  bool isSoft() const { return m_isSoft; }
134  const Store& leaves() const { return m_store; }
136  size_t size() const { return m_store.size(); }
138  bool isEmpty() const { return m_store.size() == 0; }
140  Iterator begin() const { return m_store.begin(); }
142  Iterator end() const { return m_store.end(); }
144  IRegistry* find( const IRegistry* obj ) const { return i_find( obj ); }
146  IRegistry* find( std::string_view path ) const { return i_find( path ); }
148  void setAddress( IOpaqueAddress* pAddress ) override;
150  void setObject( DataObject* obj );
151 
153  StatusCode add( std::string name, DataObject* pObject, bool is_soft = false );
155  StatusCode add( std::string name, IOpaqueAddress* pAddress, bool is_soft = false );
157  StatusCode remove( std::string_view name );
159  long add( IRegistry* obj );
161  long remove( IRegistry* obj );
163  long deleteElements();
165  StatusCode traverseTree( IDataStoreAgent* pAgent, int level = 0 );
166  };
167 } // namespace DataSvcHelpers
DataSvcHelpers::RegistryEntry::find
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
Definition: RegistryEntry.h:144
DataSvcHelpers::RegistryEntry::m_path
std::string m_path
Path name.
Definition: RegistryEntry.h:61
DataSvcHelpers::RegistryEntry::findLeaf
RegistryEntry * findLeaf(std::string_view path) const
Find identified leaf in this registry node.
Definition: RegistryEntry.h:98
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
DataSvcHelpers::RegistryEntry::isSoft
bool isSoft() const
Is the link soft or hard.
Definition: RegistryEntry.h:132
gaudirun.s
string s
Definition: gaudirun.py:346
IOpaqueAddress
Definition: IOpaqueAddress.h:28
DataSvcHelpers::RegistryEntry::begin
Iterator begin() const
Return starting point for container iteration.
Definition: RegistryEntry.h:140
DataSvcHelpers::RegistryEntry::findLeaf
RegistryEntry * findLeaf(const DataObject *key) const
Find identified leaf in this registry node.
Definition: RegistryEntry.h:100
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:136
IRegistry
Definition: IRegistry.h:29
DataSvcHelpers::RegistryEntry::m_fullpath
std::string m_fullpath
String containing full path of the object (volatile)
Definition: RegistryEntry.h:59
DataSvcHelpers::RegistryEntry::Store
std::vector< IRegistry * > Store
Definition of datastore type.
Definition: RegistryEntry.h:44
DataSvcHelpers::RegistryEntry::addRef
unsigned long addRef() override
IInterface implementation: Dereference the object.
Definition: RegistryEntry.h:118
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:146
StatusCode.h
DataSvcHelpers::RegistryEntry::address
IOpaqueAddress * address() const override
Retrieve opaque storage address.
Definition: RegistryEntry.h:128
DataSvcHelpers::RegistryEntry::leaves
const Store & leaves() const
Access the leaves of the object.
Definition: RegistryEntry.h:134
DataSvcHelpers::RegistryEntry::object
DataObject * object() const override
Retrive object behind the link.
Definition: RegistryEntry.h:126
StatusCode
Definition: StatusCode.h:64
DataSvcHelpers::RegistryEntry::m_store
Store m_store
Store of leaves.
Definition: RegistryEntry.h:71
DataSvcHelpers::RegistryEntry::name
const std::string & name() const override
Retrieve name of the entry.
Definition: RegistryEntry.h:120
DataSvcHelpers::RegistryEntry::isEmpty
bool isEmpty() const
Simple check if the Container is empty.
Definition: RegistryEntry.h:138
DataSvcHelpers::RegistryEntry::parent
IRegistry * parent() const
Pointer to parent directory entry.
Definition: RegistryEntry.h:130
DataSvcHelpers::RegistryEntry::setDataSvc
void setDataSvc(IDataProviderSvc *s)
Set the transient data store.
Definition: RegistryEntry.h:94
gaudirun.level
level
Definition: gaudirun.py:364
IRegistry.h
DataSvcHelpers::RegistryEntry::end
Iterator end() const
Return end elemtn if the container.
Definition: RegistryEntry.h:142
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
DataSvc
Definition: DataSvc.h:43
DataSvcHelpers::RegistryEntry
Definition: RegistryEntry.h:41
DataSvcHelpers::RegistryEntry::dataSvc
IDataProviderSvc * dataSvc() const override
Retrieve pointer to Transient Store.
Definition: RegistryEntry.h:124
Kernel.h
DataObject
Definition: DataObject.h:37
DataSvcHelpers::RegistryEntry::identifier
const std::string & identifier() const override
Full identifier (or key)
Definition: RegistryEntry.h:122
IDataProviderSvc
Definition: IDataProviderSvc.h:48
TsDataSvc
Definition: TsDataSvc.h:53
DataSvcHelpers::RegistryEntry::Iterator
Store::const_iterator Iterator
Iterator definition.
Definition: RegistryEntry.h:51
ProduceConsume.key
key
Definition: ProduceConsume.py:84
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:49
GaudiPython.Persistency.add
def add(instance)
Definition: Persistency.py:50
DataSvcHelpers
Definition: DataSvc.h:28
IDataStoreAgent
Definition: IDataStoreAgent.h:24
DataSvcHelpers::RegistryEntry::parentEntry
RegistryEntry * parentEntry()
Pointer to parent registry entry.
Definition: RegistryEntry.h:96