ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ExpressionParsing::AccessorFactory Class Reference

Class which creates accessors for the specified xAOD object content (singleton). More...

#include <xAODAccessor.h>

Inheritance diagram for ExpressionParsing::AccessorFactory:
Collaboration diagram for ExpressionParsing::AccessorFactory:

Public Member Functions

 AccessorFactory ()
 
std::unique_ptr< IAccessorcreate (const SG::ReadHandleKey< SG::AuxElement > &key, SG::auxid_t auxid, const SG::ReadDecorHandleKey< SG::AuxElement > *decor_key=nullptr) const
 create an accessor for the specified content of an AuxElement. More...
 
std::unique_ptr< IAccessorcreate (const SG::ReadHandleKey< SG::AuxVectorBase > &key, SG::auxid_t auxid, const SG::ReadDecorHandleKey< SG::AuxVectorBase > *decor_key=nullptr) const
 create an accessor for the specified content of an AuxVectorBase. More...
 

Static Public Member Functions

static AccessorFactoryinstance ()
 

Private Member Functions

const IAccessorKitgetKit (SG::auxid_t auxid) const
 Get an auxiliary class which creates an accessor for the specified content. More...
 

Private Attributes

std::map< std::size_t, std::unique_ptr< IAccessorKit > > m_kits
 

Static Private Attributes

static CxxUtils::CachedUniquePtrT< AccessorFactory > s_instance ATLAS_THREAD_SAFE
 

Detailed Description

Class which creates accessors for the specified xAOD object content (singleton).

The accessors will either use xAOD accessor access or read decoration handles.

Definition at line 181 of file xAODAccessor.h.

Constructor & Destructor Documentation

◆ AccessorFactory()

ExpressionParsing::AccessorFactory::AccessorFactory ( )
inline

Definition at line 183 of file xAODAccessor.h.

183  {
184  m_kits.insert( std::make_pair(typeid(float).hash_code(), std::make_unique<AccessorKit<float,IProxyLoader::VT_VECDOUBLE> >()));
185  m_kits.insert( std::make_pair(typeid(double).hash_code(), std::make_unique<AccessorKit<double,IProxyLoader::VT_VECDOUBLE> >()));
186  m_kits.insert( std::make_pair(typeid(bool).hash_code(), std::make_unique<AccessorKit<bool,IProxyLoader::VT_VECINT> >()));
187  m_kits.insert( std::make_pair(typeid(unsigned char).hash_code(), std::make_unique<AccessorKit<unsigned char,IProxyLoader::VT_VECINT> >()));
188  m_kits.insert( std::make_pair(typeid(unsigned short).hash_code(), std::make_unique<AccessorKit<unsigned short,IProxyLoader::VT_VECINT> >()));
189  m_kits.insert( std::make_pair(typeid(unsigned int).hash_code(), std::make_unique<AccessorKit<unsigned int,IProxyLoader::VT_VECINT> >()));
190  m_kits.insert( std::make_pair(typeid(unsigned long).hash_code(), std::make_unique<AccessorKit<unsigned long,IProxyLoader::VT_VECINT> >())); // @TODO might get cropped if int interface is used
191  m_kits.insert( std::make_pair(typeid(char).hash_code(), std::make_unique<AccessorKit<char,IProxyLoader::VT_VECINT> >()));
192  m_kits.insert( std::make_pair(typeid(short).hash_code(), std::make_unique<AccessorKit<short,IProxyLoader::VT_VECINT> >()));
193  m_kits.insert( std::make_pair(typeid(int).hash_code(), std::make_unique<AccessorKit<int,IProxyLoader::VT_VECINT> >()));
194  m_kits.insert( std::make_pair(typeid(long).hash_code(), std::make_unique<AccessorKit<long,IProxyLoader::VT_VECINT> >())); // @TODO might get cropped if int interface is used
195  }

Member Function Documentation

◆ create() [1/2]

