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 25 of file TestStore.cxx.

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

Member Function Documentation

◆ addToStore()

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

Definition at line 187 of file TestStore.cxx.

188{
190 proxy->setStore (this);
191 m_kmap[proxy->sgkey()] = proxy;
192 proxy->addRef();
193 return StatusCode::SUCCESS;
194}
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 247 of file TestStore.cxx.

249{
251 sgkey_t sgkey = m_stringPool.stringToKey (newKey, proxy->clID());
252 m_kmap[sgkey] = proxy;
253 proxy->addRef();
254 proxy->setAlias (newKey);
255}
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 197 of file TestStore.cxx.

198{
200 m_boundHandles.push_back (handle);
201}
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 168 of file TestStore.cxx.

169{
171 return m_stringPool.keyToString (key, clid);
172}

◆ keyToString() [2/2]

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

Definition at line 43 of file TestStore.cxx.

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

◆ name()

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

Definition at line 108 of file TestStore.cxx.

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

◆ proxies()

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

Definition at line 37 of file TestStore.cxx.

38{
39 std::cout << "proxies\n"; std::abort();
40}

◆ proxy() [1/4]

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

Definition at line 132 of file TestStore.cxx.

133{
135 return proxy (lock, id, key);
136}

◆ proxy() [2/4]

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

Definition at line 115 of file TestStore.cxx.

116{
118 return proxy (lock, pTransient);
119}

◆ proxy() [3/4]

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

Definition at line 140 of file TestStore.cxx.

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

◆ proxy() [4/4]

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

Definition at line 123 of file TestStore.cxx.

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

◆ proxy_exact()

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

Definition at line 151 of file TestStore.cxx.

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

◆ 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 214 of file TestStore.cxx.

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

◆ recordObject()

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

Definition at line 57 of file TestStore.cxx.

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

◆ registerKey()

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

Definition at line 49 of file TestStore.cxx.

52{
53 std::cout << "registerKey\n"; std::abort();
54}

◆ 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 238 of file TestStore.cxx.

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

◆ storeID()

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

Definition at line 31 of file TestStore.cxx.

32{
33 return m_id;
34}

◆ stringToKey()

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

Definition at line 161 of file TestStore.cxx.

162{
164 return m_stringPool.stringToKey (str, clid);
165}

◆ 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 175 of file TestStore.cxx.

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

◆ unboundHandle()

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

Definition at line 204 of file TestStore.cxx.

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

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: