The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MyGaudiTool.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 // Framework include files
13 #include "GaudiKernel/MsgStream.h"
14 
15 // Accessing data:
17 
18 // Tool example
19 #include "MyGaudiTool.h"
20 
21 // Declaration of the AlgTool Factory
23 
24 //------------------------------------------------------------------------------
25 const std::string& MyGaudiTool::message() const
26 //------------------------------------------------------------------------------
27 {
28  static const std::string msg( "It works!!!" );
29  return msg;
30 }
31 
32 //------------------------------------------------------------------------------
33 void MyGaudiTool::doIt() const
34 //------------------------------------------------------------------------------
35 {
36  info() << "doIt() has been called" << endmsg;
37  debug() << "doIt() [DEBUG] has been called" << endmsg;
38  // show the feature introduced with GAUDI-1078
39  if ( contextSvc() && name().substr( 0, 7 ) == "ToolSvc" ) Info( "public tool called by" ).ignore();
40 }
41 
42 //------------------------------------------------------------------------------
44 //------------------------------------------------------------------------------
45 {
46  info() << "doItAgain() has been called" << endmsg;
47 }
48 
49 //------------------------------------------------------------------------------
51 //------------------------------------------------------------------------------
52 {
54 
55  info() << "intialize() has been called" << endmsg;
56 
57  // Make use of tool<>
58 
59  info() << "Int = " << m_int.value() << endmsg;
60  info() << "Double = " << m_double.value() << endmsg;
61  info() << "String = " << m_string.value() << endmsg;
62  info() << "Bool = " << m_bool.value() << endmsg;
63 
64  return sc;
65 }
66 //------------------------------------------------------------------------------
68 //------------------------------------------------------------------------------
69 {
70  info() << "finalize() has been called" << endmsg;
71  return base_class::finalize();
72 }
73 
74 //------------------------------------------------------------------------------
76 //------------------------------------------------------------------------------
77 {
78  // do not print messages if we are created in genconf
79  const std::string cmd = System::cmdLineArgs()[0];
80  if ( cmd.find( "genconf" ) != std::string::npos ) return;
81 
82  info() << "destructor has been called" << endmsg;
83 }
GaudiHive.precedence.message
message
Definition: precedence.py:19
MyGaudiTool::m_bool
Gaudi::Property< bool > m_bool
Definition: MyGaudiTool.h:48
std::string
STL class.
MyGaudiTool::initialize
StatusCode initialize() override
Overriding initialize and finalize.
Definition: MyGaudiTool.cpp:50
GaudiException.h
std::string::find
T find(T... args)
MyGaudiTool::m_string
Gaudi::Property< std::string > m_string
Definition: MyGaudiTool.h:47
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:19
MyGaudiTool::doIt
void doIt() const override
Definition: MyGaudiTool.cpp:33
PhysicalConstants.h
MyGaudiTool::m_int
Gaudi::Property< int > m_int
Properties.
Definition: MyGaudiTool.h:45
AlgTool::name
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:67
MyGaudiTool::m_double
Gaudi::Property< double > m_double
Definition: MyGaudiTool.h:46
StatusCode
Definition: StatusCode.h:65
GaudiTool::Info
StatusCode Info(const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const size_t mx=10) const
Print the info message and return with the given StatusCode.
Definition: GaudiTool.h:716
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:239
FixTESPath< AlgTool >::initialize
StatusCode initialize() override
Definition: FixTESPath.h:49
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
StatusCode::ignore
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition: StatusCode.h:139
MyGaudiTool::~MyGaudiTool
~MyGaudiTool() override
Standard destructor.
Definition: MyGaudiTool.cpp:75
MyGaudiTool.h
MyGaudiTool
Definition: MyGaudiTool.h:24
MyGaudiTool::finalize
StatusCode finalize() override
Definition: MyGaudiTool.cpp:67
std
STL namespace.
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
System::cmdLineArgs
GAUDI_API const std::vector< std::string > cmdLineArgs()
Command line arguments including executable name as arg[0] as vector of strings.
Definition: System.cpp:363
GaudiTool::contextSvc
IAlgContextSvc * contextSvc() const
acessor to the Algorithm Context Service
Definition: GaudiTool.cpp:255
MyGaudiTool::doItAgain
void doItAgain() const override
Definition: MyGaudiTool.cpp:43
MsgStream.h
AlgTool::finalize
StatusCode finalize() override
Definition: AlgTool.cpp:266