Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Types | Public Member Functions | List of all members
SG::DataStore Class Reference

Hold DataProxy instances associated with a store. More...

#include <DataStore.h>

Inheritance diagram for SG::DataStore:
Collaboration diagram for SG::DataStore:

Public Types

typedef IStringPool::sgkey_t sgkey_t
 
typedef std::map< CLID, SG::ProxyMapStoreMap
 
typedef StoreMap::iterator StoreIterator
 
typedef StoreMap::const_iterator ConstStoreIterator
 
typedef std::pair< SG::ConstProxyIterator, SG::ConstProxyIteratorconstProxyRange
 

Public Member Functions

 DataStore (IProxyDict &pool)
 Constructor. More...
 
virtual ~DataStore ()
 
void setStoreID (StoreID::type id)
 
virtual StoreID::type storeID () const
 
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 the current event store. More...
 

Implementation of IProxyRegistry.

using KeyMap_t = CxxUtils::ConcurrentMap< sgkey_t, DataProxy *, CxxUtils::SimpleUpdater, SGKeyHash, SGKeyEqual, 0, s_nullval >
 
IProxyDictm_pool
 The string pool associated with this store. More...
 
std::vector< DataProxy * > m_proxies
 All proxies managed by this store. More...
 
StoreMap m_storeMap
 Maps locating proxies by clid/key. More...
 
KeyMap_t m_keyMap
 
StoreID::type m_storeID
 
T2pMap m_t2p
 
SmartIF< ISGAudSvcm_pSGAudSvc
 
bool m_noAudSvc
 
ISvcLocator * m_pSvcLoc
 
static constexpr CxxUtils::detail::ConcurrentHashmapVal_t s_nullval
 Map of hashed sgkey -> DataProxy. More...
 
virtual StatusCode addToStore (const CLID &id, DataProxy *proxy)
 add proxy to store. More...
 
virtual DataProxyproxy (const TransientAddress *tAddr) const
 return proxy for a given type/key pair if key is empty returns the default proxy (currently last registered) More...
 
virtual DataProxyproxy (const CLID &id, const std::string &key=SG::DEFAULTKEY) const
 get proxy with given id. Returns 0 to flag failure More...
 
SG::DataProxyproxy_exact (sgkey_t sgkey) const
 get proxy with given key. More...
 
SG::DataProxyproxy_exact_unlocked (sgkey_t sgkey, std::recursive_mutex &mutex) const
 Like proxy_exact, but intended to be called without holding the store lock. More...
 
virtual SG::DataProxyproxy_exact (const CLID &id, const std::string &key) const
 get proxy with given id. More...
 
StatusCode removeProxy (DataProxy *proxy, bool forceRemove, bool hard)
 remove proxy from store, unless proxy is reset only. More...
 
StatusCode addSymLink (const CLID &linkid, DataProxy *proxy)
 add symlink to store: More...
 
StatusCode addAlias (const std::string &aliasKey, DataProxy *proxy)
 add alias to store More...
 
int typeCount (const CLID &id) const
 Count number of object of a given type in store. More...
 
StatusCode tRange (ConstStoreIterator &f, ConstStoreIterator &e) const
 Return an iterator over the StoreMap: More...
 
StatusCode pRange (const CLID &id, SG::ConstProxyIterator &f, SG::ConstProxyIterator &e) const
 Return an iterator over proxy for a given CLID: More...
 
void setPac (IPageAccessControlSvc *pac)
 set IPageAccessControlSvc ptr in T2PMap More...
 
std::vector< const DataProxy * > pacReport () const
 request an access control report, i.e. a list of proxies that have not been accessed since monitored More...
 
StatusCode t2pRegister (const void *const pTrans, DataProxy *const pPers)
 methods to query the T2PMap: More...
 
void t2pRemove (const void *const pTrans)
 
DataProxylocatePersistent (const void *const pTransient) const
 locate the persistent (proxy) for a given T* (void*): More...
 
void keys (const CLID &id, std::vector< std::string > &vkeys, bool includeAlias, bool onlyValid)
 
const std::vector< DataProxy * > & proxies () const
 All proxies managed by this store. More...
 
void setSGAudSvc ()
 
bool doAudit ()
 
StatusCode setSvcLoc ()
 
DataProxyfindDummy (CLID id, const std::string &key)
 Look for (and convert) a matching dummy proxy. More...
 
StatusCode removeFromKeyMap (DataProxy *proxy)
 Remove a proxy from m_keyMap. More...
 
StatusCode removeProxyImpl (DataProxy *proxy, int index)
 Helper for removing a proxy. More...
 

Detailed Description

Hold DataProxy instances associated with a store.

We hold proxies in several ways, for efficiency.

First, all proxies that we manage are entered in the m_proxies vector. A given proxy appears only once in this list.

Second, m_keyMap stores proxies indexed by the hashed CLID/key. A proxy may be entered here multiple times in the case of symlinks or alias; however, the entry corresponding to what proxy->sgkey() returns is called the ‘primary’ entry.

Third, proxies are stored by CLID/key in m_storeMap. This is a map indexed by CLID; the values are maps indexed by key. A proxy may again be stored several times in this map in the case of symlinks/aliases.

