ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
CP::SelectionNameSvc Class Referencefinal

the canonical implementation of ISelectionNameSvc More...

#include <SelectionNameSvc.h>

Inheritance diagram for CP::SelectionNameSvc:
Collaboration diagram for CP::SelectionNameSvc:

Public Member Functions

 SelectionNameSvc (const std::string &name, ISvcLocator *pSvcLocator)
 standard constructor More...
 
virtual StatusCode initialize () override
 set up/tear down functions More...
 
virtual StatusCode addAcceptInfo (const std::string &objectName, const std::string &decorName, const asg::AcceptInfo &acceptInfo) override
 
virtual const asg::AcceptInfogetAcceptInfo (const std::string &objectName, const std::string &decorName) const override
 
virtual void print () const
 Print the state of the service. More...
 
template<typename T >
void declareServiceInterface ()
 add the given interface to the list of interfaces More...
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvi)
 query interface for gaudi More...
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 
 DeclareInterfaceID (CP::ISelectionNameSvc, 1, 0)
 

Private Attributes

ServiceHandle< ISystematicsSvcm_sysSvc {"SystematicsSvc", "SelectionNameSvc"}
 the ISystematicsSvc we use More...
 
std::unordered_map< std::string, std::unordered_map< std::string, asg::AcceptInfo > > m_acceptInfoMap
 the map of AcceptInfo objects More...
 
std::vector< std::pair< const InterfaceID &(*)(), void *(*)(AsgService *)> > m_interfaces
 list of interfaces we have More...
 

Detailed Description

the canonical implementation of ISelectionNameSvc

Definition at line 25 of file SelectionNameSvc.h.

Constructor & Destructor Documentation

◆ SelectionNameSvc()

CP::SelectionNameSvc::SelectionNameSvc ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

standard constructor

Guarantee
strong
Failures
out of memory II

Definition at line 27 of file SelectionNameSvc.cxx.

30  : AsgService (name, pSvcLocator)
31  {
32 
33  declareServiceInterface<ISelectionNameSvc>();
34  }

Member Function Documentation

◆ addAcceptInfo()

StatusCode CP::SelectionNameSvc::addAcceptInfo ( const std::string &  objectName,
const std::string &  decorName,
const asg::AcceptInfo acceptInfo 
)
overridevirtual

Implements CP::ISelectionNameSvc.

Definition at line 47 of file SelectionNameSvc.cxx.

50  {
51  ANA_MSG_DEBUG ("adding selection " << decorName << " for object " << objectName);
52  auto& subMap = m_acceptInfoMap[decorName];
53  if (subMap.find (objectName) != subMap.end())
54  {
55  ANA_MSG_ERROR ("object " << objectName << " already has a selection named " << decorName);
56  return StatusCode::FAILURE;
57  }
58  subMap[objectName] = acceptInfo;
59  if (getAcceptInfo(objectName, decorName) == nullptr)
60  {
61  ANA_MSG_ERROR ("failed to add selection " << decorName << " for object " << objectName);
62  return StatusCode::FAILURE;
63  }
64  return StatusCode::SUCCESS;
65  }

◆ DeclareInterfaceID()

CP::ISelectionNameSvc::DeclareInterfaceID ( CP::ISelectionNameSvc  ,
,
 
)
inherited

◆ declareServiceInterface()

template<typename T >
void asg::AsgService::declareServiceInterface
inherited

add the given interface to the list of interfaces

Definition at line 76 of file AsgService.h.

77  {
78 #ifndef XAOD_STANDALONE
79  m_interfaces.emplace_back (T::interfaceID, [] (AsgService *self) -> void* {return dynamic_cast<T*>(self);});
80 #endif
81  }

◆ finalize()

StatusCode asg::AsgService::finalize ( )
virtualinherited

Reimplemented in TrackAnalysisDefinitionSvc, CP::SystematicsSvc, PlotsDefinitionSvc, and AthOnnx::OnnxRuntimeSvc.

Definition at line 40 of file AsgService.cxx.

42  {
43  return StatusCode::SUCCESS;
44  }

◆ getAcceptInfo()

const asg::AcceptInfo * CP::SelectionNameSvc::getAcceptInfo ( const std::string &  objectName,
const std::string &  decorName 
) const
overridevirtual

