ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SG::TransientAddress Class Reference

#include <TransientAddress.h>

Collaboration diagram for SG::TransientAddress:

Public Types

typedef std::vector< CLIDTransientClidSet
 Strictly a set, but there shouldn't be more than a handful of entries, so store it as a sorted vector instead. More...
 
typedef std::vector< std::string > TransientAliasSet
 
typedef IStringPool::sgkey_t sgkey_t
 Default Constructor. More...
 

Public Member Functions

 TransientAddress ()
 Construct from clid and string key: More...
 
 TransientAddress (CLID id, const std::string &key)
 Construct from clid, key and IOpaqueAddress. More...
 
 TransientAddress (CLID id, const std::string &key, IOpaqueAddress *addr, bool clearAddress=true)
 Constructor giving full list of symlinked IDs — used from DataHeaderElement::getAddress(). More...
 
 TransientAddress (CLID id, const std::string &key, IOpaqueAddress *addr, const std::vector< CLID > &clids)
 
 TransientAddress (const TransientAddress &)
 
 TransientAddress (TransientAddress &&)
 Destructor. More...
 
 ~TransientAddress ()
 
TransientAddressoperator= (const TransientAddress &)
 
TransientAddressoperator= (TransientAddress &&)
 
void setID (CLID id, const std::string &key)
 Set the CLID / key. More...
 
void reset ()
 Retrieve IOpaqueAddress. More...
 
IOpaqueAddress *address ATLAS_NOT_CONST_THREAD_SAFE () const
 set IOpaqueAddress More...
 
void setAddress (IOpaqueAddress *pAddress)
 Retrieve primary clid. More...
 
CLID clID () const
 Retrieve string key: More...
 
const std::string & name () const
 Get the primary (hashed) SG key. More...
 
sgkey_t sgkey () const
 Set the primary (hashed) SG key. More...
 
void setSGKey (sgkey_t sgkey)
 check if it is a transient ID (primary or symLinked): More...
 
bool transientID (CLID id) const
 set transient CLID's More...
 
void setTransientID (CLID id)
 get transient CLID's More...
 
const TransientClidSettransientID () const
 set alias' More...
 
void setAlias (const std::string &key)
 set alias' More...
 
void setAlias (const std::vector< std::string > &keys)
 set alias' More...
 
void setAlias (std::vector< std::string > &&keys)
 set transient Alias' More...
 
bool removeAlias (const std::string &key)
 remove alias from proxy More...
 
bool hasAlias (const std::string &key) const
 get transient alias More...
 
const TransientAliasSetalias () const
 set the clearAddress flag: IOA will not be deleted in proxy More...
 
void clearAddress (const bool &flag)
 Return the clearAddress flag. More...
 
bool clearAddress () const
 this sets the flag whether to consult the provider to update this transient address if the IOA is not valid. More...
 
void consultProvider (const bool &flag)
 Check the validity of the Transient Address. More...
 
bool isValid (const EventContext *ctx, bool forceUpdate=false)
 cache the pointer to the Address provider which can update this transient address More...
 
IAddressProviderprovider ()
 
StoreID::type storeID () const
 
void setProvider (IAddressProvider *provider, StoreID::type storeID)
 

Private Member Functions

 TransientAddress (CLID id, const std::string &key, IOpaqueAddress *addr, bool clearAddress, bool consultProvider)
 

Private Attributes

std::atomic< CLIDm_clid
 < clid of the concrete class (persistent clid) More...
 
std::atomic< sgkey_tm_sgkey
 Store type, needed by updateAddress. More...
 
StoreID::type m_storeID
 Controls if IOpaqueAddress should be deleted: More...
 
bool m_clearAddress
 Control whether the Address Provider must be consulted. More...
 
bool m_consultProvider
 IOpaqueAddress: More...
 
IOpaqueAddress * m_address
 AddressProvider. More...
 
IAddressProviderm_pAddressProvider
 string key of this object More...
 