A proxy may be given to the store that has the hashed key set, but not the CLID/key. This is referred to as a ‘dummy’ proxy. This can happen when we read a link to an object that's not described in the event's DataHeader. In this case, the proxy is entered in m_proxies and m_keyMap, but not in m_storeMap. If we later look for a proxy by CLID/key and don't find it, we also look in m_keyMap to see if a dummy proxy has been entered there. If so, that point we fill in the CLID/key fields of the proxy and also enter it in m_storeMap.

Definition at line 73 of file Control/SGTools/SGTools/DataStore.h.

Member Typedef Documentation

◆ constProxyRange

Definition at line 83 of file Control/SGTools/SGTools/DataStore.h.

◆ ConstStoreIterator

typedef StoreMap::const_iterator SG::DataStore::ConstStoreIterator

Definition at line 81 of file Control/SGTools/SGTools/DataStore.h.

◆ KeyMap_t

Definition at line 189 of file Control/SGTools/SGTools/DataStore.h.

◆ sgkey_t

Definition at line 78 of file Control/SGTools/SGTools/DataStore.h.

◆ StoreIterator

typedef StoreMap::iterator SG::DataStore::StoreIterator

Definition at line 80 of file Control/SGTools/SGTools/DataStore.h.

◆ StoreMap

Definition at line 79 of file Control/SGTools/SGTools/DataStore.h.

Constructor & Destructor Documentation

◆ DataStore()

DataStore::DataStore ( IProxyDict pool)

Constructor.

Parameters
poolThe string pool associated with this store.

Definition at line 31 of file Control/SGTools/src/DataStore.cxx.

32  : m_pool (pool),
33  m_storeMap(),
34  m_keyMap(KeyMap_t::Updater_t()),
36  m_noAudSvc(0), m_pSvcLoc(0)
37 {
38  setSvcLoc().ignore();
39 }

◆ ~DataStore()

DataStore::~DataStore ( )
virtual

Definition at line 42 of file Control/SGTools/src/DataStore.cxx.

43 {
44  clearStore(false, true, nullptr);
45 }

Member Function Documentation

◆ addAlias()

StatusCode DataStore::addAlias ( const std::string &  aliasKey,
DataProxy proxy 
)
virtual

add alias to store

Implements IProxyRegistry.

Definition at line 380 of file Control/SGTools/src/DataStore.cxx.

381 {
382  for (CLID clid : dp->transientID()) {
383  // locate proxy map and add alias to proxymap
384  ProxyMap& pmap = m_storeMap[clid];
385 
386  // check if another proxy for the same type caries the same alias.
387  // if yes, then remove that alias from that proxy and establish the
388  // alias in the new proxy.
389  // pmap.insert will overwrite, associate alias with new proxy.
390  ConstProxyIterator p_iter = pmap.find(aliasKey);
391  if (p_iter != pmap.end() && dp->clID() == p_iter->second->clID()) {
392  if (dp->name() == p_iter->second->name()) return StatusCode::SUCCESS;
393  p_iter->second->removeAlias(aliasKey);
394  p_iter->second->release();
395  }
396  dp->addRef();
397  pmap[aliasKey] = dp;
398  m_keyMap.emplace (m_pool.stringToKey (aliasKey, clid), dp);
399  }
400 
401  // set alias in proxy
402  dp->setAlias(aliasKey);
403 
404  return StatusCode::SUCCESS;
405 }

◆ addSymLink()

StatusCode DataStore::addSymLink ( const CLID linkid,
DataProxy proxy 
)

add symlink to store:

Definition at line 333 of file Control/SGTools/src/DataStore.cxx.

334 {
335  // Make sure the symlink doesn't already exist.
336  DataProxy* exist = proxy_exact (linkid, dp->name());
337  if (exist == dp) {
338  // Entry already exists pointing at the desired proxy.
339  return StatusCode::SUCCESS;
340  }
341  else if (!exist) {
342  dp->setTransientID(linkid);
343  return addToStore(linkid, dp);
344  }
345 
346  // Already an existing proxy.
347  if (exist->isValidObject()) {
348  // And it's set to something. Ok if it's the same DataObject.
349  // Otherwise fail.
350  if (exist->object() == dp->object()) {
351  dp->setTransientID(linkid);
352  return StatusCode::SUCCESS;
353  }
354  return StatusCode::FAILURE;
355  }
356  if (!dp->object()) {
357  return StatusCode::FAILURE;
358  }
359  if (exist->loader()) {
360  return StatusCode::FAILURE;
361  }
362 
363  // The existing proxy is not set to anything, and it doesn't have a loader.
364  // It may have been created by a forward-declared link to a base class.
365  // In that case, set the existing proxy to also point at the same DataObject.
366  const SG::BaseInfoBase* bib = SG::BaseInfoBase::find (dp->clID());
367  if (bib && bib->is_base (exist->clID())) {
368  dp->setTransientID(linkid);
369  exist->setObject (dp->object(), false);
370  return StatusCode::SUCCESS;
371  }
372 
373  // Entry already exists pointing at another proxy.
374  // Don't change the existing entry.
375  return StatusCode::FAILURE;
376 }

◆ addToStore()

StatusCode DataStore::addToStore ( const CLID id,
DataProxy proxy 
)
virtual

add proxy to store.

