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

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
 
virtual std::string getPropertyString () const override
 
virtual int getPropertyInt () const override
 
virtual void setPropertyInt (int val_property) override
 
virtual bool isInitialized () const override
 

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...
 

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  : base_class (name, pSvcLocator)
31  {
32  declareProperty ("propertyInt", m_propertyInt, "the integer property");
33  declareProperty ("propertyString", m_propertyString, "the string property");
34  declareProperty ("initializeFail", m_initializeFail, "whether initialize should fail");
35 
36  ++ instance_counts (name);
37 
38  ANA_MSG_DEBUG ("create UnitTestService1 " << this);
39  }

◆ ~UnitTestService1()

asg::UnitTestService1::~UnitTestService1 ( )

standard destructor

Definition at line 43 of file UnitTestService1.cxx.

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

Member Function Documentation

◆ getPropertyInt()

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

Definition at line 84 of file UnitTestService1.cxx.

86  {
87  return m_propertyInt;
88  }

◆ getPropertyString()

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

Definition at line 76 of file UnitTestService1.cxx.

78  {
79  return m_propertyString;
80  }

◆ initialize()

StatusCode asg::UnitTestService1::initialize ( )
override

Definition at line 53 of file UnitTestService1.cxx.

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

◆ 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 108 of file UnitTestService1.cxx.

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

◆ isInitialized()

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

Definition at line 100 of file UnitTestService1.cxx.

102  {
103  return m_isInitialized;
104  }

◆ setPropertyInt()

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

Definition at line 92 of file UnitTestService1.cxx.

94  {
95  m_propertyInt = val_property;
96  }

Member Data Documentation

◆ m_initializeFail

bool asg::UnitTestService1::m_initializeFail = false

whether initialize should fail

Definition at line 64 of file UnitTestService1.h.

◆ m_isInitialized

bool asg::UnitTestService1::m_isInitialized = false

whether initialize has been called

Definition at line 52 of file UnitTestService1.h.

◆ m_propertyInt

int asg::UnitTestService1::m_propertyInt = -7

the integer property

Definition at line 60 of file UnitTestService1.h.

◆ m_propertyString

std::string asg::UnitTestService1::m_propertyString

the string property

Definition at line 56 of file UnitTestService1.h.


The documentation for this struct was generated from the following files:
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:109
asg::UnitTestService1::m_initializeFail
bool m_initializeFail
whether initialize should fail
Definition: UnitTestService1.h:64
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:52
asg::UnitTestService1::m_propertyInt
int m_propertyInt
the integer property
Definition: UnitTestService1.h:60
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
asg::UnitTestService1::m_propertyString
std::string m_propertyString
the string property
Definition: UnitTestService1.h:56
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288