Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v36r16 (ea80daf8)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MyAlgorithm.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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/DataObject.h"
14 #include "GaudiKernel/IToolSvc.h"
15 
16 #include "IMyTool.h"
17 #include "MyAlgorithm.h"
18 
19 // Static Factory declaration
20 
22 
23 //------------------------------------------------------------------------------
24 StatusCode MyAlgorithm::initialize() {
25  //------------------------------------------------------------------------------
26 
27  StatusCode sc;
28  info() << "initializing...." << endmsg;
29 
30  if ( !m_privateToolsOnly ) {
31  sc = toolSvc()->retrieveTool( "MyTool", m_publicTool );
32  if ( sc.isFailure() ) {
33  error() << "Error retrieving the public tool" << endmsg;
34  return sc;
35  }
36  sc = toolSvc()->retrieveTool( "MyGaudiTool", m_publicGTool );
37  if ( sc.isFailure() ) {
38  error() << "Error retrieving the Gaudi public tool" << endmsg;
39  return sc;
40  }
41  }
42 
43  sc = toolSvc()->retrieveTool( "MyTool", m_privateTool, this );
44  if ( sc.isFailure() ) {
45  error() << "Error retrieving the private tool" << endmsg;
46  return sc;
47  }
48 
49  sc = toolSvc()->retrieveTool( "MyGaudiTool", m_privateGTool, this );
50  if ( sc.isFailure() ) {
51  error() << "Error retrieving the Gaudi private tool" << endmsg;
52  return sc;
53  }
54 
55  sc = toolSvc()->retrieveTool( m_privateToolType, "ToolWithName", m_privateToolWithName, this );
56  if ( sc.isFailure() ) {
57  error() << "Error retrieving the private tool with name" << endmsg;
58  return sc;
59  }
60 
61  sc = toolSvc()->retrieveTool( "MyGaudiTool", m_privateOtherInterface, this );
62  if ( sc.isFailure() ) {
63  error() << "Error retrieving the Gaudi private tool with second interface" << endmsg;
64  return sc;
65  }
66 
67  info() << "....initialization done" << endmsg;
68 
69  return StatusCode::SUCCESS;
70 }
71 
72 //------------------------------------------------------------------------------
74  //------------------------------------------------------------------------------
75  info() << "executing...." << endmsg;
76 
77  if ( !m_privateToolsOnly ) {
78  m_publicTool->doIt();
80  }
85 
86  return StatusCode::SUCCESS;
87 }
88 
89 //------------------------------------------------------------------------------
91  //------------------------------------------------------------------------------
92  info() << "finalizing...." << endmsg;
93 
94  if ( !m_privateToolsOnly ) {
95  toolSvc()->releaseTool( m_publicTool ).ignore();
96  toolSvc()->releaseTool( m_publicGTool ).ignore();
97  }
98  toolSvc()->releaseTool( m_privateTool ).ignore();
99  toolSvc()->releaseTool( m_privateGTool ).ignore();
100  toolSvc()->releaseTool( m_privateToolWithName ).ignore();
101  toolSvc()->releaseTool( m_privateOtherInterface ).ignore();
102 
103  return StatusCode::SUCCESS;
104 }
MyAlgorithm::m_privateToolWithName
IMyTool * m_privateToolWithName
Definition: MyAlgorithm.h:49
Gaudi::Algorithm::toolSvc
SmartIF< IToolSvc > & toolSvc() const
The standard ToolSvc service, Return a pointer to the service if present.
Definition: Algorithm.cpp:566
IMyTool.h
IMyTool::doIt
virtual void doIt() const =0
Do something.
MyAlgorithm
Definition: MyAlgorithm.h:27
MyAlgorithm::m_publicTool
IMyTool * m_publicTool
Definition: MyAlgorithm.h:45
MyAlgorithm::m_privateToolsOnly
Gaudi::Property< bool > m_privateToolsOnly
Definition: MyAlgorithm.h:42
IDataProviderSvc.h
MyAlgorithm::m_privateGTool
IMyTool * m_privateGTool
Definition: MyAlgorithm.h:46
IToolSvc.h
StatusCode
Definition: StatusCode.h:65
IMyOtherTool::doItAgain
virtual void doItAgain()=0
Do something else.
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
MyAlgorithm::m_publicGTool
IMyTool * m_publicGTool
Definition: MyAlgorithm.h:47
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
MyAlgorithm::m_privateOtherInterface
IMyOtherTool * m_privateOtherInterface
Definition: MyAlgorithm.h:51
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
DataObject.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
MyAlgorithm::m_privateTool
IMyTool * m_privateTool
Definition: MyAlgorithm.h:44
MyAlgorithm::finalize
StatusCode finalize() override
Definition: MyAlgorithm.cpp:90
MyAlgorithm.h
MyAlgorithm::execute
StatusCode execute() override
Definition: MyAlgorithm.cpp:73