If this proxy has not yet been added to the store, then make an entry for it in m_proxies.

Implements IProxyRegistry.

Definition at line 142 of file Control/SGTools/src/DataStore.cxx.

143 {
144  if (!dp) {
145  return StatusCode::FAILURE;
146  }
147 
150  bool primary = false;
151  if (dp->store() == nullptr) {
152  m_proxies.push_back (dp);
153  primary = true;
154  }
155 
156  if (id == 0 && dp->clID() == 0 && dp->sgkey() != 0) {
157  // Handle a dummied proxy.
158  m_keyMap.emplace (dp->sgkey(), dp);
159  }
160  else {
161  ProxyMap& pmap = m_storeMap[id];
162 
163  // Set the primary key.
164  sgkey_t primary_sgkey = m_pool.stringToKey (dp->name(), dp->clID());
165  sgkey_t sgkey = primary_sgkey;
166  if (id != dp->clID()) {
167  sgkey = m_pool.stringToKey (dp->name(), id);
168  }
169  if (dp->sgkey() == 0) {
170  dp->setSGKey (sgkey);
171  }
172 
173  if (!m_keyMap.emplace (sgkey, dp).second) {
174  if (primary) {
175  m_proxies.pop_back();
176  }
177  return StatusCode::FAILURE;
178  }
179 
180  pmap.insert(ProxyMap::value_type(dp->name(), dp));
181  }
182 
183  // Note : No checking if proxy already exists in store because it
184  // is already checked in StoreGateSvc.
185  // if (pmap.find(dp->name()) == pmap.end()) {
186  dp->addRef(); // The store now owns this
187  dp->setT2p(&m_t2p);
188  dp->setStore(&m_pool);
189 
190  return StatusCode::SUCCESS;
191 }

◆ clearStore()

void DataStore::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 the current event store.

(See IResetable.h.)

Be careful with changing this — it's important for performance for some analysis use cases.

Rather than dealing with erasures in m_keyMap, we first do the removals just from m_storeMap, remembering along the way the set of proxies to be removed (not reset-ony). Then if there were any such proxies, we run through the entries in m_keyMap and copy all that match one of the reset-only proxies to a new map and then swap. (We can't ask the proxy itself if it's reset-only at this point because if it isn't, it'll have been deleted.)

Go through the list of unique proxies, and run requestRelease() on each. If that returns true, then we're meant to remove this proxy from the store. Be careful that removing a proxy from the store will modify the m_proxies list, so if the proxy is successfully removed, we should not bump the index.

Definition at line 68 of file Control/SGTools/src/DataStore.cxx.

69 {
72 
80  std::unordered_set<DataProxy*> removed;
81 
87  for (size_t i = 0; i < m_proxies.size(); ) {
89  if (ATH_UNLIKELY (dp->requestRelease (force, hard))) {
90  removed.insert (dp);
91  if (removeProxyImpl (dp, i).isFailure()) {
92  ++i;
93  }
94  }
95  else {
96  ++i;
97  }
98  }
99 
100  if (!removed.empty()) {
101  KeyMap_t newMap (KeyMap_t::Updater_t(), m_keyMap.capacity());
102  {
103  auto lock = newMap.lock();
104  auto ctx = KeyMap_t::Updater_t::defaultContext();
105  for (auto p : m_keyMap) {
106  if (removed.count (p.second) == 0) {
107  newMap.emplace (lock, p.first, p.second, ctx);
108  }
109  }
110  }
111  m_keyMap.swap (newMap);
112  }
113 
114  // clear T2PMap
115  m_t2p.clear();
116 }

◆ doAudit()

bool SG::DataStore::doAudit ( )
inlineprivate

Definition at line 206 of file Control/SGTools/SGTools/DataStore.h.

206  {
207  if (!m_noAudSvc) setSGAudSvc();
208  return (m_pSGAudSvc);
209  }

◆ findDummy()

DataProxy * DataStore::findDummy ( CLID  id,
const std::string &  key 
)
private

Look for (and convert) a matching dummy proxy.

Parameters
idThe CLID for which to search.
keyThe key for which to search.

