ATLAS Offline Software
Loading...
Searching...
No Matches
ProxyProviderSvc Class Reference

manages the address providers and add proxies on demand to the store More...

#include <ProxyProviderSvc.h>

Inheritance diagram for ProxyProviderSvc:
Collaboration diagram for ProxyProviderSvc:

Public Types

typedef std::list< IAddressProvider * >::iterator pAPiterator
typedef std::list< SG::TransientAddress * > TAdList
typedef TAdList::iterator TAdIterator

Public Member Functions

virtual StatusCode preLoadProxies (IProxyRegistry &storeToModify) override
 IProxyProvider interface.
virtual StatusCode loadProxies (IProxyRegistry &storeToModify) override
 add proxies to the store to modify (during Begin Event)
virtual SG::DataProxyretrieveProxy (const CLID &id, const std::string &key, IProxyRegistry &storeToModify) override
 Use a provider to create a proxy for ID/KEY.
SG::DataProxyaddAddress (IProxyRegistry &storeToModify, SG::TransientAddress &&tad)
 create a new Proxy, overriding CLID and/or key
virtual void addProvider (IAddressProvider *aProvider) override final
 IAddressProvider manager functionality add a provider to the set of known ones.
virtual StatusCode initialize () override
 Service boilerplate.
 ProxyProviderSvc (const std::string &name, ISvcLocator *svcLoc)
 Standard Service Constructor.
virtual ~ProxyProviderSvc ()

Private Member Functions

const EventContext & contextFromStore (IProxyRegistry &ds) const
 Retrieve the EventContext saved in store DS.
StatusCode addAddresses (IProxyRegistry &store, TAdList &tList)
 Add lists of TADs to the store.
void providerNamesPropertyHandler (Gaudi::Details::PropertyBase &theProp)
 the handler for m_providerNames
StatusCode doPreLoadProxies (IProxyRegistry &storeToModify)

Private Attributes

StringArrayProperty m_providerNames
 property: the services declared as providers
std::list< IAddressProvider * > m_providers
 the providers we know about. WE DON'T OWN THEM
ServiceHandle< IConversionSvc > m_pDataLoader
 Persistency Service.
std::vector< IProxyRegistry * > m_pendingLoad
 List of pending stores on which to run preLoadProxies().

Detailed Description

manages the address providers and add proxies on demand to the store

Definition at line 41 of file ProxyProviderSvc.h.

Member Typedef Documentation

◆ pAPiterator

Definition at line 44 of file ProxyProviderSvc.h.

◆ TAdIterator

typedef TAdList::iterator ProxyProviderSvc::TAdIterator

Definition at line 46 of file ProxyProviderSvc.h.

◆ TAdList

Definition at line 45 of file ProxyProviderSvc.h.

Constructor & Destructor Documentation

◆ ProxyProviderSvc()

ProxyProviderSvc::ProxyProviderSvc ( const std::string & name,
ISvcLocator * svcLoc )

Standard Service Constructor.

Definition at line 52 of file ProxyProviderSvc.cxx.

53 :
54 base_class(name, svcLoc),
55 m_pDataLoader("EventPersistencySvc", name)
56{
58}
ServiceHandle< IConversionSvc > m_pDataLoader
Persistency Service.
StringArrayProperty m_providerNames
property: the services declared as providers
void providerNamesPropertyHandler(Gaudi::Details::PropertyBase &theProp)
the handler for m_providerNames

◆ ~ProxyProviderSvc()

ProxyProviderSvc::~ProxyProviderSvc ( )
virtual

Definition at line 60 of file ProxyProviderSvc.cxx.

60{}

Member Function Documentation

◆ addAddress()

SG::DataProxy * ProxyProviderSvc::addAddress ( IProxyRegistry & storeToModify,
SG::TransientAddress && tad )

create a new Proxy, overriding CLID and/or key

Definition at line 185 of file ProxyProviderSvc.cxx.

