ATLAS Offline Software
Loading...
Searching...
No Matches
SGTest::TestStore Class Reference

#include <TestStore.h>

Inheritance diagram for SGTest::TestStore:
Collaboration diagram for SGTest::TestStore:

Public Types

typedef std::unordered_map< const void *, SG::DataProxy * > tmap_t
typedef SG::SGKeyMap< SG::DataProxy * > kmap_t
typedef std::unordered_map< TestStoreRemap, TestStoreRemap, TestStoreRemapHash > remap_t
typedef std::mutex mutex_t
typedef std::lock_guard< mutex_t > lock_t

Public Member Functions

 TestStore (StoreID::type id=StoreID::EVENT_STORE)
virtual StoreID::type storeID () const override
virtual std::vector< const SG::DataProxy * > proxies () const override
virtual const std::string * keyToString (sgkey_t) const override
virtual void registerKey (sgkey_t, const std::string &, CLID) override
virtual const std::string & name () const override
virtual SG::DataProxy * proxy (const void *const pTransient) const override
virtual SG::DataProxy * proxy (const CLID &id, const std::string &key) const override
virtual SG::DataProxy * proxy_exact (SG::sgkey_t sgkey) const override
virtual sgkey_t stringToKey (const std::string &str, CLID clid) override
virtual const std::string * keyToString (sgkey_t key, CLID &clid) const override
virtual bool tryELRemap (sgkey_t sgkey_in, size_t index_in, sgkey_t &sgkey_out, size_t &index_out) override
virtual StatusCode addToStore (CLID, SG::DataProxy *proxy) override
virtual void boundHandle (IResetable *handle) override
virtual void unboundHandle (IResetable *handle) override
virtual SG::DataProxy * recordObject (SG::DataObjectSharedPtr< DataObject > obj, const std::string &key, bool allowMods, bool returnExisting) override
template<class T>
void record (const T *p, const std::string &key)
template<class T>
void record (std::unique_ptr< T > up, const std::string &key)
void remap (sgkey_t sgkey_in, sgkey_t sgkey_out, size_t index_in=0, size_t index_out=0)
template<class T>
void remap (const std::string &key_in, const std::string &key_out, size_t index_in=0, size_t index_out=0)
void alias (SG::DataProxy *proxy, const std::string &newKey)
SG::DataProxy * proxy (lock_t &, const void *const pTransient) const
SG::DataProxy * proxy (lock_t &, const CLID &id, const std::string &key) const
SG::DataProxy * record1 (lock_t &, const void *p, DataObject *obj, CLID clid, const std::string &key)

Public Attributes

tmap_t m_tmap
kmap_t m_kmap
remap_t m_remap
SG::StringPool m_stringPool ATLAS_THREAD_SAFE
std::vector< IResetable * > m_boundHandles
std::vector< std::pair< CLID, std::string > > m_missedProxies ATLAS_THREAD_SAFE
mutex_t m_mutex
StoreID::type m_id

Detailed Description

Definition at line 50 of file TestStore.h.

Member Typedef Documentation

◆ kmap_t

Definition at line 123 of file TestStore.h.

◆ lock_t

typedef std::lock_guard<mutex_t> SGTest::TestStore::lock_t

Definition at line 137 of file TestStore.h.

◆ mutex_t

typedef std::mutex SGTest::TestStore::mutex_t

Definition at line 136 of file TestStore.h.

◆ remap_t

Definition at line 126 of file TestStore.h.

◆ tmap_t

typedef std::unordered_map<const void*, SG::DataProxy*> SGTest::TestStore::tmap_t

Definition at line 120 of file TestStore.h.

Constructor & Destructor Documentation

◆ TestStore()

SGTest::TestStore::TestStore ( StoreID::type id = StoreID::EVENT_STORE)

Definition at line 26 of file TestStore.cxx.

27 : m_id (id)
28{
29}
StoreID::type m_id
Definition TestStore.h:140

Member Function Documentation

◆ addToStore()

StatusCode SGTest::TestStore::addToStore ( CLID ,
SG::DataProxy * proxy )
overridevirtual

Definition at line 188 of file TestStore.cxx.

189{
191 proxy->setStore (this);
192 m_kmap[proxy->sgkey()] = proxy;
193 proxy->addRef();
194 return StatusCode::SUCCESS;
195}
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
virtual SG::DataProxy * proxy(const void *const pTransient) const override
std::lock_guard< mutex_t > lock_t
Definition TestStore.h:137

◆ alias()

void SGTest::TestStore::alias ( SG::DataProxy * proxy,
const std::string & newKey )

Definition at line 248 of file TestStore.cxx.

250{
252 sgkey_t sgkey = m_stringPool.stringToKey (newKey, proxy->clID());
253 m_kmap[sgkey] = proxy;
254 proxy->addRef();
255 proxy->setAlias (newKey);
256}
SG::sgkey_t sgkey_t
Definition TestStore.h:29
sgkey(tool)
Definition common.py:1027

◆ boundHandle()

void SGTest::TestStore::boundHandle ( IResetable * handle)
overridevirtual