In some cases, we may enter into the store a ‘dummy’ proxy, which is identified only by the hashed CLID/key pair. (This can happen when we have a link to an object that's not listed in the DataHeader; in this case, we know the only hashed key and not the CLID or key.)

This function is called after we fail to find a proxy by CLID/key. It additionally checks to see if there exists a dummy proxy with a hash matching this CLID/key. If so, the CLID/key are filled in in the proxy, and the proxy is entered in m_storeMap.

Returns either the matching proxy or 0.

Definition at line 508 of file Control/SGTools/src/DataStore.cxx.

509 {
512  if (p) {
513  p->setID (id, key);
514  ProxyMap& pmap = m_storeMap[id];
515  if (!pmap.insert(ProxyMap::value_type(key, p)).second) {
516  // This shouldn't happen.
517  DataProxy* p2 = pmap[key];
518  throw SG::ExcProxyCollision (id, key, p2->clID(), p2->name());
519  }
520  }
521  return p;
522 }

◆ keys()

void DataStore::keys ( const CLID id,
std::vector< std::string > &  vkeys,
bool  includeAlias,
bool  onlyValid 
)

Definition at line 121 of file Control/SGTools/src/DataStore.cxx.

123 {
124  vkeys.clear();
125  for (const ProxyMap::value_type& p : m_storeMap[id]) {
126  bool includeProxy(true);
127  if (onlyValid) includeProxy=p.second->isValid();
128  if (includeAlias) {
129  if (includeProxy) vkeys.push_back(p.first);
130  }
131  else {
132  if (p.first == p.second->name() && includeProxy)
133  vkeys.push_back(p.first);
134  }
135  }
136 }

◆ locatePersistent()

DataProxy * DataStore::locatePersistent ( const void *const  pTransient) const

locate the persistent (proxy) for a given T* (void*):

Definition at line 609 of file Control/SGTools/src/DataStore.cxx.

610 {
611  return m_t2p.locatePersistent(pTransient);
612 }

◆ pacReport()

std::vector<const DataProxy*> SG::DataStore::pacReport ( ) const
inline

request an access control report, i.e. a list of proxies that have not been accessed since monitored

Definition at line 156 of file Control/SGTools/SGTools/DataStore.h.

156 { return m_t2p.pacReport();}

◆ pRange()

StatusCode DataStore::pRange ( const CLID id,
SG::ConstProxyIterator f,
SG::ConstProxyIterator e 
) const

Return an iterator over proxy for a given CLID:

Definition at line 577 of file Control/SGTools/src/DataStore.cxx.

579 {
580  static const ProxyMap emptyMap;
581  StatusCode sc(StatusCode::FAILURE);
582 
583  ConstStoreIterator storeIter = m_storeMap.find(id);
584  if (storeIter != m_storeMap.end())
585  {
586  const ProxyMap& pmap = storeIter->second;
587  pf = pmap.begin();
588  pe = pmap.end();
589  if (pmap.size() > 0) sc = StatusCode::SUCCESS;
590  } else {
591  //keep valgrind happy
592  pf = emptyMap.end();
593  pe = emptyMap.end();
594  }
595  return sc;
596 }

◆ proxies()

const std::vector< DataProxy * > & DataStore::proxies ( ) const

All proxies managed by this store.

Every proxy appears exactly once in this list.

Definition at line 630 of file Control/SGTools/src/DataStore.cxx.

631 {
632  return m_proxies;
633 }

◆ proxy() [1/2]

DataProxy * DataStore::proxy ( const CLID id,
const std::string &  key = SG::DEFAULTKEY 
) const
virtual

get proxy with given id. Returns 0 to flag failure

Implements IProxyRegistry.

Definition at line 423 of file Control/SGTools/src/DataStore.cxx.

424 {
425 
426  // The logic here: if a key is specified, we locate it.
427  // If we don't find it and the default key (DEFAULTKEY) is specified,
428  // then we return any existing proxy for this type as long as there
429  // is exactly one, not counting aliases. More than one would be ambiguous
430 
431  ConstStoreIterator siter = m_storeMap.find(id);
432  DataProxy *p(0);
433  if (siter != m_storeMap.end())
434  {
435  const ProxyMap& pmap = siter->second;
436  ConstProxyIterator p_iter = pmap.find(key);
437  if (p_iter != pmap.end()) {
438  p=p_iter->second;
439 
440  } else if (key == SG::DEFAULTKEY && !pmap.empty()) {
441  // we did not find the object using key.
442  // Now check for default object.
443  // If there are multiple entries, they must all be
444  // referring to the same proxy (aliases).
445  for (const auto& ent : pmap) {
446  if (!p) {
447  p = ent.second;
448  }
449  else if (p != ent.second) {
450  p = nullptr;
451  break;
452  }
453  }
454 
455  // If that didn't work, try it again, considering only objects that
456  // are exactly the type being requested.
457  if (!p) {
458  for (const auto& ent : pmap) {
459  if (ent.second->clID() == id) {
460  if (!p) {
461  p = ent.second;
462  }
463  else if (p != ent.second) {
464  p = nullptr;
465  break;
466  }
467  }
468  }
469  }
470  }
471  else {
472  // Ok since access to DataStore is serialized by StoreGate.
473  DataStore* nc_store ATLAS_THREAD_SAFE = const_cast<DataStore*> (this);
474  p = nc_store->findDummy (id, key);
475  }
476  }
477  else {
478  // Ok since access to DataStore is serialized by StoreGate.
479  DataStore* nc_store ATLAS_THREAD_SAFE = const_cast<DataStore*> (this);
480  p = nc_store->findDummy (id, key);
481  }
482 
483  if (p && m_pSGAudSvc)
484  m_pSGAudSvc->SGAudit(p->name(), id, 0, m_storeID);
485 
486  return p;
487 }

◆ proxy() [2/2]

DataProxy * DataStore::proxy ( const TransientAddress tAddr) const
virtual

return proxy for a given type/key pair if key is empty returns the default proxy (currently last registered)

Implements IProxyRegistry.

Definition at line 417 of file Control/SGTools/src/DataStore.cxx.

418 {
419  return proxy(tAddr->clID(), tAddr->name());
420 }

◆ proxy_exact() [1/2]

DataProxy * DataStore::proxy_exact ( const CLID id,
const std::string &  key 
) const
virtual

get proxy with given id.

get proxy with given key.

Returns 0 to flag failure the key must match exactly (no wild carding for the default key)

Implements IProxyRegistry.

Definition at line 565 of file Control/SGTools/src/DataStore.cxx.

567 {
568  // Suppress warning here about calling to a nonconst method
569  // of m_pool. Ok since all callers here must own the store lock.
571  return proxy_exact (pool_nc.stringToKey (key, id));
572 }

◆ proxy_exact() [2/2]

DataProxy * DataStore::proxy_exact ( sgkey_t  sgkey) const

get proxy with given key.

Returns 0 to flag failure the key must match exactly (no wild carding for the default key)

Definition at line 527 of file Control/SGTools/src/DataStore.cxx.

528 {
529  if (m_pSGAudSvc) {
530  CLID clid;
531  const std::string* strkey = m_pool.keyToString (sgkey, clid);
532  if (strkey)
533  m_pSGAudSvc->SGAudit(*strkey, clid, 0, m_storeID);
534  }
535  KeyMap_t::const_iterator i = m_keyMap.find (sgkey);
536  if (i != m_keyMap.end())
537  return i->second;
538  return 0;
539 }

◆ proxy_exact_unlocked()

DataProxy * DataStore::proxy_exact_unlocked ( sgkey_t  sgkey,
std::recursive_mutex &  mutex 
) const

Like proxy_exact, but intended to be called without holding the store lock.

However, the store lock still must be passed as an argument; it will be acquired should be need to call the auditor service.

Definition at line 546 of file Control/SGTools/src/DataStore.cxx.

548 {
549  if (m_pSGAudSvc) {
550  std::unique_lock lock (mutex);
551  CLID clid;
552  const std::string* strkey = m_pool.keyToString (sgkey, clid);
553  if (strkey)
554  m_pSGAudSvc->SGAudit(*strkey, clid, 0, m_storeID);
555  }
556  KeyMap_t::const_iterator i = m_keyMap.find (sgkey);
557  if (i != m_keyMap.end())
558  return i->second;
559  return 0;
560 }

◆ removeFromKeyMap()

StatusCode DataStore::removeFromKeyMap ( DataProxy proxy)
private

Remove a proxy from m_keyMap.

Parameters
proxyThe proxy being removed.

Definition at line 237 of file Control/SGTools/src/DataStore.cxx.

238 {
239  SG::DataProxy::AliasCont_t alias_set = proxy->alias();
240  std::string name = proxy->name();
241 
242  for (CLID symclid : proxy->transientID())
243  {
244  sgkey_t sgkey = m_pool.stringToKey (name, symclid);
245  m_keyMap.erase (sgkey);
246 
247  for (const std::string& alias : alias_set) {
248  m_keyMap.erase (m_pool.stringToKey (alias, symclid));
249  }
250  }
251 
252  return StatusCode::SUCCESS;
253 }

◆ removeProxy()

StatusCode DataStore::removeProxy ( DataProxy proxy,
bool  forceRemove,
bool  hard 
)

remove proxy from store, unless proxy is reset only.


Parameters
forceRemoveremove the proxy no matter what If HARD is true, then the bound objects should also clear any data that depends on the identity of the current event store. (See IResetable.h.)

Definition at line 199 of file Control/SGTools/src/DataStore.cxx.

200 {
201  if (!proxy) {
202  return StatusCode::FAILURE;
203  }
204 
205  if (!forceRemove && proxy->isResetOnly()) {
206  // A reset-only proxy. Don't remove it.
207  proxy->reset (hard);
208  return StatusCode::SUCCESS;
209  }
210 
211  // First remove from m_keyMap.
212  // We may fail to find the entry if this is a key that has been versioned.
213  // E.g., we add aVersObj. Call this DP1.
214  // Then we add a new version of it. Call this DP2.
215  // The version logic will add the alias ';00;aVersObj' to DP1.
216  // It will also then add the alias `aVersObj' to DP2.
217  // This will overwrite the entries for DP1 in pmap and m_keyMap.
218  // If we then clear and DP2 is removed first, then the m_keyMap entry
219  // for DP1's primary key will be gone.
220  // FIXME: Should just remove the versioned key code ... it's anyway
221  // not compatible with MT.
222  removeFromKeyMap (proxy).ignore();
223 
224  // Then remove from the m_storeMap and release the proxy.
225  auto it = std::find (m_proxies.begin(), m_proxies.end(), proxy);
226  if (it == m_proxies.end()) {
227  return StatusCode::FAILURE;
228  }
229  return removeProxyImpl (proxy, it - m_proxies.begin());
230 }

◆ removeProxyImpl()

StatusCode DataStore::removeProxyImpl ( DataProxy proxy,
int  index 
)
private

Helper for removing a proxy.

Parameters
proxyThe proxy being removed.
indexThe index of this proxy in m_proxies.

This removes the proxy from m_storeMap and releases it, but does NOT remove it from m_keyMap.

Definition at line 265 of file Control/SGTools/src/DataStore.cxx.

266 {
267  proxy->setStore (nullptr);
268 
269  std::string name = proxy->name();
270  CLID clid = proxy->clID();
271  SG::DataProxy::AliasCont_t alias_set = proxy->alias();
272 
273  // nb. This has to be here, not just before the loop below,
274  // as the proxy may be deleted in the meantime.
276 
277  StoreIterator storeIter = m_storeMap.find(clid);
278  if (storeIter != m_storeMap.end()) {
279  ProxyMap& pmap = storeIter->second;
280 
281  // first remove the alias key:
282  SG::DataProxy::AliasCont_t alias_set = proxy->alias();
283  for (const std::string& alias : alias_set) {
284  if (1 == pmap.erase(alias)) proxy->release();
285  }
286 
287  // Remove primary entry.
288  if (1 == pmap.erase(name)) {
289  proxy->release();
290  }
291  }
292  else {
293  // A dummy proxy.
294  proxy->release();
295  }
296 
297  // Remove all symlinks too.
298  for (CLID symclid : clids)
299  {
300  if (clid == symclid) continue;
301  storeIter = m_storeMap.find(symclid);
302  if (storeIter != m_storeMap.end()) {
303  ProxyMap& pmap = storeIter->second;
304  SG::ProxyIterator it = pmap.find (name);
305  if (it != pmap.end() && it->second == proxy) {
306  storeIter->second.erase (it);
307  proxy->release();
308  }
309 
310  for (const std::string& alias : alias_set) {
311  if (1 == pmap.erase (alias)) proxy->release();
312  }
313  }
314  } //symlinks loop
315 
316  if (index != -1 && !m_proxies.empty()) {
317  // Remove the proxy from m_proxies. If it's not at the end, then
318  // move the proxy at the end to this proxy's index (and update the
319  // index for the other proxy stored in m_keyMap).
320  if (index != (int)m_proxies.size() - 1) {
321  m_proxies[index] = m_proxies.back();
322  }
323  m_proxies.pop_back();
324  }
325 
326  return StatusCode::SUCCESS;
327 }

◆ setPac()

void SG::DataStore::setPac ( IPageAccessControlSvc pac)
inline

set IPageAccessControlSvc ptr in T2PMap

Definition at line 154 of file Control/SGTools/SGTools/DataStore.h.

154 { m_t2p.setPac(pac); }

◆ setSGAudSvc()

void DataStore::setSGAudSvc ( )
private

Definition at line 54 of file Control/SGTools/src/DataStore.cxx.

54  {
55  if (!m_pSGAudSvc) {
56  //try once to get the service
57  if (!m_noAudSvc) {
58  const bool DONOTCREATE(false);
59  m_pSGAudSvc = m_pSvcLoc->service("SGAudSvc", DONOTCREATE);
60  m_noAudSvc = not m_pSGAudSvc.isValid();
61  }
62  }
63  return;
64 }

◆ setStoreID()

void SG::DataStore::setStoreID ( StoreID::type  id)
inline

Definition at line 92 of file Control/SGTools/SGTools/DataStore.h.

92 { m_storeID = id;}

◆ setSvcLoc()

StatusCode DataStore::setSvcLoc ( )
private

Definition at line 47 of file Control/SGTools/src/DataStore.cxx.

47  {
48  StatusCode sc(StatusCode::FAILURE);
49  m_pSvcLoc = Gaudi::svcLocator( );
50  if (!m_pSvcLoc) std::cout<<"DataStore::setSvcLoc: WARNING svcLocator not found! "<<std::endl;
51  return sc;
52 }

◆ storeID()

virtual StoreID::type SG::DataStore::storeID ( ) const
inlinevirtual

Implements IProxyRegistry.

Definition at line 93 of file Control/SGTools/SGTools/DataStore.h.

93 { return m_storeID; }

◆ t2pRegister()

StatusCode DataStore::t2pRegister ( const void *const  pTrans,
DataProxy *const  pPers 
)

methods to query the T2PMap:

Definition at line 616 of file Control/SGTools/src/DataStore.cxx.

617 {
618  std::string name=pPers->name();
619  int i=name.find('/', 0);
620  name=name.erase(0,i+1);
621 
622  if (doAudit()) m_pSGAudSvc->SGAudit(name, pPers->clID(), 1, m_storeID);
623 
624  return (m_t2p.t2pRegister(pTrans, pPers)) ?
625  StatusCode::SUCCESS :
626  StatusCode::FAILURE;
627 }

◆ t2pRemove()

void SG::DataStore::t2pRemove ( const void *const  pTrans)
inline

Definition at line 256 of file Control/SGTools/SGTools/DataStore.h.

257  {
258  m_t2p.t2pRemove(pTrans);
259  }

◆ tRange()

StatusCode DataStore::tRange ( ConstStoreIterator f,
ConstStoreIterator e 
) const

Return an iterator over the StoreMap:

Definition at line 599 of file Control/SGTools/src/DataStore.cxx.

601 {
602  tf = m_storeMap.begin();
603  te = m_storeMap.end();
604  return StatusCode::SUCCESS;
605 }

◆ typeCount()

int DataStore::typeCount ( const CLID id) const

Count number of object of a given type in store.

Definition at line 408 of file Control/SGTools/src/DataStore.cxx.

409 {
410  ConstStoreIterator storeIter = m_storeMap.find(id);
411  if (storeIter == m_storeMap.end()) return 0;
412  return (storeIter->second).size();
413 }

Member Data Documentation

◆ m_keyMap

KeyMap_t SG::DataStore::m_keyMap
private

Definition at line 194 of file Control/SGTools/SGTools/DataStore.h.

◆ m_noAudSvc

bool SG::DataStore::m_noAudSvc
private

Definition at line 205 of file Control/SGTools/SGTools/DataStore.h.

◆ m_pool

IProxyDict& SG::DataStore::m_pool
private

The string pool associated with this store.

Definition at line 176 of file Control/SGTools/SGTools/DataStore.h.

◆ m_proxies

std::vector<DataProxy*> SG::DataStore::m_proxies
private

All proxies managed by this store.

Every proxy appears exactly once in this list.

Definition at line 180 of file Control/SGTools/SGTools/DataStore.h.

◆ m_pSGAudSvc

SmartIF<ISGAudSvc> SG::DataStore::m_pSGAudSvc
private

Definition at line 204 of file Control/SGTools/SGTools/DataStore.h.

◆ m_pSvcLoc

ISvcLocator* SG::DataStore::m_pSvcLoc
private

Definition at line 211 of file Control/SGTools/SGTools/DataStore.h.

◆ m_storeID

StoreID::type SG::DataStore::m_storeID
private

Definition at line 196 of file Control/SGTools/SGTools/DataStore.h.

◆ m_storeMap

StoreMap SG::DataStore::m_storeMap
private

Maps locating proxies by clid/key.

Definition at line 183 of file Control/SGTools/SGTools/DataStore.h.

◆ m_t2p

T2pMap SG::DataStore::m_t2p
private

Definition at line 201 of file Control/SGTools/SGTools/DataStore.h.

◆ s_nullval

constexpr CxxUtils::detail::ConcurrentHashmapVal_t SG::DataStore::s_nullval
staticconstexprprivate
Initial value:

Map of hashed sgkey -> DataProxy.

Definition at line 187 of file Control/SGTools/SGTools/DataStore.h.


The documentation for this class was generated from the following files:
SG::ProxyIterator
ProxyMap::iterator ProxyIterator
Definition: ProxyMap.h:27
SG::T2pMap::setPac
void setPac(IPageAccessControlSvc *pac)
set IPageAccessControlSvc ptr in T2PMap
Definition: T2pMap.h:65
common.sgkey
def sgkey(tool)
Definition: common.py:1028
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
calibdata.force
bool force
Definition: calibdata.py:19
SG::T2pMap::locatePersistent
DataProxy * locatePersistent(const void *const pTransient) const
Definition: T2pMap.h:42
CxxUtils::detail::ConcurrentHashmapVal_t
uintptr_t ConcurrentHashmapVal_t
Type used for keys and values — an unsigned big enough to hold a pointer.
Definition: ConcurrentHashmapImpl.h:40
IStringPool::stringToKey
virtual sgkey_t stringToKey(const std::string &str, CLID clid)=0
Find the key for a string/CLID pair.
index
Definition: index.py:1
SG::DataStore::m_t2p
T2pMap m_t2p
Definition: Control/SGTools/SGTools/DataStore.h:201
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
pool
pool namespace
Definition: libname.h:15
SG::DataStore::m_keyMap
KeyMap_t m_keyMap
Definition: Control/SGTools/SGTools/DataStore.h:194
skel.it
it
Definition: skel.GENtoEVGEN.py:407
SG::DataStore::m_storeMap
StoreMap m_storeMap
Maps locating proxies by clid/key.
Definition: Control/SGTools/SGTools/DataStore.h:183
SG::DataStore::addToStore
virtual StatusCode addToStore(const CLID &id, DataProxy *proxy)
add proxy to store.
Definition: Control/SGTools/src/DataStore.cxx:142
SG::DataStore::ConstStoreIterator
StoreMap::const_iterator ConstStoreIterator
Definition: Control/SGTools/SGTools/DataStore.h:81
SG::DataStore::clearStore
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...
Definition: Control/SGTools/src/DataStore.cxx:68
ATH_UNLIKELY
#define ATH_UNLIKELY(x)
Definition: AthUnlikelyMacros.h:17
SG::DataStore::proxy
virtual DataProxy * proxy(const TransientAddress *tAddr) const
return proxy for a given type/key pair if key is empty returns the default proxy (currently last regi...
Definition: Control/SGTools/src/DataStore.cxx:417
LArG4AODNtuplePlotter.pe
pe
Definition: LArG4AODNtuplePlotter.py:116
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
SG::DataProxy::CLIDCont_t
TransientAddress::TransientClidSet CLIDCont_t
Definition: DataProxy.h:54
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::DataStore::removeFromKeyMap
StatusCode removeFromKeyMap(DataProxy *proxy)
Remove a proxy from m_keyMap.
Definition: Control/SGTools/src/DataStore.cxx:237
SG::DataProxy::setStore
void setStore(IProxyDict *store)
Set the store of which we're a part.
SG::DataStore::doAudit
bool doAudit()
Definition: Control/SGTools/SGTools/DataStore.h:206
SG::ProxyMap
std::map< std::string, DataProxy * > ProxyMap
Definition: ProxyMap.h:24
SG::DataStore::StoreIterator
StoreMap::iterator StoreIterator
Definition: Control/SGTools/SGTools/DataStore.h:80
SG::DataStore::proxy_exact
SG::DataProxy * proxy_exact(sgkey_t sgkey) const
get proxy with given key.
Definition: Control/SGTools/src/DataStore.cxx:527
SG::DataStore::setSGAudSvc
void setSGAudSvc()
Definition: Control/SGTools/src/DataStore.cxx:54
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
StateLessPT_NewConfig.primary
primary
Definition: StateLessPT_NewConfig.py:231
WriteCellNoiseToCool.exist
exist
Definition: WriteCellNoiseToCool.py:543
lumiFormat.i
int i
Definition: lumiFormat.py:85
SG::DataStore::m_proxies
std::vector< DataProxy * > m_proxies
All proxies managed by this store.
Definition: Control/SGTools/SGTools/DataStore.h:180
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::DataProxy::alias
AliasCont_t alias() const
access set of proxy aliases Returns a COPY of the alias set.
SG::DataStore::m_pool
IProxyDict & m_pool
The string pool associated with this store.
Definition: Control/SGTools/SGTools/DataStore.h:176
COOLRates.alias
alias
Definition: COOLRates.py:1172
SG::DataStore::m_pSGAudSvc
SmartIF< ISGAudSvc > m_pSGAudSvc
Definition: Control/SGTools/SGTools/DataStore.h:204
SG::T2pMap::t2pRegister
bool t2pRegister(const void *const pTrans, DataProxy *const pPers)
Definition: T2pMap.h:34
SG::DataStore::m_pSvcLoc
ISvcLocator * m_pSvcLoc
Definition: Control/SGTools/SGTools/DataStore.h:211
SG::DataStore::sgkey_t
IStringPool::sgkey_t sgkey_t
Definition: Control/SGTools/SGTools/DataStore.h:78
SG::T2pMap::clear
void clear()
Definition: T2pMap.h:53
SG::DEFAULTKEY
const std::string DEFAULTKEY
Definition: DefaultKey.h:12
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SG::DataProxy::clID
CLID clID() const
Retrieve clid.
SG::DataProxy::release
virtual unsigned long release() override final
release reference to object
Definition: DataProxy.cxx:320
SG::DataStore::removeProxyImpl
StatusCode removeProxyImpl(DataProxy *proxy, int index)
Helper for removing a proxy.
Definition: Control/SGTools/src/DataStore.cxx:265
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:239
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
SG::BaseInfoBase::find
static const BaseInfoBase * find(CLID clid)
Find the BaseInfoBase instance for clid.
Definition: BaseInfo.cxx:569
SG::DataStore::setSvcLoc
StatusCode setSvcLoc()
Definition: Control/SGTools/src/DataStore.cxx:47
SG::DataProxy::name
virtual const name_type & name() const override final
Retrieve data object key == string.
SG::DataStore::m_storeID
StoreID::type m_storeID
Definition: Control/SGTools/SGTools/DataStore.h:196
DeMoScan.index
string index
Definition: DeMoScan.py:364
SG::DataProxy::reset
void reset(bool hard=false)
Other methods of DataProxy (not in Interface IRegistry):
Definition: DataProxy.cxx:240
SG::DataProxy::transientID
bool transientID(CLID id) const
return the list of transient IDs (primary or symLinked):
python.output.AtlRunQueryRoot.pf
pf
Definition: AtlRunQueryRoot.py:988
SG::DataStore
Hold DataProxy instances associated with a store.
Definition: Control/SGTools/SGTools/DataStore.h:74
StoreID::UNKNOWN
@ UNKNOWN
Definition: StoreID.h:32
IStringPool::keyToString
virtual const std::string * keyToString(sgkey_t key) const =0
Find the string corresponding to a given key.
SG::BaseInfoBase
The non-template portion of the BaseInfo implementation.
Definition: Control/AthenaKernel/AthenaKernel/BaseInfo.h:451
SG::DataStore::KeyMap_t
CxxUtils::ConcurrentMap< sgkey_t, DataProxy *, CxxUtils::SimpleUpdater, SGKeyHash, SGKeyEqual, 0, s_nullval > KeyMap_t
Definition: Control/SGTools/SGTools/DataStore.h:193
SG::T2pMap::t2pRemove
void t2pRemove(const void *const pTrans)
Definition: T2pMap.h:59
SG::DataProxy::isResetOnly
bool isResetOnly() const
Check reset only:
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
SG::T2pMap::pacReport
std::vector< const DataProxy * > pacReport() const
request an access control report, i.e. a list of proxies that have not been accessed since under cont...
Definition: T2pMap.cxx:7
SG::DataProxy
Definition: DataProxy.h:45
SG::DataStore::m_noAudSvc
bool m_noAudSvc
Definition: Control/SGTools/SGTools/DataStore.h:205
SG::DataProxy::AliasCont_t
TransientAddress::TransientAliasSet AliasCont_t
Definition: DataProxy.h:55
SG::ExcProxyCollision
Exception — Proxy collision for clid/key.
Definition: Control/SGTools/SGTools/exceptions.h:83
SG::ConstProxyIterator
ProxyMap::const_iterator ConstProxyIterator
Definition: ProxyMap.h:28
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
SG::BaseInfoBase::is_base
bool is_base(CLID clid) const
Return true if clid is the ID of a class that is known to be a base of T.
Definition: BaseInfo.cxx:344