ATLAS Offline Software
Loading...
Searching...
No Matches
Control/SGTools/SGTools/DataStore.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef STOREGATE_DATASTORE_H
6#define STOREGATE_DATASTORE_H
11
12
13#include "SGTools/ProxyMap.h"
14#include "SGTools/T2pMap.h"
18#include "SGCore/sgkey_t.h"
20#include "GaudiKernel/ClassID.h"
21#include "GaudiKernel/SmartIF.h"
22#include "GaudiKernel/StatusCode.h"
23
24#include <exception>
25#include <list>
26#include <vector>
27#include <map>
28#include <string>
29#include <typeinfo> /*typeid*/
30#include <utility> /*std::pair*/
31#include <unordered_map>
32#include <mutex>
33
34
35class ISvcLocator;
36class ISGAudSvc;
37class MsgStream;
39
40namespace SG {
41
42 class DataProxy;
43
44
74 {
75
76 public:
77
79 typedef std::map<CLID, SG::ProxyMap> StoreMap;
80 typedef StoreMap::iterator StoreIterator;
81 typedef StoreMap::const_iterator ConstStoreIterator;
82
83 typedef std::pair<SG::ConstProxyIterator, SG::ConstProxyIterator> constProxyRange;
84
90 virtual ~DataStore();
91
93 virtual StoreID::type storeID() const override { return m_storeID; }
94
95 // If FORCE is true, then force deleting of all proxies,
96 // even if they would normally only be reset.
100 void clearStore(bool force, bool hard, MsgStream* pmlog);
101
104
105 virtual StatusCode addToStore(const CLID& id, DataProxy* proxy) override;
108 virtual DataProxy* proxy(const TransientAddress* tAddr) const override;
110 virtual DataProxy* proxy(const CLID& id,
111 const std::string& key=SG::DEFAULTKEY) const override;
112
115 virtual SG::DataProxy* proxy_exact (sgkey_t sgkey) const override;
116
122 std::recursive_mutex& mutex) const;
123
126 virtual SG::DataProxy* proxy_exact(const CLID& id,
127 const std::string& key) const override;
128
134 StatusCode removeProxy(DataProxy* proxy, bool forceRemove, bool hard);
135
137 StatusCode addSymLink(const CLID& linkid, DataProxy* proxy);
138
140 virtual StatusCode addAlias(const std::string& aliasKey, DataProxy* proxy) override;
141
143 int typeCount(const CLID& id) const;
144
146 StatusCode tRange(ConstStoreIterator& f, ConstStoreIterator& e) const;
147
149 StatusCode pRange(const CLID& id, SG::ConstProxyIterator& f,
150 SG::ConstProxyIterator& e) const;
151
152
154 void setPac(IPageAccessControlSvc* pac) { m_t2p.setPac(pac); }
156 std::vector<const DataProxy*> pacReport() const { return m_t2p.pacReport();}
157
159 StatusCode t2pRegister(const void* const pTrans, DataProxy* const pPers);
160 void t2pRemove(const void* const pTrans);
161
163 DataProxy* locatePersistent(const void* const pTransient) const;
164
165 // return list of keys associated with an object
166 void keys(const CLID& id, std::vector<std::string>& vkeys,
167 bool includeAlias, bool onlyValid);
168
171 const std::vector<DataProxy*>& proxies() const;
172
173
174 private:
177
180 std::vector<DataProxy*> m_proxies;
181
184
188
190
191 // Map to hold the relation between transient and persistent object:
192 // we have changed to DataProxy as it is faster while recording
193 // to check if it already exists
195
196 void setSGAudSvc();
197 SmartIF<ISGAudSvc> m_pSGAudSvc;
199 inline bool doAudit() {
200 if (!m_noAudSvc) setSGAudSvc();
201 return (m_pSGAudSvc);
202 }
203
204 ISvcLocator* m_pSvcLoc;
205 StatusCode setSvcLoc();
206
207
226 DataProxy* findDummy (CLID id, const std::string& key);
227
228
233 StatusCode removeFromKeyMap (DataProxy* proxy);
234
235
244 StatusCode
246 };
247
248 inline void
249 DataStore::t2pRemove(const void* const pTrans)
250 {
251 m_t2p.t2pRemove(pTrans);
252 }
253
254} //end namespace SG
255
256
257#endif // STOREGATE_DATASTORE
uint32_t CLID
The Class ID type.
DataStore(IProxyDict &pool)
Constructor.
Interface to a service that monitors memory page accesses.
a proxy registry (a read/write dictionary)
SG::sgkey_t sgkey_t
Type of the keys.
Definition IStringPool.h:34
std::pair< SG::ConstProxyIterator, SG::ConstProxyIterator > constProxyRange
ConcurrentSGKeyMap< DataProxy * > KeyMap_t
Map of hashed sgkey -> DataProxy.
virtual StatusCode addToStore(const CLID &id, DataProxy *proxy) override
add proxy to store.
std::map< CLID, SG::ProxyMap > StoreMap
StatusCode removeFromKeyMap(DataProxy *proxy)
Remove a proxy from m_keyMap.
DataStore(IProxyDict &pool)
Constructor.
DataProxy * locatePersistent(const void *const pTransient) const
locate the persistent (proxy) for a given T* (void*):
int typeCount(const CLID &id) const
Count number of object of a given type in store.
virtual StatusCode addAlias(const std::string &aliasKey, DataProxy *proxy) override
add alias to store
std::vector< const DataProxy * > pacReport() const
request an access control report, i.e. a list of proxies that have not been accessed since monitored
std::vector< DataProxy * > m_proxies
All proxies managed by this store.
IProxyDict & m_pool
The string pool associated with this store.
StatusCode addSymLink(const CLID &linkid, DataProxy *proxy)
add symlink to store:
StatusCode t2pRegister(const void *const pTrans, DataProxy *const pPers)
methods to query the T2PMap:
StatusCode tRange(ConstStoreIterator &f, ConstStoreIterator &e) const
Return an iterator over the StoreMap:
virtual StoreID::type storeID() const override
SG::DataProxy * proxy_exact_unlocked(sgkey_t sgkey, std::recursive_mutex &mutex) const
Like proxy_exact, but intended to be called without holding the store lock.
void keys(const CLID &id, std::vector< std::string > &vkeys, bool includeAlias, bool onlyValid)
StatusCode pRange(const CLID &id, SG::ConstProxyIterator &f, SG::ConstProxyIterator &e) const
Return an iterator over proxy for a given CLID:
StoreMap::const_iterator ConstStoreIterator
StoreMap m_storeMap
Maps locating proxies by clid/key.
void setStoreID(StoreID::type id)
virtual DataProxy * proxy(const TransientAddress *tAddr) const override
return proxy for a given type/key pair if key is empty returns the default proxy (currently last regi...
StatusCode removeProxy(DataProxy *proxy, bool forceRemove, bool hard)
remove proxy from store, unless proxy is reset only.
void t2pRemove(const void *const pTrans)
const std::vector< DataProxy * > & proxies() const
All proxies managed by this store.
StatusCode removeProxyImpl(DataProxy *proxy, int index)
Helper for removing a proxy.
void setPac(IPageAccessControlSvc *pac)
set IPageAccessControlSvc ptr in T2PMap
DataProxy * findDummy(CLID id, const std::string &key)
Look for (and convert) a matching dummy proxy.
virtual SG::DataProxy * proxy_exact(sgkey_t sgkey) const override
get proxy with given key.
void clearStore(bool force, bool hard, MsgStream *pmlog)
If HARD is true, then the bound objects should also clear any data that depends on the identity of th...
STL class.
Forward declaration.
CxxUtils::ConcurrentMap< sgkey_t, T, CxxUtils::SimpleUpdater, SGKeyHash, SGKeyEqual, 0, s_sgkey_nullval > ConcurrentSGKeyMap
A concurrent map using sgkey_t as key.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
const std::string DEFAULTKEY
Definition DefaultKey.h:12
ProxyMap::const_iterator ConstProxyIterator
Definition ProxyMap.h:24
Definition index.py:1
pool namespace
Definition libname.h:15
Additional utilities and types related to sgkey_t.