CxxUtils::CachedValue< std::string > m_name
 all transient clids. They come from symlinks More...
 
TransientClidSet m_transientID
 all alias names for a DataObject. They come from setAlias More...
 
TransientAliasSet m_transientAlias
 

Static Private Attributes

static const std::string s_emptyString
 

Detailed Description

Definition at line 31 of file TransientAddress.h.

Member Typedef Documentation

◆ sgkey_t

Default Constructor.

Definition at line 41 of file TransientAddress.h.

◆ TransientAliasSet

typedef std::vector<std::string> SG::TransientAddress::TransientAliasSet

Definition at line 40 of file TransientAddress.h.

◆ TransientClidSet

Strictly a set, but there shouldn't be more than a handful of entries, so store it as a sorted vector instead.

Definition at line 38 of file TransientAddress.h.

Constructor & Destructor Documentation

◆ TransientAddress() [1/7]

TransientAddress::TransientAddress ( )

Construct from clid and string key:

Definition at line 18 of file TransientAddress.cxx.

19  : TransientAddress (CLID_NULL, "", nullptr, true, false)
20 {
21 }

◆ TransientAddress() [2/7]

TransientAddress::TransientAddress ( CLID  id,
const std::string &  key 
)

Construct from clid, key and IOpaqueAddress.

Definition at line 25 of file TransientAddress.cxx.

26  : TransientAddress (id, key, nullptr, true, false)
27 {
28  if (id != CLID_NULL)
29  m_transientID.push_back(id);
30 }

◆ TransientAddress() [3/7]

TransientAddress::TransientAddress ( CLID  id,
const std::string &  key,
IOpaqueAddress *  addr,
bool  clearAddress = true 
)

Constructor giving full list of symlinked IDs — used from DataHeaderElement::getAddress().

Definition at line 34 of file TransientAddress.cxx.

37  : TransientAddress (id, key, addr, clearAddress, true)
38 {
39  if (id != CLID_NULL)
40  m_transientID.push_back(id);
41 }

◆ TransientAddress() [4/7]

TransientAddress::TransientAddress ( CLID  id,
const std::string &  key,
IOpaqueAddress *  addr,
const std::vector< CLID > &  clids 
)

Definition at line 46 of file TransientAddress.cxx.

49  : TransientAddress (id, key, addr, true, true)
50 {
51  m_transientID.reserve (clids.size() + 1);
52  m_transientID = clids;
53  if (id != CLID_NULL) {
54  m_transientID.push_back (id);
55  std::ranges::sort (m_transientID);
56  }
57 }

◆ TransientAddress() [5/7]

TransientAddress::TransientAddress ( const TransientAddress other)

Definition at line 83 of file TransientAddress.cxx.

84  : m_clid (static_cast<CLID>(other.m_clid)),
85  m_sgkey (static_cast<sgkey_t>(other.m_sgkey)),
86  m_storeID (other.m_storeID),
87  m_clearAddress (other.m_clearAddress),
88  m_consultProvider (other.m_consultProvider),
89  m_pAddressProvider (other.m_pAddressProvider),
90  m_name (other.m_name),
91  m_transientID (other.m_transientID),
92  m_transientAlias (other.m_transientAlias)
93 {
94  m_address = nullptr;
95  setAddress (other.m_address);
96 }

◆ TransientAddress() [6/7]

TransientAddress::TransientAddress ( TransientAddress &&  other)

Destructor.

Definition at line 99 of file TransientAddress.cxx.

100  : m_clid (static_cast<CLID>(other.m_clid)),
101  m_sgkey (static_cast<sgkey_t>(other.m_sgkey)),
102  m_storeID (other.m_storeID),
103  m_clearAddress (other.m_clearAddress),
104  m_consultProvider (other.m_consultProvider),
105  m_pAddressProvider (other.m_pAddressProvider),
106  m_name (std::move (other.m_name)),
107  m_transientID (std::move (other.m_transientID)),
108  m_transientAlias (std::move (other.m_transientAlias))
109 {
110  m_address = other.m_address;
111  other.m_address = nullptr;
112 }

