ATLAS Offline Software
Loading...
Searching...
No Matches
UnitTestTool1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8
9//
10// includes
11//
12
14
15#include <map>
16#include <mutex>
17
18//
19// method implementations
20//
21
22namespace asg
23{
24 UnitTestTool1 ::
25 UnitTestTool1 (const std::string& val_name)
26 : AsgTool (val_name)
27 {
28 std::scoped_lock lock(m_mutex);
29 ++ m_instances[name()];
30
31 ANA_MSG_DEBUG ("create UnitTestTool1 " << this);
32 }
33
34
35
36 UnitTestTool1 ::
37 ~UnitTestTool1 ()
38 {
39 ANA_MSG_DEBUG ("destroy UnitTestTool1 " << this);
40
41 std::scoped_lock lock(m_mutex);
42 -- m_instances[name()];
43 }
44
45
46
47 StatusCode UnitTestTool1 ::
48 initialize ()
49 {
50 ANA_MSG_INFO ("initialize UnitTestTool1 " << this);
51 ANA_MSG_INFO (" propertyString: " << m_propertyString);
52 ANA_MSG_INFO (" propertyInt: " << m_propertyInt);
53
55 {
56 ATH_MSG_ERROR ("tool configured to fail initialize");
57 return StatusCode::FAILURE;
58 }
60 {
61 ATH_MSG_ERROR ("initialize called twice");
62 return StatusCode::FAILURE;
63 }
64 m_isInitialized = true;
65 return StatusCode::SUCCESS;
66 }
67
68
69
70 std::string UnitTestTool1 ::
71 getPropertyString () const
72 {
73 return m_propertyString;
74 }
75
76
77
78 int UnitTestTool1 ::
79 getPropertyInt () const
80 {
81 return m_propertyInt;
82 }
83
84
85
86 void UnitTestTool1 ::
87 setPropertyInt (int val_property)
88 {
89 m_propertyInt = val_property;
90 }
91
92
93
94 bool UnitTestTool1 ::
95 isInitialized () const
96 {
97 return m_isInitialized;
98 }
99
100
101
102 int UnitTestTool1 ::
103 instance_counts (const std::string& name)
104 {
105 std::scoped_lock lock(m_mutex);
106 auto iter = m_instances.find(name);
107 assert (iter != m_instances.end());
108 return iter->second;
109 }
110}
#define ATH_MSG_ERROR(x)
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
static std::mutex m_mutex
mutex for above map
Gaudi::Property< std::string > m_propertyString
the string property
Gaudi::Property< int > m_propertyInt
the integer property
Gaudi::Property< bool > m_initializeFail
whether initialize should fail
bool m_isInitialized
whether initialize has been called