The Gaudi Framework  v33r1 (b1225454)
RegistryEntry.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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:
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  int 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
IDataProviderSvc * dataSvc() const override
Retrieve pointer to Transient Store.
unsigned long addRef() override
IInterface implementation: Dereference the object.
RegistryEntry * findLeaf(std::string_view path) const
Find identified leaf in this registry node.
std::vector< IRegistry * > Store
Definition of datastore type.
Definition: RegistryEntry.h:49
bool isEmpty() const
Simple check if the Container is empty.
T end(T... args)
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
Data provider interface definition.
RegistryEntry * findLeaf(const DataObject *key) const
Find identified leaf in this registry node.
IRegistry * parent() const
Pointer to parent directory entry.
STL class.
std::string m_fullpath
String containing full path of the object (volatile)
Definition: RegistryEntry.h:64
Iterator end() const
Return end elemtn if the container.
IRegistry * find(std::string_view path) const
Try to find an object identified by its relative name to the directory.
IOpaqueAddress * address() const override
Retrieve opaque storage address.
const std::string & name() const override
Retrieve name of the entry.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
const Store & leaves() const
Access the leaves of the object.
void setDataSvc(IDataProviderSvc *s)
Set the transient data store.
Definition: RegistryEntry.h:99
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
const std::string & identifier() const override
Full identifier (or key)
Store::const_iterator Iterator
Iterator definition.
Definition: RegistryEntry.h:56
Definition of an entry in the transient data store.
Definition: RegistryEntry.h:46
T size(T... args)
DataObject * object() const override
Retrive object behind the link.
Generic data agent interface.
T begin(T... args)
RegistryEntry * parentEntry()
Pointer to parent registry entry.
Data service base class.
Definition: TsDataSvc.h:76
Data service base class.
Definition: DataSvc.h:52
Store m_store
Store of leaves.
Definition: RegistryEntry.h:76
int size() const
Return the size of the container(=number of objects)
string s
Definition: gaudirun.py:328
std::string m_path
Path name.
Definition: RegistryEntry.h:66
const Gaudi::Algorithm & parent
bool isSoft() const
Is the link soft or hard.
Opaque address interface definition.
#define GAUDI_API
Definition: Kernel.h:81
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
Iterator begin() const
Return starting point for container iteration.