Implements CP::ISelectionNameSvc.

Definition at line 69 of file SelectionNameSvc.cxx.

72  {
73  ANA_MSG_DEBUG ("querying selection " << decorName << " for object " << objectName);
74  auto subMap = m_acceptInfoMap.find (decorName);
75  if (subMap == m_acceptInfoMap.end())
76  return nullptr;
77  std::string myObjectName = objectName;
78  while (!myObjectName.empty())
79  {
80  auto result = subMap->second.find (myObjectName);
81  if (result != subMap->second.end())
82  {
83  ANA_MSG_DEBUG ("found selection " << decorName << " for object " << objectName << " using name " << myObjectName);
84  return &result->second;
85  }
86  myObjectName = m_sysSvc->getCopySource (myObjectName);
87  }
88  return nullptr;
89  }

◆ initialize()

StatusCode CP::SelectionNameSvc::initialize ( )
overridevirtual

set up/tear down functions

Reimplemented from asg::AsgService.

Definition at line 38 of file SelectionNameSvc.cxx.

40  {
41  ANA_CHECK (m_sysSvc.retrieve());
42  return StatusCode::SUCCESS;
43  }

◆ msg() [1/2]

MsgStream& AthCommonMsg< Service >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< Service >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< Service >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ print()

void asg::AsgService::print ( ) const
virtualinherited

Print the state of the service.

Implements asg::IAsgService.

Definition at line 48 of file AsgService.cxx.

49  {
50  ATH_MSG_INFO( "AsgService " << name() << " @ " << this );
51  return;
52  }

◆ queryInterface()

StatusCode asg::AsgService::queryInterface ( const InterfaceID &  riid,
void **  ppvi 
)
virtualinherited

query interface for gaudi

Definition at line 57 of file AsgService.cxx.

59  {
60  for (const auto& interface : m_interfaces)
61  {
62  if (riid == interface.first())
63  {
64  *ppvi = interface.second (this);
65  addRef();
66  return StatusCode::SUCCESS;
67  }
68  }
69  return AsgServiceBase::queryInterface (riid, ppvi);
70  }

Member Data Documentation

◆ m_acceptInfoMap

std::unordered_map<std::string, std::unordered_map<std::string, asg::AcceptInfo> > CP::SelectionNameSvc::m_acceptInfoMap
private

the map of AcceptInfo objects

Definition at line 69 of file SelectionNameSvc.h.

◆ m_interfaces

std::vector<std::pair<const InterfaceID& (*)(),void *(*)(AsgService*)> > asg::AsgService::m_interfaces
privateinherited

list of interfaces we have

Definition at line 68 of file AsgService.h.

◆ m_sysSvc

ServiceHandle<ISystematicsSvc> CP::SelectionNameSvc::m_sysSvc {"SystematicsSvc", "SelectionNameSvc"}
private

the ISystematicsSvc we use

This is needed to look up the source objects of object copies

Definition at line 66 of file SelectionNameSvc.h.


The documentation for this class was generated from the following files:
get_generator_info.result
result
Definition: get_generator_info.py:21
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
asg::AsgService::m_interfaces
std::vector< std::pair< const InterfaceID &(*)(), void *(*)(AsgService *)> > m_interfaces
list of interfaces we have
Definition: AsgService.h:68
CP::SelectionNameSvc::m_sysSvc
ServiceHandle< ISystematicsSvc > m_sysSvc
the ISystematicsSvc we use
Definition: SelectionNameSvc.h:66
CP::SelectionNameSvc::getAcceptInfo
virtual const asg::AcceptInfo * getAcceptInfo(const std::string &objectName, const std::string &decorName) const override
Definition: SelectionNameSvc.cxx:70
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CP::SelectionNameSvc::m_acceptInfoMap
std::unordered_map< std::string, std::unordered_map< std::string, asg::AcceptInfo > > m_acceptInfoMap
the map of AcceptInfo objects
Definition: SelectionNameSvc.h:69
asg::AsgService::AsgService
AsgService(const std::string &name, ISvcLocator *pSvcLocator)
Definition: AsgService.cxx:19
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288