◆ ~TransientAddress()

TransientAddress::~TransientAddress ( )

Definition at line 116 of file TransientAddress.cxx.

117 {
118  setAddress(0);
119 }

◆ TransientAddress() [7/7]

TransientAddress::TransientAddress ( CLID  id,
const std::string &  key,
IOpaqueAddress *  addr,
bool  clearAddress,
bool  consultProvider 
)
private

Definition at line 62 of file TransientAddress.cxx.

66  : m_clid(id),
67  m_sgkey(0),
71  m_address(nullptr),
72  m_pAddressProvider(nullptr)
73 {
74  if (!key.empty()) {
75  m_name.store (key);
76  }
77  if (addr) {
78  setAddress(addr);
79  }
80 }

Member Function Documentation

◆ alias()

const TransientAddress::TransientAliasSet & SG::TransientAddress::alias ( ) const
inline

set the clearAddress flag: IOA will not be deleted in proxy

get transient Alias'

Definition at line 301 of file TransientAddress.h.

302  {
303  return m_transientAlias;
304  }

◆ ATLAS_NOT_CONST_THREAD_SAFE()

IOpaqueAddress* address SG::TransientAddress::ATLAS_NOT_CONST_THREAD_SAFE ( ) const

set IOpaqueAddress

◆ clearAddress() [1/2]

bool SG::TransientAddress::clearAddress ( ) const
inline

this sets the flag whether to consult the provider to update this transient address if the IOA is not valid.

Return the clearAddress flag.

Definition at line 315 of file TransientAddress.h.

316  {
317  return m_clearAddress;
318  }

◆ clearAddress() [2/2]

void SG::TransientAddress::clearAddress ( const bool &  flag)
inline

Return the clearAddress flag.

set the clearAddress flag: IOA will not be deleted in proxy

Definition at line 308 of file TransientAddress.h.

309  {
311  }

◆ clID()

CLID SG::TransientAddress::clID ( ) const
inline

Retrieve string key:

Retrieve clid.

Definition at line 210 of file TransientAddress.h.

211  {
212  return m_clid;
213  }

◆ consultProvider()

void SG::TransientAddress::consultProvider ( const bool &  flag)
inline

Check the validity of the Transient Address.

cache the pointer to the Address provider which can update this transient address

If forceUpdate is true, then call updateAddress even if we already have an address. If ctx is nullptr, we don't try to update the address.

Definition at line 321 of file TransientAddress.h.

◆ hasAlias()

bool SG::TransientAddress::hasAlias ( const std::string &  key) const
inline

get transient alias

Test for an alias.

Definition at line 294 of file TransientAddress.h.

295  {
296  return std::ranges::binary_search (m_transientAlias, key);
297  }

◆ isValid()

bool TransientAddress::isValid ( const EventContext *  ctx,
bool  forceUpdate = false 
)

cache the pointer to the Address provider which can update this transient address

Definition at line 201 of file TransientAddress.cxx.

203 {
204  if (!forceUpdate && 0 != address()) return true;
205 
206  if (ctx && m_consultProvider && 0 != provider()) {
207  if ((provider()->updateAddress(storeID(), this, *ctx)).isSuccess())
208  return true;
209  }
210  return false;
211 }

◆ name()

const std::string & SG::TransientAddress::name ( ) const
inline

Get the primary (hashed) SG key.

Return StoreGate key.

Definition at line 217 of file TransientAddress.h.

218  {
219  // Most of the time, m_name is set when the TransientAddress is created
220  // and then never changed. To handle dummy proxies though, m_name
221  // can be created as blank and filled in later, but then never changed
222  // again. Used CachedValue to avoid having to use a lock for this.
223  if (m_name.isValid()) {
224  return *m_name.ptr();
225  }
226  return s_emptyString;
227  }

◆ operator=() [1/2]

