ATLAS Offline Software
Loading...
Searching...
No Matches
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.
virtual ~DataStore ()
void setStoreID (StoreID::type id)
virtual StoreID::type storeID () const override
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.

Implementation of IProxyRegistry.

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

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

◆ ConstStoreIterator

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

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

◆ KeyMap_t

Map of hashed sgkey -> DataProxy.

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

◆ sgkey_t

◆ 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 30 of file Control/SGTools/src/DataStore.cxx.

◆ ~DataStore()

DataStore::~DataStore ( )
virtual

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

42{
43 clearStore(false, true, nullptr);
44}
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...

Member Function Documentation

◆ addAlias()

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

add alias to store

Implements IProxyRegistry.

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

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

◆ addSymLink()

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

add symlink to store:

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

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

◆ addToStore()

StatusCode DataStore::addToStore ( const CLID & id,
DataProxy * proxy )
overridevirtual

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 141 of file Control/SGTools/src/DataStore.cxx.

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

◆ 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 67 of file Control/SGTools/src/DataStore.cxx.

68{
71
79 std::unordered_set<DataProxy*> removed;
80
86 for (size_t i = 0; i < m_proxies.size(); ) {
87 SG::DataProxy* dp = m_proxies[i];
88 if (ATH_UNLIKELY (dp->requestRelease (force, hard))) {
89 removed.insert (dp);
90 if (removeProxyImpl (dp, i).isFailure()) {
91 ++i;
92 }
93 }
94 else {
95 ++i;
96 }
97 }
98
99 if (!removed.empty()) {
100 KeyMap_t newMap (KeyMap_t::Updater_t(), m_keyMap.capacity());
101 {
102 auto lock = newMap.lock();
103 auto ctx = KeyMap_t::Updater_t::defaultContext();
104 for (auto p : m_keyMap) {
105 if (removed.count (p.second) == 0) {
106 newMap.emplace (lock, p.first, p.second, ctx);
107 }
108 }
109 }
110 m_keyMap.swap (newMap);
111 }
112
113 // clear T2PMap
114 m_t2p.clear();
115}
#define ATH_UNLIKELY(x)
ConcurrentSGKeyMap< DataProxy * > KeyMap_t
Map of hashed sgkey -> DataProxy.
StatusCode removeProxyImpl(DataProxy *proxy, int index)
Helper for removing a proxy.

◆ doAudit()

bool SG::DataStore::doAudit ( )
inlineprivate

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

199 {
200 if (!m_noAudSvc) setSGAudSvc();
201 return (m_pSGAudSvc);
202 }

◆ 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 506 of file Control/SGTools/src/DataStore.cxx.

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

◆ keys()

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

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

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

◆ locatePersistent()

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

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

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

608{
609 return m_t2p.locatePersistent(pTransient);
610}

◆ 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 575 of file Control/SGTools/src/DataStore.cxx.

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

◆ 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 628 of file Control/SGTools/src/DataStore.cxx.

629{
630 return m_proxies;
631}

◆ proxy() [1/2]

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

get proxy with given id. Returns 0 to flag failure

Implements IProxyRegistry.

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

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

◆ proxy() [2/2]

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

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

Implements IProxyRegistry.

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

416{
417 return proxy(tAddr->clID(), tAddr->name());
418}
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...
CLID clID() const
Retrieve string key:
const std::string & name() const
Get the primary (hashed) SG key.

◆ proxy_exact() [1/2]

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

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 563 of file Control/SGTools/src/DataStore.cxx.

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

◆ proxy_exact() [2/2]

DataProxy * DataStore::proxy_exact ( sgkey_t sgkey) const
overridevirtual

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 525 of file Control/SGTools/src/DataStore.cxx.

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

◆ 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 544 of file Control/SGTools/src/DataStore.cxx.

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

◆ removeFromKeyMap()

StatusCode DataStore::removeFromKeyMap ( DataProxy * proxy)
private

Remove a proxy from m_keyMap.

Parameters
proxyThe proxy being removed.

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

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

◆ 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 198 of file Control/SGTools/src/DataStore.cxx.

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

◆ 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 264 of file Control/SGTools/src/DataStore.cxx.

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

◆ 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 53 of file Control/SGTools/src/DataStore.cxx.

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

◆ 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 46 of file Control/SGTools/src/DataStore.cxx.

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

◆ storeID()

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

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 614 of file Control/SGTools/src/DataStore.cxx.

615{
616 std::string name=pPers->name();
617 int i=name.find('/', 0);
618 name=name.erase(0,i+1);
619
620 if (doAudit()) m_pSGAudSvc->SGAudit(name, pPers->clID(), 1, m_storeID);
621
622 return (m_t2p.t2pRegister(pTrans, pPers)) ?
623 StatusCode::SUCCESS :
624 StatusCode::FAILURE;
625}
CLID clID() const
Retrieve clid.
virtual const name_type & name() const override final
Retrieve data object key == string.

◆ t2pRemove()

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

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

250 {
251 m_t2p.t2pRemove(pTrans);
252 }

◆ tRange()

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

Return an iterator over the StoreMap:

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

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

◆ typeCount()

int DataStore::typeCount ( const CLID & id) const

Count number of object of a given type in store.

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

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

Member Data Documentation

◆ m_keyMap

KeyMap_t SG::DataStore::m_keyMap
private

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

◆ m_noAudSvc

bool SG::DataStore::m_noAudSvc
private

Definition at line 198 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 197 of file Control/SGTools/SGTools/DataStore.h.

◆ m_pSvcLoc

ISvcLocator* SG::DataStore::m_pSvcLoc
private

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

◆ m_storeID

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

Definition at line 189 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 194 of file Control/SGTools/SGTools/DataStore.h.


The documentation for this class was generated from the following files: