The Gaudi Framework
master (9f3f8895)
Toggle main menu visibility
Loading...
Searching...
No Matches
bug34121_MyAlgorithm.cpp
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
// Include files
12
#include <
GaudiKernel/Algorithm.h
>
13
#include <
GaudiKernel/DataObject.h
>
14
#include <
GaudiKernel/IDataProviderSvc.h
>
15
#include <
GaudiKernel/IToolSvc.h
>
16
#include <
GaudiKernel/MsgStream.h
>
17
18
#include "
../AlgTools/IMyTool.h
"
19
20
namespace
bug_34121
{
21
22
class
MyAlgorithm
:
public
Algorithm
{
23
public
:
25
using
Algorithm::Algorithm
;
26
28
StatusCode
initialize
()
override
;
29
StatusCode
execute
()
override
;
30
StatusCode
finalize
()
override
;
31
32
private
:
33
Gaudi::Property<std::string>
m_toolName
{
this
,
"Tool"
,
"bug_34121::Tool"
,
"Type of the tool to use"
};
34
IMyTool
*
m_tool
=
nullptr
;
35
};
36
37
//------------------------------------------------------------------------------
38
StatusCode
MyAlgorithm::initialize
() {
39
//------------------------------------------------------------------------------
40
41
StatusCode
sc;
42
info
() <<
"initializing...."
<<
endmsg
;
43
44
sc =
toolSvc
()->
retrieveTool
(
m_toolName
,
m_tool
,
this
);
45
if
( sc.
isFailure
() ) {
46
error
() <<
"Error retrieving the tool"
<<
endmsg
;
47
return
sc;
48
}
49
info
() <<
"....initialization done"
<<
endmsg
;
50
51
return
StatusCode::SUCCESS
;
52
}
53
54
//------------------------------------------------------------------------------
55
StatusCode
MyAlgorithm::execute
() {
56
//------------------------------------------------------------------------------
57
info
() <<
"executing...."
<<
endmsg
;
58
59
m_tool
->doIt();
60
61
return
StatusCode::SUCCESS
;
62
}
63
64
//------------------------------------------------------------------------------
65
StatusCode
MyAlgorithm::finalize
() {
66
//------------------------------------------------------------------------------
67
info
() <<
"finalizing...."
<<
endmsg
;
68
69
toolSvc
()->
releaseTool
(
m_tool
).
ignore
();
70
71
return
StatusCode::SUCCESS
;
72
}
73
74
// Static Factory declaration
75
DECLARE_COMPONENT
(
MyAlgorithm
)
76
77
}
// namespace bug_34121
DataObject.h
Algorithm.h
IDataProviderSvc.h
IMyTool.h
IToolSvc.h
MsgStream.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition
CommonMessaging.h:109
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition
CommonMessaging.h:115
Gaudi::Algorithm::Algorithm
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition
Algorithm.h:98
Gaudi::Algorithm::toolSvc
SmartIF< IToolSvc > & toolSvc() const
The standard ToolSvc service, Return a pointer to the service if present.
Definition
Algorithm.cpp:556
Gaudi::Property
Implementation of property with value of concrete type.
Definition
Property.h:35
IMyTool
Example of an Interface of a Algorithm Tool.
Definition
IMyTool.h:21
IToolSvc::releaseTool
virtual StatusCode releaseTool(IAlgTool *tool)=0
Release the tool.
IToolSvc::retrieveTool
StatusCode retrieveTool(std::string_view type, T *&tool, const IInterface *parent=nullptr, bool createIf=true)
Retrieve specified tool sub-type with tool dependent part of the name automatically assigned.
Definition
IToolSvc.h:147
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::isFailure
bool isFailure() const
Definition
StatusCode.h:118
StatusCode::ignore
void ignore() const
Allow discarding a StatusCode without warning.
Definition
StatusCode.h:128
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
bug_34121::MyAlgorithm
Definition
bug34121_MyAlgorithm.cpp:22
bug_34121::MyAlgorithm::m_tool
IMyTool * m_tool
Definition
bug34121_MyAlgorithm.cpp:34
bug_34121::MyAlgorithm::finalize
StatusCode finalize() override
Definition
bug34121_MyAlgorithm.cpp:65
bug_34121::MyAlgorithm::initialize
StatusCode initialize() override
Three mandatory member functions of any algorithm.
Definition
bug34121_MyAlgorithm.cpp:38
bug_34121::MyAlgorithm::execute
StatusCode execute() override
Definition
bug34121_MyAlgorithm.cpp:55
bug_34121::MyAlgorithm::m_toolName
Gaudi::Property< std::string > m_toolName
Definition
bug34121_MyAlgorithm.cpp:33
bug_34121
Definition
bug_34121.py:1
GaudiTestSuite
src
bug_34121
bug34121_MyAlgorithm.cpp
Generated on
for The Gaudi Framework by
1.17.0