TransientAddress & TransientAddress::operator= ( const TransientAddress other)

Definition at line 124 of file TransientAddress.cxx.

125 {
126  if (this != &other) {
127  m_clid = static_cast<CLID>(other.m_clid);
128  m_name = other.m_name;
129  m_transientID = other.m_transientID;
130  m_transientAlias = other.m_transientAlias;
131  m_clearAddress = other.m_clearAddress;
132  m_consultProvider = other.m_consultProvider;
133  m_pAddressProvider = other.m_pAddressProvider;
134  m_storeID = other.m_storeID;
135  m_sgkey = static_cast<sgkey_t>(other.m_sgkey);
136 
137  setAddress (other.m_address);
138  }
139  return *this;
140 }

◆ operator=() [2/2]

TransientAddress & TransientAddress::operator= ( TransientAddress &&  other)

Definition at line 143 of file TransientAddress.cxx.

144 {
145  if (this != &other) {
146  m_clid = static_cast<CLID>(other.m_clid);
147  m_name = std::move (other.m_name);
148  m_transientID = std::move (other.m_transientID);
149  m_transientAlias = std::move (other.m_transientAlias);
150  m_clearAddress = other.m_clearAddress;
151  m_consultProvider = other.m_consultProvider;
152  m_pAddressProvider = other.m_pAddressProvider;
153  m_storeID = other.m_storeID;
154  m_sgkey = static_cast<sgkey_t>(other.m_sgkey);
155 
156  m_address = other.m_address;
157  other.m_address = nullptr;
158  }
159  return *this;
160 }

◆ provider()

IAddressProvider * SG::TransientAddress::provider ( )
inline

Definition at line 329 of file TransientAddress.h.

330  {
331  return m_pAddressProvider;
332  }

◆ removeAlias()

bool SG::TransientAddress::removeAlias ( const std::string &  key)
inline

remove alias from proxy

remove alias

Test for an alias.

Definition at line 283 of file TransientAddress.h.

284  {
285  auto it = std::ranges::lower_bound (m_transientAlias, key);
286  if (it != m_transientAlias.end() && *it == key) {
287  m_transientAlias.erase (it);
288  return true;
289  }
290  return false;
291  }

◆ reset()

void SG::TransientAddress::reset ( )
inline

Retrieve IOpaqueAddress.

Definition at line 196 of file TransientAddress.h.

197  {
198  if (m_clearAddress) setAddress(0);
199  }

◆ setAddress()

void TransientAddress::setAddress ( IOpaqueAddress *  pAddress)

Retrieve primary clid.

set IOpaqueAddress

Definition at line 194 of file TransientAddress.cxx.

195 {
196  if (0 != pAddress) pAddress->addRef();
197  if (0 != m_address) m_address->release();
198  m_address = pAddress;
199 }

◆ setAlias() [1/3]

void SG::TransientAddress::setAlias ( const std::string &  key)
inline

set alias'

set transient Alias'

Definition at line 260 of file TransientAddress.h.

261  {
262  auto it = std::ranges::lower_bound (m_transientAlias, key);
263  if (it == m_transientAlias.end() || *it != key) {
264  m_transientAlias.insert (it, key);
265  }
266  }

◆ setAlias() [2/3]

void SG::TransientAddress::setAlias ( const std::vector< std::string > &  keys)
inline

set alias'

set transient Alias'

Definition at line 270 of file TransientAddress.h.

271  {
273  }

◆ setAlias() [3/3]

void SG::TransientAddress::setAlias ( std::vector< std::string > &&  keys)
inline

set transient Alias'

Definition at line 277 of file TransientAddress.h.

278  {
279  m_transientAlias = std::move(keys);
280  }

◆ setID()

void TransientAddress::setID ( CLID  id,
const std::string &  key 
)

Set the CLID / key.

This will only succeed if the clid/key are currently clear. Reset

Parameters
idThe new CLID.
keyThe new StoreGate key.

This will only succeed if the clid/key are currently clear.