Definition at line 198 of file TestStore.cxx.

199{
201 m_boundHandles.push_back (handle);
202}
std::vector< IResetable * > m_boundHandles
Definition TestStore.h:131

◆ keyToString() [1/2]

const std::string * SGTest::TestStore::keyToString ( sgkey_t key,
CLID & clid ) const
overridevirtual

Definition at line 169 of file TestStore.cxx.

170{
172 return m_stringPool.keyToString (key, clid);
173}

◆ keyToString() [2/2]

const std::string * SGTest::TestStore::keyToString ( sgkey_t key) const
overridevirtual

Definition at line 44 of file TestStore.cxx.

45{
46 return m_stringPool.keyToString (key);
47}

◆ name()

const std::string & SGTest::TestStore::name ( ) const
overridevirtual

Definition at line 109 of file TestStore.cxx.

110{
111 static const std::string nm = "TestStore";
112 return nm;
113}

◆ proxies()

std::vector< const SG::DataProxy * > SGTest::TestStore::proxies ( ) const
overridevirtual

Definition at line 38 of file TestStore.cxx.

39{
40 std::println ("proxies"); std::abort();
41}

◆ proxy() [1/4]

SG::DataProxy * SGTest::TestStore::proxy ( const CLID & id,
const std::string & key ) const
overridevirtual

Definition at line 133 of file TestStore.cxx.

134{
136 return proxy (lock, id, key);
137}

◆ proxy() [2/4]

SG::DataProxy * SGTest::TestStore::proxy ( const void *const pTransient) const
overridevirtual

Definition at line 116 of file TestStore.cxx.

117{
119 return proxy (lock, pTransient);
120}

◆ proxy() [3/4]

SG::DataProxy * SGTest::TestStore::proxy ( lock_t & ,
const CLID & id,
const std::string & key ) const

Definition at line 141 of file TestStore.cxx.

142{
143 sgkey_t sgkey = m_stringPool.stringToKey (key, id);
144 kmap_t::const_iterator i = m_kmap.find (sgkey);
145 if (i != m_kmap.end())
146 return i->second;
147 m_missedProxies.emplace_back (id, key);
148 return 0;
149}

◆ proxy() [4/4]

SG::DataProxy * SGTest::TestStore::proxy ( lock_t & ,
const void *const pTransient ) const

Definition at line 124 of file TestStore.cxx.

125{
126 tmap_t::const_iterator i = m_tmap.find (pTransient);
127 if (i != m_tmap.end())
128 return i->second;
129 return 0;
130}

◆ proxy_exact()

SG::DataProxy * SGTest::TestStore::proxy_exact ( SG::sgkey_t sgkey) const
overridevirtual

Definition at line 152 of file TestStore.cxx.

153{
155 kmap_t::const_iterator i = m_kmap.find (sgkey);
156 if (i != m_kmap.end())
157 return i->second;
158 return 0;
159}

◆ record() [1/2]

template<class T>
void SGTest::TestStore::record ( const T * p,
const std::string & key )
inline

Definition at line 83 of file TestStore.h.

84 {
86 T* p_nc ATLAS_THREAD_SAFE = const_cast<T*>(p);
87 DataObject* obj = SG::asStorable<T>(p_nc);
89 record1 (lock, p, obj, clid, key);
90 }
uint32_t CLID
The Class ID type.
SG::DataProxy * record1(lock_t &, const void *p, DataObject *obj, CLID clid, const std::string &key)
SG::StringPool m_stringPool ATLAS_THREAD_SAFE
Definition TestStore.h:129
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
unsigned long long T

◆ record() [2/2]

template<class T>
void SGTest::TestStore::record ( std::unique_ptr< T > up,
const std::string & key )
inline

Definition at line 94 of file TestStore.h.

95 {
97 T* p = up.get();
98 DataObject* obj = SG::asStorable<T>(std::move (up));
100 record1 (lock, p, obj, clid, key);
101 }

◆ record1()

SG::DataProxy * SGTest::TestStore::record1 ( lock_t & ,
const void * p,
DataObject * obj,
CLID clid,
const std::string & key )

Definition at line 215 of file TestStore.cxx.

217{
218 sgkey_t sgkey = m_stringPool.stringToKey (key, clid);
219 if (m_kmap.find (sgkey) != m_kmap.end()) {
220 SG::DataProxy* dp = m_kmap[sgkey];
221 dp->setObject (obj);
222 if (dp->clID() == CLID_NULL)
223 dp->setID (clid, key);
224 m_tmap[p] = dp;
225 return dp;
226 }
227
228 SG::DataProxy* dp = new SG::DataProxy(obj, SG::TransientAddress(clid, key));
229 dp->setStore (this);
230 m_tmap[p] = dp;
231
232 m_kmap[sgkey] = dp;
233 dp->addRef();
234 dp->setSGKey (sgkey);
235 return dp;
236}

◆ recordObject()

SG::DataProxy * SGTest::TestStore::recordObject ( SG::DataObjectSharedPtr< DataObject > obj,
const std::string & key,
bool allowMods,
bool returnExisting )
overridevirtual