187{
188 //HACK! The proxies for all object those key starts with "HLTAutoKey" will be deleted at the end of each event (resetOnly=false)
189 //hence avoiding the proxy explosion observed with trigger object for releases <= 14.1.0
190 bool resetOnly(tAddr.name().substr(0,10) != std::string("HLTAutoKey"));
191 // std::cout << "PPS:addAdress: proxy for key " << tAddr->name() << " has resetOnly " << resetOnly << std::endl;
192 SG::DataProxy* dp = new SG::DataProxy(std::move(tAddr),
193 m_pDataLoader.get(), true, resetOnly );
194
195 // Must add the primary CLID first.
196 bool addedProxy = store.addToStore(dp->clID(), dp).isSuccess();
197 // ATH_MSG_VERBOSE("created proxy for " << tAddr->clID() << "/" << tAddr->name() << "using " << m_pDataLoader->repSvcType());
198 if (!addedProxy) {
199 ATH_MSG_ERROR ("Failed to add proxy to store "
200 << dp->clID() << "/" << dp->name());
201 delete dp;
202 dp = nullptr;
203 }
204 else {
205 // loop over all the transient CLIDs:
206 SG::TransientAddress::TransientClidSet tClid = dp->transientID();
207 for (CLID clid : tClid) {
208 if (clid != dp->clID()) {
209 bool flag = (store.addToStore(clid, dp)).isSuccess();
210 if (!flag) {
211 ATH_MSG_ERROR ("Failed to add proxy to store for symlink "
212 << clid << "/" << dp->name());
213 }
214 addedProxy &= flag;
215 }
216 }
217
218 // loop over all alias'
219 for (const std::string& alias : dp->alias()) {
220 (store.addAlias(alias, dp)).ignore();
221 }
222
223 // Add any other allowable conversions.
224 const SG::BaseInfoBase* bi = getBaseInfo (dp->clID());
225 if (bi) {
226 for (CLID clid : bi->get_bases()) {
227 if (std::find (tClid.begin(), tClid.end(), clid) == tClid.end()) {
228 store.addToStore (clid, dp).ignore();
229 dp->setTransientID (clid);
230 }
231 }
232
233 for (CLID clid : bi->get_copy_conversions()) {
234 if (std::find (tClid.begin(), tClid.end(), clid) == tClid.end()) {
235 store.addToStore (clid, dp).ignore();
236 dp->setTransientID (clid);
237 }
238 }
239 }
240 }
241
242 return dp;
243}
#define ATH_MSG_ERROR(x)
uint32_t CLID
The Class ID type.
virtual StatusCode addToStore(CLID, SG::DataProxy *proxy) override
const std::vector< CLID > & get_bases() const
Return the class IDs of all known bases of T (that have class IDs).
Definition BaseInfo.cxx:304
std::vector< CLID > get_copy_conversions() const
Return known copy conversions.
Definition BaseInfo.cxx:455
std::vector< CLID > TransientClidSet
Strictly a set, but there shouldn't be more than a handful of entries, so store it as a sorted vector...
TestStore store
Definition TestStore.cxx:23
bool flag
Definition master.py:29

◆ addAddresses()

StatusCode ProxyProviderSvc::addAddresses ( IProxyRegistry & store,
TAdList & tList )
private

Add lists of TADs to the store.

Parameters
storeStore to which to add.
tListList of TADs from all providers.

if proxy exists, simply update the proxy with new TransientAddress, else construct a new proxy

Definition at line 158 of file ProxyProviderSvc.cxx.

160{
161 for (SG::TransientAddress* tad : tList) {
162 SG::sgkey_t sgkey = tad->sgkey();
163 SG::DataProxy* proxy = sgkey ? store.proxy_exact(tad->sgkey()) : store.proxy_exact(tad->clID(), tad->name());
166 if (0 != proxy)
167 {
168 proxy->setAddress(tad->address());
169 if (proxy->provider() == 0) {
170 proxy->setProvider(tad->provider(), store.storeID());
171 }
172 }
173 else {
174 if ( 0 == addAddress(store, std::move(*tad)) ) return StatusCode::FAILURE;
175 }
176 delete tad;
177 }
178
179 return StatusCode::SUCCESS;
180}
SG::DataProxy * addAddress(IProxyRegistry &storeToModify, SG::TransientAddress &&tad)
create a new Proxy, overriding CLID and/or key
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const override
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
sgkey(tool)
Definition common.py:1027

◆ addProvider()

