ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
virtual StatusCode loadProxies (IProxyRegistry &storeToModify) override
 add proxies to the store to modify (during Begin Event) More...
 
virtual SG::DataProxyretrieveProxy (const CLID &id, const std::string &key, IProxyRegistry &storeToModify) override
 Use a provider to create a proxy for ID/KEY. More...
 
SG::DataProxyaddAddress (IProxyRegistry &storeToModify, SG::TransientAddress &&tad)
 create a new Proxy, overriding CLID and/or key More...
 
virtual void addProvider (IAddressProvider *aProvider) override final
 IAddressProvider manager functionality add a provider to the set of known ones. More...
 
virtual StatusCode initialize () override
 Service boilerplate. More...
 
 ProxyProviderSvc (const std::string &name, ISvcLocator *svcLoc)
 Standard Service Constructor. More...
 
virtual ~ProxyProviderSvc ()
 

Private Member Functions

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

Private Attributes

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

Detailed Description

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

Definition at line 42 of file ProxyProviderSvc.h.

Member Typedef Documentation

◆ pAPiterator

typedef std::list<IAddressProvider*>::iterator ProxyProviderSvc::pAPiterator

Definition at line 45 of file ProxyProviderSvc.h.

◆ TAdIterator

typedef TAdList::iterator ProxyProviderSvc::TAdIterator

Definition at line 47 of file ProxyProviderSvc.h.

◆ TAdList

Definition at line 46 of file ProxyProviderSvc.h.

Constructor & Destructor Documentation

◆ ProxyProviderSvc()

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

Standard Service Constructor.

Definition at line 51 of file ProxyProviderSvc.cxx.

52  :
53  base_class(name, svcLoc){
55 }

◆ ~ProxyProviderSvc()

ProxyProviderSvc::~ProxyProviderSvc ( )
virtual

Definition at line 57 of file ProxyProviderSvc.cxx.

57 {}

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 192 of file ProxyProviderSvc.cxx.

194 {
195  //HACK! The proxies for all object those key starts with "HLTAutoKey" will be deleted at the end of each event (resetOnly=false)
196  //hence avoiding the proxy explosion observed with trigger object for releases <= 14.1.0
197  bool resetOnly(tAddr.name().substr(0,10) != std::string("HLTAutoKey"));
198  // std::cout << "PPS:addAdress: proxy for key " << tAddr->name() << " has resetOnly " << resetOnly << std::endl;
199  SG::DataProxy* dp = new SG::DataProxy(std::move(tAddr),
200  m_pDataLoader, true, resetOnly );
201 
202  // Must add the primary CLID first.
203  bool addedProxy = store.addToStore(dp->clID(), dp).isSuccess();
204  // ATH_MSG_VERBOSE("created proxy for " << tAddr->clID() << "/" << tAddr->name() << "using " << m_pDataLoader->repSvcType());
205  if (!addedProxy) {
206  ATH_MSG_ERROR ("Failed to add proxy to store "
207  << dp->clID() << "/" << dp->name());
208  delete dp;
209  dp = nullptr;
210  }
211  else {
212  // loop over all the transient CLIDs:
213  SG::TransientAddress::TransientClidSet tClid = dp->transientID();
214  for (CLID clid : tClid) {
215  if (clid != dp->clID()) {
216  bool flag = (store.addToStore(clid, dp)).isSuccess();
217  if (!flag) {
218  ATH_MSG_ERROR ("Failed to add proxy to store for symlink "
219  << clid << "/" << dp->name());
220  }
221  addedProxy &= flag;
222  }
223  }
224 
225  // loop over all alias'
226  for (const std::string& alias : dp->alias()) {
227  (store.addAlias(alias, dp)).ignore();
228  }
229 
230  // Add any other allowable conversions.
231  const SG::BaseInfoBase* bi = getBaseInfo (dp->clID());
232  if (bi) {
233  for (CLID clid : bi->get_bases()) {
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  for (CLID clid : bi->get_copy_conversions()) {
241  if (std::find (tClid.begin(), tClid.end(), clid) == tClid.end()) {
242  store.addToStore (clid, dp).ignore();
243  dp->setTransientID (clid);
244  }
245  }
246  }
247  }
248 
249  return dp;
250 }

◆ 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 166 of file ProxyProviderSvc.cxx.

168 {
169  for (SG::TransientAddress* tad : tList) {
170  SG::DataProxy* proxy = store.proxy_exact(tad->clID(), tad->name());
173  if (0 != proxy)
174  {
175  proxy->setAddress(tad->address());
176  if (proxy->provider() == 0) {
177  proxy->setProvider(tad->provider(), store.storeID());
178  }
179  }
180  else {
181  if ( 0 == addAddress(store, std::move(*tad)) ) return StatusCode::FAILURE;
182  }
183  delete tad;
184  }
185 
186  return StatusCode::SUCCESS;
187 }

◆ 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 120 of file ProxyProviderSvc.h.

120  {
121  assert(aProvider);
122  if (find(m_providers.begin(), m_providers.end(), aProvider) == m_providers.end()) {
123  m_providers.push_back(aProvider);
124  }
125 }

◆ 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 282 of file ProxyProviderSvc.cxx.

283 {
285  "EventContext");
286  if (proxy) {
287  EventContext* ctx = SG::DataProxy_cast<EventContext> (proxy);
288  if (ctx) return *ctx;
289  }
290  static const EventContext emptyContext;
291  return emptyContext;
292 }

