The Gaudi Framework  master (37c0b60a)
AuditorTestAlg.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 // from Gaudi
13 #include <GaudiKernel/Algorithm.h>
14 
21 class AuditorTestAlg : public Algorithm {
22 public:
24  AuditorTestAlg( const std::string& name, ISvcLocator* pSvcLocator );
25 
26  ~AuditorTestAlg() override;
27 
28  StatusCode initialize() override;
29  StatusCode execute() override;
30  StatusCode finalize() override;
31 
32 protected:
33 private:
34 };
35 
36 //-----------------------------------------------------------------------------
37 // Implementation for class : AuditorTestAlg
38 //
39 // Apr 2, 2008 : Marco Clemencic
40 //-----------------------------------------------------------------------------
41 
42 // Declaration of the Algorithm Factory
44 
45 //=============================================================================
46 // Standard constructor, initializes variables
47 //=============================================================================
48 AuditorTestAlg::AuditorTestAlg( const std::string& name, ISvcLocator* pSvcLocator ) : Algorithm( name, pSvcLocator ) {}
49 //=============================================================================
50 // Destructor
51 //=============================================================================
53 
54 //=============================================================================
55 // Initialization
56 //=============================================================================
58  StatusCode sc = Algorithm::initialize(); // must be executed first
59  if ( sc.isFailure() ) return sc; // error printed already by Algorithm
60 
61  debug() << "==> Initialize" << endmsg;
62 
63  return StatusCode::SUCCESS;
64 }
65 
66 //=============================================================================
67 // Main execution
68 //=============================================================================
70 
71  debug() << "==> Execute" << endmsg;
72 
73  const IAuditor::CustomEventType evt( "loop" );
74  auditorSvc()->before( evt, name() );
75  for ( long i = 0; i < 1000000; ++i ) {}
76  auditorSvc()->after( evt, name() );
77 
78  return StatusCode::SUCCESS;
79 }
80 
81 //=============================================================================
82 // Finalize
83 //=============================================================================
85 
86  debug() << "==> Finalize" << endmsg;
87 
88  return Algorithm::finalize(); // must be called after all other actions
89 }
90 
91 //=============================================================================
IOTest.evt
evt
Definition: IOTest.py:107
std::string
STL class.
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:526
AuditorTestAlg::AuditorTestAlg
AuditorTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Definition: AuditorTestAlg.cpp:48
ISvcLocator
Definition: ISvcLocator.h:46
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition: Algorithm.h:178
Algorithm
Alias for backward compatibility.
Definition: Algorithm.h:58
Algorithm.h
Gaudi::Algorithm::auditorSvc
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Algorithm.cpp:555
AuditorTestAlg
Definition: AuditorTestAlg.cpp:21
StatusCode
Definition: StatusCode.h:65
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
AuditorTestAlg::~AuditorTestAlg
~AuditorTestAlg() override
Destructor.
Definition: AuditorTestAlg.cpp:52
Gaudi::Algorithm::finalize
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition: Algorithm.h:184
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
std
STL namespace.
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
AuditorTestAlg::finalize
StatusCode finalize() override
Algorithm finalization.
Definition: AuditorTestAlg.cpp:84
AuditorTestAlg::execute
StatusCode execute() override
Algorithm execution.
Definition: AuditorTestAlg.cpp:69
AuditorTestAlg::initialize
StatusCode initialize() override
Algorithm initialization.
Definition: AuditorTestAlg.cpp:57