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, TestStoreRemapHashremap_t
typedef std::mutex mutex_t
typedef std::lock_guard< mutex_tlock_t

Public Member Functions

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::DataProxyproxy (const void *const pTransient) const override
virtual SG::DataProxyproxy (const CLID &id, const std::string &key) const override
virtual SG::DataProxyproxy_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::DataProxyrecordObject (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::DataProxyproxy (lock_t &, const void *const pTransient) const
SG::DataProxyproxy (lock_t &, const CLID &id, const std::string &key) const
SG::DataProxyrecord1 (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

Detailed Description

Definition at line 50 of file TestStore.h.

Member Typedef Documentation

◆ kmap_t

Definition at line 121 of file TestStore.h.

◆ lock_t

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

Definition at line 135 of file TestStore.h.

◆ mutex_t

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

Definition at line 134 of file TestStore.h.

◆ remap_t

Definition at line 124 of file TestStore.h.

◆ tmap_t

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

Definition at line 118 of file TestStore.h.

Member Function Documentation

◆ addToStore()

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

Definition at line 176 of file TestStore.cxx.

177{
178 lock_t lock (m_mutex);
179 proxy->setStore (this);
180 m_kmap[proxy->sgkey()] = proxy;
181 proxy->addRef();
182 return StatusCode::SUCCESS;
183}
virtual SG::DataProxy * proxy(const void *const pTransient) const override
std::lock_guard< mutex_t > lock_t
Definition TestStore.h:135

◆ alias()

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

Definition at line 236 of file TestStore.cxx.

238{
239 lock_t lock (m_mutex);
240 sgkey_t sgkey = m_stringPool.stringToKey (newKey, proxy->clID());
241 m_kmap[sgkey] = proxy;
242 proxy->addRef();
243 proxy->setAlias (newKey);
244}
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 186 of file TestStore.cxx.

187{
188 lock_t lock (m_mutex);
189 m_boundHandles.push_back (handle);
190}
std::vector< IResetable * > m_boundHandles
Definition TestStore.h:129

◆ keyToString() [1/2]

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

Definition at line 157 of file TestStore.cxx.

158{
159 lock_t lock (m_mutex);
160 return m_stringPool.keyToString (key, clid);
161}

◆ keyToString() [2/2]

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

Definition at line 32 of file TestStore.cxx.

33{
34 return m_stringPool.keyToString (key);
35}

◆ name()

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

Definition at line 97 of file TestStore.cxx.

98{
99 static const std::string nm = "TestStore";
100 return nm;
101}

◆ proxies()

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

Definition at line 26 of file TestStore.cxx.

27{
28 std::cout << "proxies\n"; std::abort();
29}

◆ proxy() [1/4]

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

Definition at line 121 of file TestStore.cxx.

122{
123 lock_t lock (m_mutex);
124 return proxy (lock, id, key);
125}

◆ proxy() [2/4]

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

Definition at line 104 of file TestStore.cxx.

105{
106 lock_t lock (m_mutex);
107 return proxy (lock, pTransient);
108}

◆ proxy() [3/4]

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

Definition at line 129 of file TestStore.cxx.

130{
131 sgkey_t sgkey = m_stringPool.stringToKey (key, id);
132 kmap_t::const_iterator i = m_kmap.find (sgkey);
133 if (i != m_kmap.end())
134 return i->second;
135 m_missedProxies.emplace_back (id, key);
136 return 0;
137}

◆ proxy() [4/4]

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

Definition at line 112 of file TestStore.cxx.

113{
114 tmap_t::const_iterator i = m_tmap.find (pTransient);
115 if (i != m_tmap.end())
116 return i->second;
117 return 0;
118}

◆ proxy_exact()

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

Definition at line 140 of file TestStore.cxx.

141{
142 lock_t lock (m_mutex);
143 kmap_t::const_iterator i = m_kmap.find (sgkey);
144 if (i != m_kmap.end())
145 return i->second;
146 return 0;
147}

◆ record() [1/2]

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

Definition at line 81 of file TestStore.h.

82 {
83 lock_t lock (m_mutex);
84 T* p_nc ATLAS_THREAD_SAFE = const_cast<T*>(p);
85 DataObject* obj = SG::asStorable<T>(p_nc);
87 record1 (lock, p, obj, clid, key);
88 }
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:127
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 92 of file TestStore.h.

93 {
94 lock_t lock (m_mutex);
95 T* p = up.get();
96 DataObject* obj = SG::asStorable<T>(std::move (up));
98 record1 (lock, p, obj, clid, key);
99 }

◆ record1()

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

Definition at line 203 of file TestStore.cxx.

205{
206 sgkey_t sgkey = m_stringPool.stringToKey (key, clid);
207 if (m_kmap.find (sgkey) != m_kmap.end()) {
208 SG::DataProxy* dp = m_kmap[sgkey];
209 dp->setObject (obj);
210 if (dp->clID() == CLID_NULL)
211 dp->setID (clid, key);
212 m_tmap[p] = dp;
213 return dp;
214 }
215
216 SG::DataProxy* dp = new SG::DataProxy(obj, SG::TransientAddress(clid, key));
217 dp->setStore (this);
218 m_tmap[p] = dp;
219
220 m_kmap[sgkey] = dp;
221 dp->addRef();
222 dp->setSGKey (sgkey);
223 return dp;
224}

◆ recordObject()

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

Definition at line 46 of file TestStore.cxx.

50{
51 lock_t lock (m_mutex);
52 const void* raw_ptr = obj.get();
53 if (DataBucketBase* bucket = dynamic_cast<DataBucketBase*> (obj.get())) {
54 raw_ptr = bucket->object();
55 }
56
57 CLID clid = obj->clID();
58 SG::DataProxy* proxy = this->proxy (lock, clid, key);
59 if (proxy) {
60 if (returnExisting)
61 return proxy;
62 else
63 return nullptr;
64 }
65
66 proxy = this->proxy (lock, raw_ptr);
67 if (proxy) {
68 sgkey_t sgkey = m_stringPool.stringToKey (key, obj->clID());
69 if (!returnExisting)
70 return nullptr;
71 if (obj->clID() == proxy->clID()) {
72 // Alias?
74 proxy->addRef();
75 proxy->setAlias (key);
76 return proxy;
77 }
78 if (key == proxy->name()) {
79 // Symlink?
81 proxy->addRef();
82 proxy->setTransientID (obj->clID());
83 return proxy;
84 }
85
86 // Error.
87 return nullptr;
88 }
89
90 proxy = record1 (lock, raw_ptr, obj.get(), clid, key);
91 if (!allowMods)
92 proxy->setConst();
93 return proxy;
94}

◆ registerKey()

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

Definition at line 38 of file TestStore.cxx.

41{
42 std::cout << "registerKey\n"; std::abort();
43}

◆ 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 107 of file TestStore.h.

109 {
111 sgkey_t sgkey_in = stringToKey (key_in, clid);
112 sgkey_t sgkey_out = stringToKey (key_out, clid);
113 remap (sgkey_in, sgkey_out, index_in, index_out);
114 }
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:95

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

229{
230 lock_t lock (m_mutex);
231 m_remap[TestStoreRemap(sgkey_in, index_in)] =
232 TestStoreRemap(sgkey_out, index_out);
233}

◆ stringToKey()

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

Definition at line 150 of file TestStore.cxx.

151{
152 lock_t lock (m_mutex);
153 return m_stringPool.stringToKey (str, clid);
154}

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

166{
167 lock_t lock (m_mutex);
168 remap_t::iterator i = m_remap.find (TestStoreRemap (sgkey_in, index_in));
169 if (i == m_remap.end()) return false;
170 sgkey_out = i->second.key;
171 index_out = i->second.index;
172 return true;
173}

◆ unboundHandle()

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

Definition at line 193 of file TestStore.cxx.

194{
195 lock_t lock (m_mutex);
196 std::vector<IResetable*>::iterator it =
197 std::find (m_boundHandles.begin(), m_boundHandles.end(), handle);
198 if (it != m_boundHandles.end())
199 m_boundHandles.erase (it);
200}

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/2]

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

Definition at line 127 of file TestStore.h.

◆ ATLAS_THREAD_SAFE [2/2]

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

Definition at line 132 of file TestStore.h.

◆ m_boundHandles

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

Definition at line 129 of file TestStore.h.

◆ m_kmap

kmap_t SGTest::TestStore::m_kmap

Definition at line 122 of file TestStore.h.

◆ m_mutex

mutex_t SGTest::TestStore::m_mutex
mutable

Definition at line 136 of file TestStore.h.

◆ m_remap

remap_t SGTest::TestStore::m_remap

Definition at line 125 of file TestStore.h.

◆ m_tmap

tmap_t SGTest::TestStore::m_tmap

Definition at line 119 of file TestStore.h.


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