10#include "GaudiKernel/ClassID.h"
11#include "GaudiKernel/MsgStream.h"
12#include "GaudiKernel/Bootstrap.h"
13#include "GaudiKernel/ISvcLocator.h"
47 StatusCode
sc(StatusCode::FAILURE);
49 if (!
m_pSvcLoc) std::cout<<
"DataStore::setSvcLoc: WARNING svcLocator not found! "<<std::endl;
57 const bool DONOTCREATE(
false);
79 std::unordered_set<DataProxy*> removed;
86 for (
size_t i = 0; i <
m_proxies.size(); ) {
99 if (!removed.empty()) {
102 auto lock = newMap.
lock();
103 auto ctx = KeyMap_t::Updater_t::defaultContext();
105 if (removed.count (p.second) == 0) {
106 newMap.
emplace (lock, p.first, p.second, ctx);
121 bool includeAlias,
bool onlyValid)
124 for (
const ProxyMap::value_type& p :
m_storeMap[
id]) {
125 bool includeProxy(
true);
126 if (onlyValid) includeProxy=p.second->isValid();
128 if (includeProxy) vkeys.push_back(p.first);
131 if (p.first == p.second->name() && includeProxy)
132 vkeys.push_back(p.first);
144 return StatusCode::FAILURE;
149 bool primary =
false;
150 if (dp->store() ==
nullptr) {
155 if (
id == 0 && dp->clID() == 0 && dp->sgkey() != 0) {
163 sgkey_t primary_sgkey =
m_pool.stringToKey (dp->name(), dp->clID());
165 if (
id != dp->clID()) {
166 sgkey =
m_pool.stringToKey (dp->name(),
id);
168 if (dp->sgkey() == 0) {
169 dp->setSGKey (sgkey);
172 if (!
m_keyMap.emplace (sgkey, dp).second) {
176 return StatusCode::FAILURE;
179 pmap.insert(ProxyMap::value_type(dp->name(), dp));
189 return StatusCode::SUCCESS;
201 return StatusCode::FAILURE;
204 if (!forceRemove &&
proxy->isResetOnly()) {
207 return StatusCode::SUCCESS;
226 return StatusCode::FAILURE;
239 std::string name =
proxy->name();
241 for (
CLID symclid :
proxy->transientID())
246 for (
const std::string& alias : alias_set) {
251 return StatusCode::SUCCESS;
266 proxy->setStore (
nullptr);
268 std::string name =
proxy->name();
281 for (
const std::string& alias : alias_set) {
282 if (1 == pmap.erase(alias))
proxy->release();
286 if (1 == pmap.erase(name)) {
296 for (
CLID symclid : clids)
298 if (clid == symclid)
continue;
303 if (it != pmap.end() && it->second ==
proxy) {
304 storeIter->second.erase (it);
308 for (
const std::string& alias : alias_set) {
309 if (1 == pmap.erase (alias))
proxy->release();
324 return StatusCode::SUCCESS;
337 return StatusCode::SUCCESS;
340 dp->setTransientID(linkid);
345 if (exist->isValidObject()) {
348 if (exist->object() == dp->object()) {
349 dp->setTransientID(linkid);
350 return StatusCode::SUCCESS;
352 return StatusCode::FAILURE;
355 return StatusCode::FAILURE;
357 if (exist->loader()) {
358 return StatusCode::FAILURE;
365 if (bib && bib->
is_base (exist->clID())) {
366 dp->setTransientID(linkid);
367 exist->setObject (dp->object(),
false);
368 return StatusCode::SUCCESS;
373 return StatusCode::FAILURE;
380 for (
CLID clid : dp->transientID()) {
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();
400 dp->setAlias(aliasKey);
402 return StatusCode::SUCCESS;
410 return (storeIter->second).size();
433 const ProxyMap& pmap = siter->second;
435 if (p_iter != pmap.end()) {
443 for (
const auto& ent : pmap) {
447 else if (p != ent.second) {
456 for (
const auto& ent : pmap) {
457 if (ent.second->clID() ==
id) {
461 else if (p != ent.second) {
472 p = nc_store->findDummy (
id, key);
478 p = nc_store->findDummy (
id, key);
513 if (!pmap.insert(ProxyMap::value_type(key, p)).second) {
529 const std::string* strkey =
m_pool.keyToString (sgkey, clid);
533 KeyMap_t::const_iterator i =
m_keyMap.find (sgkey);
545 std::recursive_mutex& mutex)
const
548 std::unique_lock lock (mutex);
550 const std::string* strkey =
m_pool.keyToString (sgkey, clid);
554 KeyMap_t::const_iterator i =
m_keyMap.find (sgkey);
564 const std::string& key)
const
569 return proxy_exact (pool_nc.stringToKey (key,
id));
579 StatusCode
sc(StatusCode::FAILURE);
584 const ProxyMap& pmap = storeIter->second;
587 if (pmap.size() > 0)
sc = StatusCode::SUCCESS;
602 return StatusCode::SUCCESS;
609 return m_t2p.locatePersistent(pTransient);
616 std::string name=pPers->
name();
617 int i=name.find(
'/', 0);
618 name=name.erase(0,i+1);
622 return (
m_t2p.t2pRegister(pTrans, pPers)) ?
623 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
Lock_t lock()
Take a lock on the container.
std::pair< const_iterator, bool > emplace(key_type key, mapped_type val, const Context_t &ctx=Updater_t::defaultContext())
Add an element to the map.
typename Impl_t::Updater_t Updater_t
DataStore(IProxyDict &pool)
Constructor.
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 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< 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:
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:
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.
IStringPool::sgkey_t sgkey_t
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::iterator StoreIterator
StoreMap::const_iterator ConstStoreIterator
StoreMap m_storeMap
Maps locating proxies by clid/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.
const std::vector< DataProxy * > & proxies() const
All proxies managed by this store.
StatusCode removeProxyImpl(DataProxy *proxy, int index)
Helper for removing a proxy.
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...
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...
std::map< std::string, DataProxy * > ProxyMap
const std::string DEFAULTKEY
ProxyMap::const_iterator ConstProxyIterator
ProxyMap::iterator ProxyIterator