ATLAS Offline Software
Loading...
Searching...
No Matches
ExpressionParsing::MultipleProxyLoader Class Reference

#include <MultipleProxyLoader.h>

Inheritance diagram for ExpressionParsing::MultipleProxyLoader:
Collaboration diagram for ExpressionParsing::MultipleProxyLoader:

Public Types

using VariableType = IAccessor::VariableType

Public Member Functions

 MultipleProxyLoader ()
virtual ~MultipleProxyLoader ()
IProxyLoaderpush_back (std::unique_ptr< IProxyLoader > proxyLoader)
virtual void reset () override
virtual IAccessor::VariableType variableType (const std::string &var_name) const override
virtual std::pair< IAccessor::VariableType, const IAccessor & > getAccessorFromString (const EventContext &ctx, const std::string &varname) const override
virtual int loadInt (const EventContext &ctx, const std::string &varname) const override
virtual double loadDouble (const EventContext &ctx, const std::string &varname) const override
virtual std::vector< int > loadVecInt (const EventContext &ctx, const std::string &varname) const override
virtual std::vector< double > loadVec (const EventContext &ctx, const std::string &varname) const override

Private Types

using proxyCache_t = CxxUtils::ConcurrentStrMap<const IAccessor *, CxxUtils::SimpleUpdater>

Private Attributes

std::vector< std::unique_ptr< IProxyLoader > > m_proxyLoaders
proxyCache_t m_varnameToProxyLoader ATLAS_THREAD_SAFE

Detailed Description

Definition at line 25 of file MultipleProxyLoader.h.

Member Typedef Documentation

◆ proxyCache_t

◆ VariableType

Constructor & Destructor Documentation

◆ MultipleProxyLoader()

ExpressionParsing::MultipleProxyLoader::MultipleProxyLoader ( )

Definition at line 21 of file MultipleProxyLoader.cxx.

21 :
22 m_varnameToProxyLoader(proxyCache_t::Updater_t())
23 {
24 }

◆ ~MultipleProxyLoader()

ExpressionParsing::MultipleProxyLoader::~MultipleProxyLoader ( )
virtual

Definition at line 26 of file MultipleProxyLoader.cxx.

27 {
28 }

Member Function Documentation

◆ getAccessorFromString()

std::pair< IAccessor::VariableType, const IAccessor & > ExpressionParsing::MultipleProxyLoader::getAccessorFromString ( const EventContext & ctx,
const std::string & varname ) const
overridevirtual

Implements ExpressionParsing::IProxyLoader.

Definition at line 52 of file MultipleProxyLoader.cxx.

53 {
54 auto itr = m_varnameToProxyLoader.find(varname);
55 if (itr != m_varnameToProxyLoader.end()) {
56 return {itr->second->variableType(varname),*itr->second};
57 }
58
59 for (const auto &proxyLoader : m_proxyLoaders) {
60 try {
61 std::pair<IAccessor::VariableType, const IAccessor &>
62 result = proxyLoader->getAccessorFromString(ctx, varname);
63 if (result.first == VT_UNK) continue;
64 if (result.first != VT_VECEMPTY) {
65 // do not cache the result for an "empty vector", since in such cases there is
66 // not enough information available to decide the correct accessor.
67 m_varnameToProxyLoader.emplace(varname, &result.second);
68 }
69 return result;
70 } catch (const std::runtime_error &) {
71 continue;
72 }
73 }
74 std::stringstream msg;
75 msg << "MultipleProxyLoader: unable to find valid proxy loader for " << varname << "."
76 << " If it is an xAOD element or container which is read from the input file"
77 << " this problem may occur if it is not accessed anywhere in the job via read handles."
78 << " The problem can be mitigated by providing the missing information in the property "
79 << " ExtraDataForDynamicConsumers of the sequence which has the property "
80 << " ProcessDynamicDataDependencies set to True."
81 << " The property takes a list of strings of the form \'type/container-name\' e.g."
82 << " \'xAOD::TrackParticleContainer/InDetTrackParticles\'.";
83 throw std::runtime_error(msg.str());
84 }
std::vector< std::unique_ptr< IProxyLoader > > m_proxyLoaders
MsgStream & msg
Definition testRead.cxx:32

◆ loadDouble()

double ExpressionParsing::MultipleProxyLoader::loadDouble ( const EventContext & ctx,
const std::string & varname ) const
overridevirtual

Implements ExpressionParsing::IAccessor.

Definition at line 91 of file MultipleProxyLoader.cxx.

92 {
93 return m_varnameToProxyLoader.at(varname)->loadDouble(ctx,varname);
94 }

◆ loadInt()

int ExpressionParsing::MultipleProxyLoader::loadInt ( const EventContext & ctx,
const std::string & varname ) const
overridevirtual

Implements ExpressionParsing::IAccessor.

Definition at line 86 of file MultipleProxyLoader.cxx.

87 {
88 return m_varnameToProxyLoader.at(varname)->loadInt(ctx,varname);
89 }

◆ loadVec()

std::vector< double > ExpressionParsing::MultipleProxyLoader::loadVec ( const EventContext & ctx,
const std::string & varname ) const
overridevirtual

Implements ExpressionParsing::IAccessor.

Definition at line 101 of file MultipleProxyLoader.cxx.

102 {
103 return m_varnameToProxyLoader.at(varname)->loadVec(ctx,varname);
104 }

◆ loadVecInt()

std::vector< int > ExpressionParsing::MultipleProxyLoader::loadVecInt ( const EventContext & ctx,
const std::string & varname ) const
overridevirtual

Implements ExpressionParsing::IAccessor.

Definition at line 96 of file MultipleProxyLoader.cxx.

97 {
98 return m_varnameToProxyLoader.at(varname)->loadVecInt(ctx,varname);
99 }

◆ push_back()

IProxyLoader * ExpressionParsing::MultipleProxyLoader::push_back ( std::unique_ptr< IProxyLoader > proxyLoader)

Definition at line 31 of file MultipleProxyLoader.cxx.

32 {
33 m_proxyLoaders.push_back(std::move(proxyLoader));
34 return m_proxyLoaders.back().get();
35 }

◆ reset()

void ExpressionParsing::MultipleProxyLoader::reset ( )
overridevirtual

Implements ExpressionParsing::IProxyLoader.

Definition at line 37 of file MultipleProxyLoader.cxx.

38 {
39 for (const auto &proxyLoader : m_proxyLoaders) {
40 proxyLoader->reset();
41 }
42 }

◆ variableType()

IAccessor::VariableType ExpressionParsing::MultipleProxyLoader::variableType ( const std::string & var_name) const
overridevirtual

Implements ExpressionParsing::IAccessor.

Definition at line 44 of file MultipleProxyLoader.cxx.

44 {
45 const EventContext& ctx = Gaudi::Hive::currentContext();
46 std::pair< IProxyLoader::VariableType, const IAccessor &>
47 ret = getAccessorFromString(ctx, varname);
48 return ret.first;
49 }
virtual std::pair< IAccessor::VariableType, const IAccessor & > getAccessorFromString(const EventContext &ctx, const std::string &varname) const override

Member Data Documentation

◆ ATLAS_THREAD_SAFE

proxyCache_t m_varnameToProxyLoader ExpressionParsing::MultipleProxyLoader::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 47 of file MultipleProxyLoader.h.

◆ m_proxyLoaders

std::vector<std::unique_ptr<IProxyLoader> > ExpressionParsing::MultipleProxyLoader::m_proxyLoaders
private

Definition at line 44 of file MultipleProxyLoader.h.


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