Definition at line 183 of file TransientAddress.cxx.

184 {
185  assert (m_clid == CLID_NULL && !m_name.isValid() && m_transientID.empty() &&
186  m_transientAlias.empty());
187  m_clid = id;
188  m_name.set (key);
189  if (id != CLID_NULL)
190  m_transientID.push_back(id);
191 }

◆ setProvider()

void SG::TransientAddress::setProvider ( IAddressProvider provider,
StoreID::type  storeID 
)
inline

Definition at line 340 of file TransientAddress.h.

342  {
344  m_consultProvider = true;
346  }

◆ setSGKey()

void SG::TransientAddress::setSGKey ( sgkey_t  sgkey)
inline

check if it is a transient ID (primary or symLinked):

Set the primary (hashed) SG key.

Definition at line 238 of file TransientAddress.h.

239  {
240  m_sgkey = sgkey;
241  }

◆ setTransientID()

void TransientAddress::setTransientID ( CLID  id)

get transient CLID's

set transient CLID's

Definition at line 164 of file TransientAddress.cxx.

165 {
166  if (m_transientID.empty()) {
167  m_transientID.push_back (id);
168  }
169  else if (!transientID (id)) {
170  m_transientID.push_back (id);
171  std::sort (m_transientID.begin(), m_transientID.end());
172  }
173 }

◆ sgkey()

TransientAddress::sgkey_t SG::TransientAddress::sgkey ( ) const
inline

Set the primary (hashed) SG key.

Get the primary (hashed) SG key.

Definition at line 231 of file TransientAddress.h.

232  {
233  return m_sgkey;
234  }

◆ storeID()

StoreID::type SG::TransientAddress::storeID ( ) const
inline

Definition at line 334 of file TransientAddress.h.

335  {
336  return m_storeID;
337  }

◆ transientID() [1/2]

const TransientAddress::TransientClidSet & SG::TransientAddress::transientID ( ) const
inline

set alias'

get transient CLID's

Definition at line 253 of file TransientAddress.h.

254  {
255  return m_transientID;
256  }

◆ transientID() [2/2]

bool SG::TransientAddress::transientID ( CLID  id) const
inline

set transient CLID's

check if it is a transient ID:

Definition at line 245 of file TransientAddress.h.

246  {
247  return std::find (m_transientID.begin(), m_transientID.end(), id) !=
248  m_transientID.end();
249  }

Member Data Documentation

◆ m_address

IOpaqueAddress* SG::TransientAddress::m_address
private

AddressProvider.

Definition at line 174 of file TransientAddress.h.

◆ m_clearAddress

bool SG::TransientAddress::m_clearAddress
private

Control whether the Address Provider must be consulted.

Definition at line 168 of file TransientAddress.h.

◆ m_clid

std::atomic<CLID> SG::TransientAddress::m_clid
private

< clid of the concrete class (persistent clid)

(hashed) SG key for primary clid / key.

Definition at line 159 of file TransientAddress.h.

◆ m_consultProvider

bool SG::TransientAddress::m_consultProvider
private

IOpaqueAddress:

Definition at line 171 of file TransientAddress.h.

◆ m_name

CxxUtils::CachedValue<std::string> SG::TransientAddress::m_name
private

all transient clids. They come from symlinks

Definition at line 180 of file TransientAddress.h.

◆ m_pAddressProvider

IAddressProvider* SG::TransientAddress::m_pAddressProvider
private

string key of this object

Definition at line 177 of file TransientAddress.h.

◆ m_sgkey

std::atomic<sgkey_t> SG::TransientAddress::m_sgkey
private

Store type, needed by updateAddress.

Definition at line 162 of file TransientAddress.h.

◆ m_storeID

StoreID::type SG::TransientAddress::m_storeID
private

Controls if IOpaqueAddress should be deleted:

Definition at line 165 of file TransientAddress.h.

◆ m_transientAlias

TransientAliasSet SG::TransientAddress::m_transientAlias
private