void ProxyProviderSvc::addProvider ( IAddressProvider * aProvider)
inlinefinaloverridevirtual

IAddressProvider manager functionality add a provider to the set of known ones.

PROVIDER IS OWNED BY THE CLIENT

Definition at line 119 of file ProxyProviderSvc.h.

119 {
120 assert(aProvider);
121 if (find(m_providers.begin(), m_providers.end(), aProvider) == m_providers.end()) {
122 m_providers.push_back(aProvider);
123 }
124}
std::list< IAddressProvider * > m_providers
the providers we know about. WE DON'T OWN THEM
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138

◆ contextFromStore()

const EventContext & ProxyProviderSvc::contextFromStore ( IProxyRegistry & ds) const
private

Retrieve the EventContext saved in store DS.

Parameters
dsThe store from which to retrieve the context.

If there is no context recorded in the store, return a default-initialized context.

Definition at line 275 of file ProxyProviderSvc.cxx.

276{
277 SG::DataProxy* proxy = ds.proxy (ClassID_traits<EventContext>::ID(),
278 "EventContext");
279 if (proxy) {
280 EventContext* ctx = SG::DataProxy_cast<EventContext> (proxy);
281 if (ctx) return *ctx;
282 }
283 static const EventContext emptyContext;
284 return emptyContext;
285}
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies

◆ doPreLoadProxies()

StatusCode ProxyProviderSvc::doPreLoadProxies ( IProxyRegistry & storeToModify)
private

Definition at line 102 of file ProxyProviderSvc.cxx.

103{
104 if (m_providers.empty()) return StatusCode::SUCCESS;
105
106 StoreID::type storeID = store.storeID();
107 TAdList tList;
108 for (IAddressProvider* provider : m_providers) {
109 ATH_CHECK( provider->preLoadAddresses(storeID, tList) );
110 setProviderOnList (tList, provider, storeID);
111 }
112 ATH_CHECK( addAddresses (store, tList) );
113 return StatusCode::SUCCESS;
114}
#define ATH_CHECK
Evaluate an expression and check for errors.
StatusCode addAddresses(IProxyRegistry &store, TAdList &tList)
Add lists of TADs to the store.
std::list< SG::TransientAddress * > TAdList

◆ initialize()

StatusCode ProxyProviderSvc::initialize ( )
overridevirtual

Service boilerplate.

Definition at line 63 of file ProxyProviderSvc.cxx.

64{
65 ATH_MSG_VERBOSE( "Initializing " << name() );
66
67 // retrieve Persistency Service
68 ATH_CHECK( m_pDataLoader.retrieve() );
69
70 // get properties set
71 ATH_CHECK( AthService::initialize() );
72
73 // Take care of any pending preLoadProxies requests.
74 for (IProxyRegistry* reg : m_pendingLoad) {
76 }
77 m_pendingLoad.clear();
78
79 return StatusCode::SUCCESS;
80}
#define ATH_MSG_VERBOSE(x)
StatusCode doPreLoadProxies(IProxyRegistry &storeToModify)
std::vector< IProxyRegistry * > m_pendingLoad
List of pending stores on which to run preLoadProxies().

◆ loadProxies()

StatusCode ProxyProviderSvc::loadProxies ( IProxyRegistry & storeToModify)
overridevirtual

add proxies to the store to modify (during Begin Event)

IProxyProvider interface add proxies to the store to modify.

Definition at line 138 of file ProxyProviderSvc.cxx.

139{
140 if (m_providers.empty()) return StatusCode::SUCCESS;
141
142 StoreID::type storeID = store.storeID();
143 TAdList tList;
144 for (IAddressProvider* provider : m_providers) {
145 ATH_CHECK( provider->loadAddresses(storeID, tList) );
146 setProviderOnList (tList, provider, storeID);
147 }
148 ATH_CHECK( addAddresses (store, tList) );
149 return StatusCode::SUCCESS;
150}

◆ preLoadProxies()

StatusCode ProxyProviderSvc::preLoadProxies ( IProxyRegistry & storeToModify)
overridevirtual

IProxyProvider interface.

IProxyProvider interface add proxies (before Begin Event)

add proxies to the store to modify (before Begin Event)

Definition at line 120 of file ProxyProviderSvc.cxx.