std::unique_ptr<IAccessor> ExpressionParsing::AccessorFactory::create ( const SG::ReadHandleKey< SG::AuxElement > &  key,
SG::auxid_t  auxid,
const SG::ReadDecorHandleKey< SG::AuxElement > *  decor_key = nullptr 
) const
inline

create an accessor for the specified content of an AuxElement.

Definition at line 198 of file xAODAccessor.h.

200  {
201  return getKit(auxid).create(key,auxid, decor_key);
202  }

◆ create() [2/2]

std::unique_ptr<IAccessor> ExpressionParsing::AccessorFactory::create ( const SG::ReadHandleKey< SG::AuxVectorBase > &  key,
SG::auxid_t  auxid,
const SG::ReadDecorHandleKey< SG::AuxVectorBase > *  decor_key = nullptr 
) const
inline

create an accessor for the specified content of an AuxVectorBase.

Definition at line 204 of file xAODAccessor.h.

206  {
207  return getKit(auxid).create(key,auxid, decor_key);
208  }

◆ getKit()

const IAccessorKit& ExpressionParsing::AccessorFactory::getKit ( SG::auxid_t  auxid) const
inlineprivate

Get an auxiliary class which creates an accessor for the specified content.

Definition at line 214 of file xAODAccessor.h.

214  {
215  const std::type_info* the_type_info = SG::AuxTypeRegistry::instance().getType (auxid);
216  if (!the_type_info) {
217  std::stringstream msg;
218  msg << "ExpressionParsing::AccessorFactory: no type information about " << auxid
219  << " (" << SG::AuxTypeRegistry::instance().getName(auxid) << ")";
220  throw std::runtime_error(msg.str());
221  }
222  std::map<std::size_t, std::unique_ptr<IAccessorKit> >::const_iterator
223  iter = m_kits.find(the_type_info->hash_code());
224  if (iter == m_kits.end()) {
225  std::stringstream msg;
226  msg << "ExpressionParsing::AccessorFactory: no type information about " << auxid
227  << " (" << SG::AuxTypeRegistry::instance().getName(auxid) << ")";
228  throw std::runtime_error(msg.str());
229  }
230  return *(iter->second);
231  }

◆ instance()

static AccessorFactory & ExpressionParsing::Singleton< AccessorFactory >::instance
inlinestaticinherited

Definition at line 90 of file PhysicsAnalysis/CommonTools/ExpressionEvaluation/src/Utils.h.

90  {
91  if (!s_instance) {
92  s_instance.set(std::make_unique<T_Derived>());
93  }
94  return *s_instance;
95  }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

CxxUtils::CachedUniquePtrT<AccessorFactory > s_instance ExpressionParsing::Singleton< AccessorFactory >::ATLAS_THREAD_SAFE
staticprivateinherited

◆ m_kits

std::map<std::size_t, std::unique_ptr<IAccessorKit> > ExpressionParsing::AccessorFactory::m_kits
private

Definition at line 232 of file xAODAccessor.h.


The documentation for this class was generated from the following file:
ExpressionParsing::IAccessorKit::create
virtual std::unique_ptr< IAccessor > create(const SG::ReadHandleKey< SG::AuxVectorBase > &key, SG::auxid_t auxid, const SG::ReadDecorHandleKey< SG::AuxVectorBase > *decor_key=nullptr) const =0
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:49
ExpressionParsing::AccessorFactory::m_kits
std::map< std::size_t, std::unique_ptr< IAccessorKit > > m_kits
Definition: xAODAccessor.h:232
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
SG::AuxTypeRegistry::getName
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
Definition: AuxTypeRegistry.cxx:277
SG::AuxTypeRegistry::getType
const std::type_info * getType(SG::auxid_t auxid) const
Return the type of an aux data item.
Definition: AuxTypeRegistry.cxx:302
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
ExpressionParsing::AccessorFactory::getKit
const IAccessorKit & getKit(SG::auxid_t auxid) const
Get an auxiliary class which creates an accessor for the specified content.
Definition: xAODAccessor.h:214
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37