ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthToolSupport
AsgExampleTools
Root
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
13
#include <
AsgExampleTools/UnitTestTool1.h
>
14
15
#include <map>
16
#include <mutex>
17
18
//
19
// method implementations
20
//
21
22
namespace
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
54
if
(
m_initializeFail
)
55
{
56
ATH_MSG_ERROR
(
"tool configured to fail initialize"
);
57
return
StatusCode::FAILURE;
58
}
59
if
(
m_isInitialized
)
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
}
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
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288
lock
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
UnitTestTool1.h
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
asg
Definition
DataHandleTestTool.h:28
asg::UnitTestTool1::m_mutex
static std::mutex m_mutex
mutex for above map
Definition
UnitTestTool1.h:56
asg::UnitTestTool1::m_propertyString
Gaudi::Property< std::string > m_propertyString
the string property
Definition
UnitTestTool1.h:59
asg::UnitTestTool1::m_propertyInt
Gaudi::Property< int > m_propertyInt
the integer property
Definition
UnitTestTool1.h:62
asg::UnitTestTool1::m_initializeFail
Gaudi::Property< bool > m_initializeFail
whether initialize should fail
Definition
UnitTestTool1.h:65
asg::UnitTestTool1::m_isInitialized
bool m_isInitialized
whether initialize has been called
Definition
UnitTestTool1.h:50
Generated on
for ATLAS Offline Software by
1.17.0