Definition at line 186 of file TransientAddress.h.

◆ m_transientID

TransientClidSet SG::TransientAddress::m_transientID
private

all alias names for a DataObject. They come from setAlias

Definition at line 183 of file TransientAddress.h.

◆ s_emptyString

const std::string TransientAddress::s_emptyString
staticprivate

Definition at line 188 of file TransientAddress.h.


The documentation for this class was generated from the following files:
SG::TransientAddress::m_clid
std::atomic< CLID > m_clid
< clid of the concrete class (persistent clid)
Definition: TransientAddress.h:159
CxxUtils::CachedValue::ptr
const T * ptr() const
Return a pointer to the cached value.
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
SG::TransientAddress::storeID
StoreID::type storeID() const
Definition: TransientAddress.h:334
SG::TransientAddress::m_name
CxxUtils::CachedValue< std::string > m_name
all transient clids. They come from symlinks
Definition: TransientAddress.h:180
CxxUtils::CachedValue::isValid
bool isValid() const
Test to see if the value is valid.
skel.it
it
Definition: skel.GENtoEVGEN.py:407
SG::TransientAddress::sgkey
sgkey_t sgkey() const
Set the primary (hashed) SG key.
Definition: TransientAddress.h:231
SG::TransientAddress::clearAddress
bool clearAddress() const
this sets the flag whether to consult the provider to update this transient address if the IOA is not...
Definition: TransientAddress.h:315
SG::TransientAddress::m_address
IOpaqueAddress * m_address
AddressProvider.
Definition: TransientAddress.h:174
CxxUtils::CachedValue::store
void store(const T &val)
Store a new value.
SG::TransientAddress::m_storeID
StoreID::type m_storeID
Controls if IOpaqueAddress should be deleted:
Definition: TransientAddress.h:165
SG::TransientAddress::m_transientID
TransientClidSet m_transientID
all alias names for a DataObject. They come from setAlias
Definition: TransientAddress.h:183
SG::TransientAddress::m_sgkey
std::atomic< sgkey_t > m_sgkey
Store type, needed by updateAddress.
Definition: TransientAddress.h:162
SG::TransientAddress::provider
IAddressProvider * provider()
Definition: TransientAddress.h:329
master.flag
bool flag
Definition: master.py:29
SG::TransientAddress::sgkey_t
IStringPool::sgkey_t sgkey_t
Default Constructor.
Definition: TransientAddress.h:41
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SG::TransientAddress::m_transientAlias
TransientAliasSet m_transientAlias
Definition: TransientAddress.h:186
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:239
SG::TransientAddress::m_clearAddress
bool m_clearAddress
Control whether the Address Provider must be consulted.
Definition: TransientAddress.h:168
CxxUtils::CachedValue::set
void set(const T &val) const
Set the value, assuming it is currently invalid.
RTTAlgmain.address
address
Definition: RTTAlgmain.py:55
SG::TransientAddress::setAddress
void setAddress(IOpaqueAddress *pAddress)
Retrieve primary clid.
Definition: TransientAddress.cxx:194
SG::TransientAddress::transientID
const TransientClidSet & transientID() const
set alias'
Definition: TransientAddress.h:253
SG::TransientAddress::consultProvider
void consultProvider(const bool &flag)
Check the validity of the Transient Address.
Definition: TransientAddress.h:321
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
SG::TransientAddress::m_consultProvider
bool m_consultProvider
IOpaqueAddress:
Definition: TransientAddress.h:171
StoreID::UNKNOWN
@ UNKNOWN
Definition: StoreID.h:32
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
SG::TransientAddress::TransientAddress
TransientAddress()
Construct from clid and string key:
Definition: TransientAddress.cxx:18
SG::TransientAddress::m_pAddressProvider
IAddressProvider * m_pAddressProvider
string key of this object
Definition: TransientAddress.h:177
SG::TransientAddress::s_emptyString
static const std::string s_emptyString
Definition: TransientAddress.h:188
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37