ATLAS Offline Software
Loading...
Searching...
No Matches
TransientAddress.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "SGTools/DataProxy.h"
9#include "GaudiKernel/IOpaqueAddress.h"
10
11#include <assert.h>
12
14
15const std::string TransientAddress::s_emptyString;
16
17// Default Constructor:
19 : TransientAddress (CLID_NULL, "", nullptr, true, false)
20{
21}
22
23// Constructor with CLID and string key:
24// (typically used through a StoreGate::record()
25TransientAddress::TransientAddress(CLID id, const std::string& key)
26 : TransientAddress (id, key, nullptr, true, false)
27{
28 if (id != CLID_NULL)
29 m_transientID.push_back(id);
30}
31
32// Constructor with CLID, string key and IOpaqueAddress:
33// (typically used by a ProxyProvider)
34TransientAddress::TransientAddress(CLID id, const std::string& key,
36 bool clearAddress)
37 : TransientAddress (id, key, std::move(addr), clearAddress, true)
38{
39 if (id != CLID_NULL)
40 m_transientID.push_back(id);
41}
42
43
44// Constructor giving full list of symlinked IDs
45// --- used from DataHeaderElement::getAddress().
46TransientAddress::TransientAddress(CLID id, const std::string& key,
48 const std::vector<CLID>& clids)
49 : TransientAddress (id, key, std::move(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}
58
59
60// Note: this is a private ctor, only used from other ctors.
61// It does not initialize m_transientID.
62TransientAddress::TransientAddress(CLID id, const std::string& key,
64 bool clearAddress,
65 bool consultProvider)
66 : m_clid(id),
67 m_sgkey(0),
68 m_storeID(StoreID::UNKNOWN),
71 m_address(std::move(addr)),
72 m_pAddressProvider(nullptr)
73{
74 if (!key.empty()) {
75 m_name.store (key);
76 }
77}
78
79
81 : m_clid (static_cast<CLID>(other.m_clid)),
82 m_sgkey (static_cast<sgkey_t>(other.m_sgkey)),
83 m_storeID (other.m_storeID),
86 m_address (other.m_address),
88 m_name (other.m_name),
91{
92}
93
94
96 : m_clid (static_cast<CLID>(other.m_clid)),
97 m_sgkey (static_cast<sgkey_t>(other.m_sgkey)),
98 m_storeID (other.m_storeID),
101 m_address (std::move (other.m_address)),
103 m_name (std::move (other.m_name)),
104 m_transientID (std::move (other.m_transientID)),
106{
107}
108
109
110// Destructor
114
115
117{
118 if (this != &other) {
119 m_clid = static_cast<CLID>(other.m_clid);
120 m_name = other.m_name;
121 m_transientID = other.m_transientID;
122 m_transientAlias = other.m_transientAlias;
123 m_clearAddress = other.m_clearAddress;
124 m_consultProvider = other.m_consultProvider;
125 m_pAddressProvider = other.m_pAddressProvider;
126 m_storeID = other.m_storeID;
127 m_sgkey = static_cast<sgkey_t>(other.m_sgkey);
128 m_address = other.m_address;
129 }
130 return *this;
131}
132
133
135{
136 if (this != &other) {
137 m_clid = static_cast<CLID>(other.m_clid);
138 m_name = std::move (other.m_name);
139 m_transientID = std::move (other.m_transientID);
140 m_transientAlias = std::move (other.m_transientAlias);
141 m_clearAddress = other.m_clearAddress;
142 m_consultProvider = other.m_consultProvider;
143 m_pAddressProvider = other.m_pAddressProvider;
144 m_storeID = other.m_storeID;
145 m_sgkey = static_cast<sgkey_t>(other.m_sgkey);
146 m_address = std::move (other.m_address);
147 }
148 return *this;
149}
150
151
154{
155 if (m_transientID.empty()) {
156 m_transientID.push_back (id);
157 }
158 else if (!transientID (id)) {
159 m_transientID.push_back (id);
160 std::sort (m_transientID.begin(), m_transientID.end());
161 }
162}
163
164
172void TransientAddress::setID (CLID id, const std::string& key)
173{
174 assert (m_clid == CLID_NULL && !m_name.isValid() && m_transientID.empty() &&
175 m_transientAlias.empty());
176 m_clid = id;
177 m_name.set (key);
178 if (id != CLID_NULL)
179 m_transientID.push_back(id);
180}
181
182// Reset the TransientAddress
184{
185 if (m_clearAddress) m_address.reset();
186}
187
190{
191 m_address = std::move(pAddress);
192}
193
194bool TransientAddress::isValid(const EventContext* ctx,
195 bool forceUpdate /*= false*/)
196{
197 if (!forceUpdate && 0 != address()) return true;
198
199 if (ctx && m_consultProvider && 0 != provider()) {
200 if ((provider()->updateAddress(storeID(), this, *ctx)).isSuccess())
201 return true;
202 }
203 return false;
204}
uint32_t CLID
The Class ID type.
if(febId1==febId2)
Simple smart pointer for Gaudi-style refcounted objects.
IStringPool::sgkey_t sgkey_t
Default Constructor.
void reset()
Retrieve IOpaqueAddress.
TransientAddress()
Construct from clid and string key:
IAddressProvider * m_pAddressProvider
string key of this object
StoreID::type storeID() const
void clearAddress(const bool &flag)
Return the clearAddress flag.
std::atomic< sgkey_t > m_sgkey
Store type, needed by updateAddress.
bool isValid(const EventContext *ctx, bool forceUpdate=false)
cache the pointer to the Address provider which can update this transient address
void setTransientID(CLID id)
get transient CLID's
bool transientID(CLID id) const
set transient CLID's
CxxUtils::CachedValue< std::string > m_name
all transient clids. They come from symlinks
bool m_consultProvider
IOpaqueAddress:
void setAddress(CxxUtils::RefCountedPtr< IOpaqueAddress > pAddress)
Retrieve primary clid.
IAddressProvider * provider()
TransientClidSet m_transientID
all alias names for a DataObject. They come from setAlias
TransientAddress & operator=(const TransientAddress &)
StoreID::type m_storeID
Controls if IOpaqueAddress should be deleted:
CxxUtils::RefCountedPtr< IOpaqueAddress > m_address
AddressProvider.
bool m_clearAddress
Control whether the Address Provider must be consulted.
void consultProvider(const bool &flag)
Check the validity of the Transient Address.
void setID(CLID id, const std::string &key)
Set the CLID / key.
TransientAliasSet m_transientAlias
std::atomic< CLID > m_clid
< clid of the concrete class (persistent clid)
defines an enum used by address providers to decide what kind of StoreGateSvc they are providing addr...
Definition StoreID.h:18
TransientAddress()
Construct from clid and string key:
static const std::string s_emptyString
STL namespace.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.