Definition at line 58 of file TestStore.cxx.

62{
64 const void* raw_ptr = obj.get();
65 if (DataBucketBase* bucket = dynamic_cast<DataBucketBase*> (obj.get())) {
66 raw_ptr = bucket->object();
67 }
68
69 CLID clid = obj->clID();
70 SG::DataProxy* proxy = this->proxy (lock, clid, key);
71 if (proxy) {
72 if (returnExisting)
73 return proxy;
74 else
75 return nullptr;
76 }
77
78 proxy = this->proxy (lock, raw_ptr);
79 if (proxy) {
80 sgkey_t sgkey = m_stringPool.stringToKey (key, obj->clID());
81 if (!returnExisting)
82 return nullptr;
83 if (obj->clID() == proxy->clID()) {
84 // Alias?
86 proxy->addRef();
87 proxy->setAlias (key);
88 return proxy;
89 }
90 if (key == proxy->name()) {
91 // Symlink?
93 proxy->addRef();
94 proxy->setTransientID (obj->clID());
95 return proxy;
96 }
97
98 // Error.
99 return nullptr;
100 }
101
102 proxy = record1 (lock, raw_ptr, obj.get(), clid, key);
103 if (!allowMods)
104 proxy->setConst();
105 return proxy;
106}

◆ registerKey()

void SGTest::TestStore::registerKey ( sgkey_t ,
const std::string & ,
CLID  )
overridevirtual

Definition at line 50 of file TestStore.cxx.

53{
54 std::println ("registerKey"); std::abort();
55}

◆ remap() [1/2]

template<class T>
void SGTest::TestStore::remap ( const std::string & key_in,
const std::string & key_out,
size_t index_in = 0,
size_t index_out = 0 )
inline

Definition at line 109 of file TestStore.h.

111 {
113 sgkey_t sgkey_in = stringToKey (key_in, clid);
114 sgkey_t sgkey_out = stringToKey (key_out, clid);
115 remap (sgkey_in, sgkey_out, index_in, index_out);
116 }
virtual sgkey_t stringToKey(const std::string &str, CLID clid) override
std::map< std::string, std::string > remap
list of directories to be explicitly remapped
Definition hcg.cxx:97

◆ remap() [2/2]

void SGTest::TestStore::remap ( sgkey_t sgkey_in,
sgkey_t sgkey_out,
size_t index_in = 0,
size_t index_out = 0 )

Definition at line 239 of file TestStore.cxx.

241{
243 m_remap[TestStoreRemap(sgkey_in, index_in)] =
244 TestStoreRemap(sgkey_out, index_out);
245}

◆ storeID()

StoreID::type SGTest::TestStore::storeID ( ) const
overridevirtual

Definition at line 32 of file TestStore.cxx.

33{
34 return m_id;
35}

◆ stringToKey()

sgkey_t SGTest::TestStore::stringToKey ( const std::string & str,
CLID clid )
overridevirtual

Definition at line 162 of file TestStore.cxx.

163{
165 return m_stringPool.stringToKey (str, clid);
166}

◆ tryELRemap()

bool SGTest::TestStore::tryELRemap ( sgkey_t sgkey_in,
size_t index_in,
sgkey_t & sgkey_out,
size_t & index_out )
overridevirtual

Definition at line 176 of file TestStore.cxx.

178{
180 remap_t::iterator i = m_remap.find (TestStoreRemap (sgkey_in, index_in));
181 if (i == m_remap.end()) return false;
182 sgkey_out = i->second.key;
183 index_out = i->second.index;
184 return true;
185}

◆ unboundHandle()

void SGTest::TestStore::unboundHandle ( IResetable * handle)
overridevirtual

Definition at line 205 of file TestStore.cxx.

206{
208 std::vector<IResetable*>::iterator it =
209 std::find (m_boundHandles.begin(), m_boundHandles.end(), handle);
210 if (it != m_boundHandles.end())
211 m_boundHandles.erase (it);
212}

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/2]

std::vector<std::pair<CLID, std::string> > m_missedProxies SGTest::TestStore::ATLAS_THREAD_SAFE
mutable

Definition at line 134 of file TestStore.h.

◆ ATLAS_THREAD_SAFE [2/2]

SG::StringPool m_stringPool SGTest::TestStore::ATLAS_THREAD_SAFE
mutable

Definition at line 129 of file TestStore.h.

◆ m_boundHandles

std::vector<IResetable*> SGTest::TestStore::m_boundHandles

Definition at line 131 of file TestStore.h.

◆ m_id

StoreID::type SGTest::TestStore::m_id

Definition at line 140 of file TestStore.h.

◆ m_kmap

kmap_t SGTest::TestStore::m_kmap

Definition at line 124 of file TestStore.h.

◆ m_mutex

mutex_t SGTest::TestStore::m_mutex
mutable

Definition at line 138 of file TestStore.h.

◆ m_remap

remap_t SGTest::TestStore::m_remap

Definition at line 127 of file TestStore.h.

◆ m_tmap

tmap_t SGTest::TestStore::m_tmap

Definition at line 121 of file TestStore.h.


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