File indexing completed on 2025-01-31 10:09:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef GAUDIKERNEL_REGISTRYENTRY_H
0012 #define GAUDIKERNEL_REGISTRYENTRY_H
0013
0014
0015 #include "GaudiKernel/IRegistry.h"
0016 #include "GaudiKernel/Kernel.h"
0017 #include "GaudiKernel/StatusCode.h"
0018
0019
0020 #include <string_view>
0021 #include <vector>
0022
0023
0024 class DataSvc;
0025
0026 class TsDataSvc;
0027 class DataObject;
0028 class IDataProviderSvc;
0029 class IOpaqueAddress;
0030 class IDataStoreAgent;
0031
0032 namespace DataSvcHelpers {
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 class GAUDI_API RegistryEntry final : public IRegistry {
0047 private:
0048
0049 typedef std::vector<IRegistry*> Store;
0050
0051 public:
0052 friend class ::DataSvc;
0053
0054 friend class ::TsDataSvc;
0055
0056 typedef Store::const_iterator Iterator;
0057
0058 private:
0059
0060 unsigned long m_refCount = 0;
0061
0062 bool m_isSoft = false;
0063
0064 std::string m_fullpath;
0065
0066 std::string m_path;
0067
0068 RegistryEntry* m_pParent = nullptr;
0069
0070 IOpaqueAddress* m_pAddress = nullptr;
0071
0072 DataObject* m_pObject = nullptr;
0073
0074 IDataProviderSvc* m_pDataProviderSvc = nullptr;
0075
0076 Store m_store;
0077
0078 private:
0079
0080
0081
0082
0083
0084
0085 void assemblePath( std::string& buffer ) const;
0086
0087 IRegistry* i_find( const IRegistry* pDirectory ) const;
0088
0089 RegistryEntry* i_find( std::string_view path ) const;
0090
0091 RegistryEntry* i_find( const DataObject* pObject ) const;
0092
0093 RegistryEntry* i_create( std::string name );
0094
0095 long i_add( RegistryEntry* entry );
0096
0097 void setParent( RegistryEntry* pParent );
0098
0099 void setDataSvc( IDataProviderSvc* s ) { m_pDataProviderSvc = s; }
0100
0101 RegistryEntry* parentEntry() { return m_pParent; }
0102
0103 RegistryEntry* findLeaf( std::string_view path ) const { return i_find( path ); }
0104
0105 RegistryEntry* findLeaf( const DataObject* key ) const { return i_find( key ); }
0106
0107 void makeHard( DataObject* pObject );
0108
0109 void makeHard( IOpaqueAddress* pAddress );
0110
0111 void makeSoft( DataObject* pObject );
0112
0113 void makeSoft( IOpaqueAddress* pAddress );
0114
0115 public:
0116
0117 RegistryEntry( std::string path, RegistryEntry* parent = nullptr );
0118
0119 ~RegistryEntry() override;
0120
0121 unsigned long release() override;
0122
0123 unsigned long addRef() override { return ++m_refCount; }
0124
0125 const std::string& name() const override { return m_path; }
0126
0127 const std::string& identifier() const override { return m_fullpath; }
0128
0129 IDataProviderSvc* dataSvc() const override { return m_pDataProviderSvc; }
0130
0131 DataObject* object() const override { return m_pObject; }
0132
0133 IOpaqueAddress* address() const override { return m_pAddress; }
0134
0135 IRegistry* parent() const { return m_pParent; }
0136
0137 bool isSoft() const { return m_isSoft; }
0138
0139 const Store& leaves() const { return m_store; }
0140
0141 size_t size() const { return m_store.size(); }
0142
0143 bool isEmpty() const { return m_store.size() == 0; }
0144
0145 Iterator begin() const { return m_store.begin(); }
0146
0147 Iterator end() const { return m_store.end(); }
0148
0149 IRegistry* find( const IRegistry* obj ) const { return i_find( obj ); }
0150
0151 IRegistry* find( std::string_view path ) const { return i_find( path ); }
0152
0153 void setAddress( IOpaqueAddress* pAddress ) override;
0154
0155 void setObject( DataObject* obj );
0156
0157
0158 StatusCode add( std::string name, DataObject* pObject, bool is_soft = false );
0159
0160 StatusCode add( std::string name, IOpaqueAddress* pAddress, bool is_soft = false );
0161
0162 StatusCode remove( std::string_view name );
0163
0164 long add( IRegistry* obj );
0165
0166 long remove( IRegistry* obj );
0167
0168 long deleteElements();
0169
0170 StatusCode traverseTree( IDataStoreAgent* pAgent, int level = 0 );
0171 };
0172 }
0173 #endif