◆ doPreLoadProxies()

StatusCode ProxyProviderSvc::doPreLoadProxies ( IProxyRegistry storeToModify)
private

Definition at line 110 of file ProxyProviderSvc.cxx.

111 {
112  if (m_providers.empty()) return StatusCode::SUCCESS;
113 
114  StoreID::type storeID = store.storeID();
115  TAdList tList;
116  for (IAddressProvider* provider : m_providers) {
117  ATH_CHECK( provider->preLoadAddresses(storeID, tList) );
118  setProviderOnList (tList, provider, storeID);
119  }
120  ATH_CHECK( addAddresses (store, tList) );
121  return StatusCode::SUCCESS;
122 }

◆ initialize()

StatusCode ProxyProviderSvc::initialize ( )
overridevirtual

Service boilerplate.

Definition at line 60 of file ProxyProviderSvc.cxx.

61 {
62  ATH_MSG_VERBOSE( "Initializing " << name() );
63 
64  const bool CREATEIF(true);
65  // cache pointer to Persistency Service
66  if (!(service("EventPersistencySvc", m_pDataLoader, CREATEIF)).isSuccess()) {
67  m_pDataLoader = 0;
68  ATH_MSG_ERROR("Could not get pointer to Persistency Service");
69  return StatusCode::FAILURE;
70  } else {
71 #ifdef DEBUGPPS
72  ATH_MSG_VERBOSE("Got pointer to Persistency Service " << m_pDataLoader);
73 #endif
74  }
75 
76  //get properties set;
77  if(!(AthService::initialize()).isSuccess()) {
78  return StatusCode::FAILURE;
79  }
80 
81  // Take care of any pending preLoadProxies requests.
84  }
85  m_pendingLoad.clear();
86 
87  return StatusCode::SUCCESS;
88 }

◆ 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 146 of file ProxyProviderSvc.cxx.

147 {
148  if (m_providers.empty()) return StatusCode::SUCCESS;
149 
150  StoreID::type storeID = store.storeID();
151  TAdList tList;
152  for (IAddressProvider* provider : m_providers) {
153  ATH_CHECK( provider->loadAddresses(storeID, tList) );
154  setProviderOnList (tList, provider, storeID);
155  }
156  ATH_CHECK( addAddresses (store, tList) );
157  return StatusCode::SUCCESS;
158 }

◆ 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 128 of file ProxyProviderSvc.cxx.

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

◆ providerNamesPropertyHandler()

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

the handler for m_providerNames

Definition at line 296 of file ProxyProviderSvc.cxx.

296  {
297  //add declared providers to the list;
298  std::vector<std::string> providerNames = m_providerNames.value();
299 
300  // FIXME: AddressRemappingSvc needs to come at the end, if it's provided.
301  auto it = std::find (providerNames.begin(), providerNames.end(),
302  "AddressRemappingSvc");
303  if (it != providerNames.end() && it != providerNames.end()-1) {
304  providerNames.erase (it);
305  providerNames.push_back ("AddressRemappingSvc");
306  }
307 
308  for (const std::string& pName : providerNames) {
309  IService *pIS(0);
310  IAddressProvider *pAP(0);
311  ListItem tn(pName);
312  if (!(service(tn.type(), tn.name(), pIS)).isSuccess() ||
313  0 == (pAP = dynamic_cast<IAddressProvider*>(pIS))) {
314  ATH_MSG_ERROR(" getting Address Provider "<< pName);
315  throw GaudiException("Failed to locate address provider",
316  "ProxyProviderSvc::providerNamesPropertyHandle",
317  StatusCode::FAILURE);
318 
319  } else {
320  ATH_MSG_DEBUG(" added Address Provider "<< pIS->name());
321  }
323  }
324 
325 }

◆ 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 256 of file ProxyProviderSvc.cxx.

