10#include "GaudiKernel/ClassID.h"
11#include "GaudiKernel/MsgStream.h"
12#include "GaudiKernel/Bootstrap.h"
13#include "GaudiKernel/ISvcLocator.h"
46 StatusCode
sc(StatusCode::FAILURE);
48 if (!
m_pSvcLoc) std::cout<<
"DataStore::setSvcLoc: WARNING svcLocator not found! "<<std::endl;
56 const bool DONOTCREATE(
false);
78 std::unordered_set<DataProxy*> removed;
85 for (
size_t i = 0; i <
m_proxies.size(); ) {
87 if (dp->requestRelease (force, hard)) [[
unlikely]] {
98 if (!removed.empty()) {
101 auto lock = newMap.lock();
102 auto ctx = KeyMap_t::Updater_t::defaultContext();
104 if (removed.count (p.second) == 0) {
105 newMap.emplace (
lock, p.first, p.second, ctx);
120 bool includeAlias,
bool onlyValid)
123 for (
const ProxyMap::value_type& p :
m_storeMap[
id]) {
124 bool includeProxy(
true);
125 if (onlyValid) includeProxy=p.second->isValid();
127 if (includeProxy) vkeys.push_back(p.first);
130 if (p.first == p.second->name() && includeProxy)
131 vkeys.push_back(p.first);
143 return StatusCode::FAILURE;
148 bool primary =
false;
149 if (dp->store() ==
nullptr) {
154 if (
id == 0 && dp->clID() == 0 && dp->sgkey() != 0) {
162 sgkey_t primary_sgkey =
m_pool.stringToKey (dp->name(), dp->clID());
164 if (
id != dp->clID()) {
165 sgkey =
m_pool.stringToKey (dp->name(),
id);
167 if (dp->sgkey() == 0) {
168 dp->setSGKey (sgkey);
171 if (!
m_keyMap.emplace (sgkey, dp).second) {
175 return StatusCode::FAILURE;
178 pmap.insert(ProxyMap::value_type(dp->name(), dp));
188 return StatusCode::SUCCESS;
200 return StatusCode::FAILURE;
203 if (!forceRemove &&
proxy->isResetOnly()) {
206 return StatusCode::SUCCESS;
225 return StatusCode::FAILURE;
238 std::string name =
proxy->name();
240 for (
CLID symclid :
proxy->transientID())
245 for (
const std::string& alias : alias_set) {
250 return StatusCode::SUCCESS;
265 proxy->setStore (
nullptr);
267 std::string name =
proxy->name();
280 for (
const std::string& alias : alias_set) {
281 if (1 == pmap.erase(alias))
proxy->release();
285 if (1 == pmap.erase(name)) {
295 for (
CLID symclid : clids)
297 if (clid == symclid)
continue;
302 if (it != pmap.end() && it->second ==
proxy) {
303 storeIter->second.erase (it);
307 for (
const std::string& alias : alias_set) {
308 if (1 == pmap.erase (alias))
proxy->release();
323 return StatusCode::SUCCESS;
336 return StatusCode::SUCCESS;
339 dp->setTransientID(linkid);
344 if (exist->isValidObject()) {
347 if (exist->object() == dp->object()) {
348 dp->setTransientID(linkid);
349 return StatusCode::SUCCESS;
351 return StatusCode::FAILURE;
354 return StatusCode::FAILURE;
356 if (exist->loader()) {
357 return StatusCode::FAILURE;
364 if (bib && bib->
is_base (exist->clID())) {
365 dp->setTransientID(linkid);
366 exist->setObject (dp->object(),
false);
367 return StatusCode::SUCCESS;
372 return StatusCode::FAILURE;
379 for (
CLID clid : dp->transientID()) {
388 if (p_iter != pmap.end() && dp->clID() == p_iter->second->clID()) {
389 if (dp->name() == p_iter->second->name())
return StatusCode::SUCCESS;
390 p_iter->second->removeAlias(aliasKey);
391 p_iter->second->release();
399 dp->setAlias(aliasKey);
401 return StatusCode::SUCCESS;
409 return (storeIter->second).size();
432 const ProxyMap& pmap = siter->second;
434 if (p_iter != pmap.end()) {
442 for (
const auto& ent : pmap) {
446 else if (p != ent.second) {
455 for (
const auto& ent : pmap) {
456 if (ent.second->clID() ==
id) {
460 else if (p != ent.second) {
471 p = nc_store->findDummy (
id, key);
477 p = nc_store->findDummy (
id, key);
505DataProxy* DataStore::findDummy (
CLID id,
const std::string& key)
512 if (!pmap.insert(ProxyMap::value_type(key, p)).second) {
528 const std::string* strkey =
m_pool.keyToString (sgkey, clid);
532 KeyMap_t::const_iterator
i =
m_keyMap.find (sgkey);
544 std::recursive_mutex& mutex)
const
547 std::unique_lock
lock (mutex);
549 const std::string* strkey =
m_pool.keyToString (sgkey, clid);
553 KeyMap_t::const_iterator
i =
m_keyMap.find (sgkey);
563 const std::string& key)
const
568 return proxy_exact (pool_nc.stringToKey (key,
id));
583 const ProxyMap& pmap = storeIter->second;
586 if (pmap.size() > 0)
sc = StatusCode::SUCCESS;
597 ConstStoreIterator& te)
const
601 return StatusCode::SUCCESS;
608 return m_t2p.locatePersistent(pTransient);
616 int i=
name.find(
'/', 0);
621 return (
m_t2p.t2pRegister(pTrans, pPers)) ?
622 StatusCode::SUCCESS :
A set of pointers, alowing concurrent, lockless reads.
uint32_t CLID
The Class ID type.
Abstract interface for looking up strings/CLIDs in a pool.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
DataStore(IProxyDict &pool)
Constructor.
virtual sgkey_t stringToKey(const std::string &str, CLID clid)=0
Find the key for a string/CLID pair.
The non-template portion of the BaseInfo implementation.
static const BaseInfoBase * find(CLID clid)
Find the BaseInfoBase instance for clid.
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.
CLID clID() const
Retrieve clid.
virtual const name_type & name() const override final
Retrieve data object key == string.
std::vector< std::string > AliasCont_t
TransientAddress::TransientClidSet CLIDCont_t
Hold DataProxy instances associated with a store.
ConcurrentSGKeyMap< DataProxy * > KeyMap_t
Map of hashed sgkey -> DataProxy.
virtual StatusCode addToStore(const CLID &id, DataProxy *proxy) override
add proxy to store.
StatusCode pRange(const CLID &id, SG::ConstProxyIterator &f, SG::ConstProxyIterator &e) const
Return an iterator over proxy for a given CLID:
StatusCode removeFromKeyMap(DataProxy *proxy)
Look for (and convert) a matching dummy proxy.
DataStore(IProxyDict &pool)
Constructor.
int typeCount(const CLID &id) const
Count number of object of a given type in store.
DataProxy * locatePersistent(const void *const pTransient) const
locate the persistent (proxy) for a given T* (void*):
virtual StatusCode addAlias(const std::string &aliasKey, DataProxy *proxy) override
add alias to store
std::vector< DataProxy * > m_proxies
All proxies managed by this store.
SmartIF< ISGAudSvc > m_pSGAudSvc
IProxyDict & m_pool
The string pool associated with this store.
StatusCode addSymLink(const CLID &linkid, DataProxy *proxy)
add symlink to store:
IStringPool::sgkey_t sgkey_t
void keys(const CLID &id, std::vector< std::string > &vkeys, bool includeAlias, bool onlyValid)
StoreMap::iterator StoreIterator
StoreMap::const_iterator ConstStoreIterator
StoreMap m_storeMap
Maps locating proxies by clid/key.
virtual SG::DataProxy * proxy_exact(sgkey_t sgkey) const override
get proxy with given key.
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.
StatusCode t2pRegister(const void *const pTrans, DataProxy *const pPers)
methods to query the T2PMap:
StatusCode removeProxyImpl(DataProxy *proxy, int index)
Helper for removing a proxy.
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.
const std::vector< DataProxy * > & proxies() const
All proxies managed by this store.
StatusCode tRange(ConstStoreIterator &f, ConstStoreIterator &e) const
Return an iterator over the StoreMap:
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...
Exception — Proxy collision for clid/key.
CLID clID() const
Retrieve string key:
const std::string & name() const
Get the primary (hashed) SG key.
defines an enum used by address providers to decide what kind of StoreGateSvc they are providing addr...
::StatusCode StatusCode
StatusCode definition for legacy code.
std::map< std::string, DataProxy * > ProxyMap
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
const std::string DEFAULTKEY
ProxyMap::const_iterator ConstProxyIterator
ProxyMap::iterator ProxyIterator
virtual void lock() override
Lock the container.