121{
122 // Due to initialization loops, it's possible for this to be called
123 // before the service is fully initialized. In that case, we may
124 // skip calling some of the providers. So we haven't been fully initialized,
125 // don't do anything now; rather, remember the store, and call
126 // preLoadProxies again for it at the end of initialize().
127 if (FSMState() == Gaudi::StateMachine::OFFLINE) {
128 m_pendingLoad.push_back (&store);
129 return StatusCode::SUCCESS;
130 }
131 return doPreLoadProxies (store);
132}

◆ providerNamesPropertyHandler()

void ProxyProviderSvc::providerNamesPropertyHandler ( Gaudi::Details::PropertyBase & theProp)
private

the handler for m_providerNames

Definition at line 289 of file ProxyProviderSvc.cxx.

289 {
290 //add declared providers to the list;
291 std::vector<std::string> providerNames = m_providerNames.value();
292
293 // FIXME: AddressRemappingSvc needs to come at the end, if it's provided.
294 auto it = std::find (providerNames.begin(), providerNames.end(),
295 "AddressRemappingSvc");
296 if (it != providerNames.end() && it != providerNames.end()-1) {
297 providerNames.erase (it);
298 providerNames.push_back ("AddressRemappingSvc");
299 }
300
301 for (const std::string& pName : providerNames) {
302 SmartIF<IAddressProvider> pAP{service(pName)};
303 if (!pAP) {
304 ATH_MSG_ERROR(" getting Address Provider "<< pName);
305 throw GaudiException("Failed to locate address provider",
306 "ProxyProviderSvc::providerNamesPropertyHandle",
307 StatusCode::FAILURE);
308 } else {
309 ATH_MSG_DEBUG(" added Address Provider "<< pName);
310 }
312 }
313
314}
#define ATH_MSG_DEBUG(x)
virtual void addProvider(IAddressProvider *aProvider) override final
IAddressProvider manager functionality add a provider to the set of known ones.

◆ retrieveProxy()

SG::DataProxy * ProxyProviderSvc::retrieveProxy ( const CLID & id,
const std::string & key,
IProxyRegistry & store )
overridevirtual

Use a provider to create a proxy for ID/KEY.

If successful, the new proxy will be added to DATASTORE and returned; otherwise, return null.

Definition at line 249 of file ProxyProviderSvc.cxx.

251{
252 if ( !m_providers.empty() ) {
253 const EventContext& ctx = contextFromStore (store);
254 SG::TransientAddress pTAd (id, key);
255 pAPiterator iProvider(m_providers.begin()), iEnd(m_providers.end());
256 for (; iProvider != iEnd; ++iProvider) {
257 if ( ((*iProvider)->updateAddress(store.storeID(),&pTAd,ctx)).isSuccess() )
258 {
259 pTAd.setProvider(*iProvider, store.storeID());
260 return this->addAddress(store,std::move(pTAd));
261 }
262 }
263 }
264
265 return nullptr;
266}
const EventContext & contextFromStore(IProxyRegistry &ds) const
Retrieve the EventContext saved in store DS.
std::list< IAddressProvider * >::iterator pAPiterator

Member Data Documentation

◆ m_pDataLoader

ServiceHandle<IConversionSvc> ProxyProviderSvc::m_pDataLoader
private

Persistency Service.

Definition at line 112 of file ProxyProviderSvc.h.

◆ m_pendingLoad

std::vector<IProxyRegistry*> ProxyProviderSvc::m_pendingLoad
private

List of pending stores on which to run preLoadProxies().

Definition at line 115 of file ProxyProviderSvc.h.

◆ m_providerNames

StringArrayProperty ProxyProviderSvc::m_providerNames
private
Initial value:
{this,"ProviderNames",{},
"names of the services to be use as address providers","OrderedSet<std::string>"}

property: the services declared as providers

Definition at line 102 of file ProxyProviderSvc.h.

102 {this,"ProviderNames",{},
103 "names of the services to be use as address providers","OrderedSet<std::string>"};

◆ m_providers

std::list<IAddressProvider*> ProxyProviderSvc::m_providers
private

the providers we know about. WE DON'T OWN THEM

Definition at line 110 of file ProxyProviderSvc.h.


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