258 {
259  if ( !m_providers.empty() ) {
260  const EventContext& ctx = contextFromStore (store);
261  SG::TransientAddress pTAd (id, key);
262  pAPiterator iProvider(m_providers.begin()), iEnd(m_providers.end());
263  for (; iProvider != iEnd; ++iProvider) {
264  if ( ((*iProvider)->updateAddress(store.storeID(),&pTAd,ctx)).isSuccess() )
265  {
266  pTAd.setProvider(*iProvider, store.storeID());
267  return this->addAddress(store,std::move(pTAd));
268  }
269  }
270  }
271 
272  return nullptr;
273 }

Member Data Documentation

◆ m_pDataLoader

IConversionSvc* ProxyProviderSvc::m_pDataLoader {nullptr}
private

Persistency Service.

Definition at line 113 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 116 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 103 of file ProxyProviderSvc.h.

◆ m_providers

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

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

Definition at line 111 of file ProxyProviderSvc.h.


The documentation for this class was generated from the following files:
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:69
ProxyProviderSvc::pAPiterator
std::list< IAddressProvider * >::iterator pAPiterator
Definition: ProxyProviderSvc.h:45
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
checkxAOD.ds
ds
Definition: Tools/PyUtils/bin/checkxAOD.py:257
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
IProxyRegistry
a proxy registry (a read/write dictionary)
Definition: IProxyRegistry.h:27
ProxyProviderSvc::addProvider
virtual void addProvider(IAddressProvider *aProvider) override final
IAddressProvider manager functionality add a provider to the set of known ones.
Definition: ProxyProviderSvc.h:120
initialize
void initialize()
Definition: run_EoverP.cxx:894
ProxyProviderSvc::m_pendingLoad
std::vector< IProxyRegistry * > m_pendingLoad
List of pending stores on which to run preLoadProxies().
Definition: ProxyProviderSvc.h:116
skel.it
it
Definition: skel.GENtoEVGEN.py:423
ProxyProviderSvc::doPreLoadProxies
StatusCode doPreLoadProxies(IProxyRegistry &storeToModify)
Definition: ProxyProviderSvc.cxx:110
SG::TransientAddress
Definition: TransientAddress.h:32
ProxyProviderSvc::m_providerNames
StringArrayProperty m_providerNames
property: the services declared as providers
Definition: ProxyProviderSvc.h:103
SG::TransientAddress::TransientClidSet
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...
Definition: TransientAddress.h:38
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ProxyProviderSvc::addAddresses
StatusCode addAddresses(IProxyRegistry &store, TAdList &tList)
Add lists of TADs to the store.
Definition: ProxyProviderSvc.cxx:166
SG::BaseInfoBase::get_bases
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
python.DomainsRegistry.reg
reg
globals -----------------------------------------------------------------—
Definition: DomainsRegistry.py:343
ProxyProviderSvc::addAddress
SG::DataProxy * addAddress(IProxyRegistry &storeToModify, SG::TransientAddress &&tad)
create a new Proxy, overriding CLID and/or key
Definition: ProxyProviderSvc.cxx:192
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:54
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ProxyProviderSvc::m_providers
std::list< IAddressProvider * > m_providers
the providers we know about. WE DON'T OWN THEM
Definition: ProxyProviderSvc.h:111
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
COOLRates.alias
alias
Definition: COOLRates.py:1172
master.flag
bool flag
Definition: master.py:29
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
IAddressProvider
interface for IOA providers
Definition: IAddressProvider.h:28
SG::BaseInfoBase::get_copy_conversions
std::vector< CLID > get_copy_conversions() const
Return known copy conversions.
Definition: BaseInfo.cxx:455
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
ProxyProviderSvc::TAdList
std::list< SG::TransientAddress * > TAdList
Definition: ProxyProviderSvc.h:46
ProxyProviderSvc::m_pDataLoader
IConversionSvc * m_pDataLoader
Persistency Service.
Definition: ProxyProviderSvc.h:113
StoreID::type
type
Definition: StoreID.h:24
SG::BaseInfoBase
The non-template portion of the BaseInfo implementation.
Definition: Control/AthenaKernel/AthenaKernel/BaseInfo.h:451
ProxyProviderSvc::contextFromStore
const EventContext & contextFromStore(IProxyRegistry &ds) const
Retrieve the EventContext saved in store DS.
Definition: ProxyProviderSvc.cxx:282
SG::DataProxy
Definition: DataProxy.h:44
ProxyProviderSvc::providerNamesPropertyHandler
void providerNamesPropertyHandler(Gaudi::Details::PropertyBase &theProp)
the handler for m_providerNames
Definition: ProxyProviderSvc.cxx:296
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37