The Gaudi Framework  master (181af51f)
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
17
18#include "../AlgTools/IMyTool.h"
19
20namespace bug_34121 {
21
22 class MyAlgorithm : public Algorithm {
23 public:
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 //------------------------------------------------------------------------------
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
52 }
53
54 //------------------------------------------------------------------------------
56 //------------------------------------------------------------------------------
57 info() << "executing...." << endmsg;
58
59 m_tool->doIt();
60
62 }
63
64 //------------------------------------------------------------------------------
66 //------------------------------------------------------------------------------
67 info() << "finalizing...." << endmsg;
68
70
72 }
73
74 // Static Factory declaration
76
77} // namespace bug_34121
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_COMPONENT(type)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition Algorithm.h:98
SmartIF< IToolSvc > & toolSvc() const
The standard ToolSvc service, Return a pointer to the service if present.
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
Example of an Interface of a Algorithm Tool.
Definition IMyTool.h:21
virtual StatusCode releaseTool(IAlgTool *tool)=0
Release the tool.
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
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isFailure() const
Definition StatusCode.h:129
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:139
constexpr static const auto SUCCESS
Definition StatusCode.h:99
StatusCode finalize() override
StatusCode initialize() override
Three mandatory member functions of any algorithm.
StatusCode execute() override
Gaudi::Property< std::string > m_toolName