ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | List of all members
asg::UnitTestService1 Struct Referenceabstract

a service used to unit test AnaToolHandle More...

#include <UnitTestService1.h>

Inheritance diagram for asg::UnitTestService1:
Collaboration diagram for asg::UnitTestService1:

Public Member Functions

 UnitTestService1 (const std::string &name, ISvcLocator *pSvcLocator)
 standard constructor More...
 
 ~UnitTestService1 ()
 standard destructor More...
 
StatusCode initialize () override
 set up/tear down functions More...
 
virtual std::string getPropertyString () const override
 get the integer property More...
 
virtual int getPropertyInt () const override
 get the integer property More...
 
virtual void setPropertyInt (int val_property) override
 get the integer property More...
 
virtual bool isInitialized () const override
 get whether we have been initialized More...
 
 DeclareInterfaceID (asg::IUnitTestService1, 1, 0)
 declare the interface that this class provides More...
 
virtual void print () const =0
 Print the state of the service. More...
 
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
 
virtual StatusCode finalize ()
 
virtual StatusCode finalize ()
 
virtual StatusCode finalize ()
 

Static Public Member Functions

static int & instance_counts (const std::string &name)
 the number of times the service of the given name has been instantiated More...
 

Public Attributes

bool m_isInitialized = false
 whether initialize has been called More...
 
std::string m_propertyString
 the string property More...
 
int m_propertyInt = -7
 the integer property More...
 
bool m_initializeFail = false
 whether initialize should fail More...
 

Private Attributes

std::vector< std::pair< const InterfaceID &(*)(), void *(*)(AsgService *)> > m_interfaces
 list of interfaces we have More...
 

Detailed Description

a service used to unit test AnaToolHandle

This allows to unit test the various capabilities of AnaToolHandle in a controlled fashion.

Definition at line 25 of file UnitTestService1.h.

Constructor & Destructor Documentation

◆ UnitTestService1()

asg::UnitTestService1::UnitTestService1 ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

standard constructor

Definition at line 28 of file UnitTestService1.cxx.

30  : AsgService (name, pSvcLocator)
31  {
32  declareServiceInterface<IUnitTestService1>();
33 
34  declareProperty ("propertyInt", m_propertyInt, "the integer property");
35  declareProperty ("propertyString", m_propertyString, "the string property");
36  declareProperty ("initializeFail", m_initializeFail, "whether initialize should fail");
37 
38  ++ instance_counts (name);
39 
40  ANA_MSG_DEBUG ("create UnitTestService1 " << this);
41  }

◆ ~UnitTestService1()

asg::UnitTestService1::~UnitTestService1 ( )

standard destructor

Definition at line 45 of file UnitTestService1.cxx.

47  {
48  ANA_MSG_DEBUG ("destroy UnitTestService1 " << this);
49 
50  -- instance_counts (name());
51  }

Member Function Documentation

◆ DeclareInterfaceID()

asg::IUnitTestService1::DeclareInterfaceID ( asg::IUnitTestService1  ,
,
 
)
inherited

declare the interface that this class provides

◆ 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  }

◆ getPropertyInt()

int asg::UnitTestService1::getPropertyInt ( ) const
overridevirtual

get the integer property

Implements asg::IUnitTestService1.

Definition at line 86 of file UnitTestService1.cxx.

88  {
89  return m_propertyInt;
90  }

◆ getPropertyString()

std::string asg::UnitTestService1::getPropertyString ( ) const
overridevirtual

get the integer property

Implements asg::IUnitTestService1.

Definition at line 78 of file UnitTestService1.cxx.

80  {
81  return m_propertyString;
82  }

◆ initialize()

StatusCode asg::UnitTestService1::initialize ( )
overridevirtual

set up/tear down functions

Reimplemented from asg::AsgService.

Definition at line 55 of file UnitTestService1.cxx.

57  {
58  ANA_MSG_INFO ("initialize UnitTestService1 " << this);
59  ANA_MSG_INFO (" propertyString: " << m_propertyString);
60  ANA_MSG_INFO (" propertyInt: " << m_propertyInt);
61 
62  if (m_initializeFail)
63  {
64  ATH_MSG_ERROR ("service configured to fail initialize");
65  return StatusCode::FAILURE;
66  }
67  if (m_isInitialized)
68  {
69  ATH_MSG_ERROR ("initialize called twice");
70  return StatusCode::FAILURE;
71  }
72  m_isInitialized = true;
73  return StatusCode::SUCCESS;
74  }

◆ instance_counts()

int & asg::UnitTestService1::instance_counts ( const std::string &  name)
static

the number of times the service of the given name has been instantiated

Definition at line 110 of file UnitTestService1.cxx.

112  {
113  static std::map<std::string,int> counts;
114  auto iter = counts.find (name);
115  if (iter == counts.end())
116  iter = counts.insert (std::make_pair (name, 0)).first;
117  assert (iter != counts.end());
118  return iter->second;
119  }

◆ isInitialized()

bool asg::UnitTestService1::isInitialized ( ) const
overridevirtual

get whether we have been initialized

Implements asg::IUnitTestService1.

Definition at line 102 of file UnitTestService1.cxx.

104  {
105  return m_isInitialized;
106  }

◆ 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() [1/2]

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  }

◆ print() [2/2]

virtual void asg::IAsgService::print ( ) const
pure virtualinherited

Print the state of the service.

Implemented in asg::AsgService.

◆ 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  }

◆ setPropertyInt()

void asg::UnitTestService1::setPropertyInt ( int  val_property)
overridevirtual

get the integer property

Implements asg::IUnitTestService1.

Definition at line 94 of file UnitTestService1.cxx.

96  {
97  m_propertyInt = val_property;
98  }

Member Data Documentation

◆ m_initializeFail

bool asg::UnitTestService1::m_initializeFail = false

whether initialize should fail

Definition at line 65 of file UnitTestService1.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_isInitialized

bool asg::UnitTestService1::m_isInitialized = false

whether initialize has been called

Definition at line 53 of file UnitTestService1.h.

◆ m_propertyInt

int asg::UnitTestService1::m_propertyInt = -7

the integer property

Definition at line 61 of file UnitTestService1.h.

◆ m_propertyString

std::string asg::UnitTestService1::m_propertyString

the string property

Definition at line 57 of file UnitTestService1.h.


The documentation for this struct was generated from the following files:
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
asg::AsgService::m_interfaces
std::vector< std::pair< const InterfaceID &(*)(), void *(*)(AsgService *)> > m_interfaces
list of interfaces we have
Definition: AsgService.h:68
asg::UnitTestService1::instance_counts
static int & instance_counts(const std::string &name)
the number of times the service of the given name has been instantiated
Definition: UnitTestService1.cxx:111
asg::UnitTestService1::m_initializeFail
bool m_initializeFail
whether initialize should fail
Definition: UnitTestService1.h:65
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
asg::UnitTestService1::m_isInitialized
bool m_isInitialized
whether initialize has been called
Definition: UnitTestService1.h:53
asg::UnitTestService1::m_propertyInt
int m_propertyInt
the integer property
Definition: UnitTestService1.h:61
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
asg::UnitTestService1::m_propertyString
std::string m_propertyString
the string property
Definition: UnitTestService1.h:57
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
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