The Gaudi Framework  master (37c0b60a)
AbortEventAlg.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 
13 // from Gaudi
15 #include <GaudiKernel/Incident.h>
16 
17 // local
18 #include "AbortEventAlg.h"
19 
20 //-----------------------------------------------------------------------------
21 // Implementation file for class : AbortEventAlg
22 //
23 // Nov 16, 2007 : Marco Clemencic
24 //-----------------------------------------------------------------------------
25 
26 // Declaration of the Algorithm Factory
28 
29 //=============================================================================
30 // Initialization
31 //=============================================================================
32 StatusCode AbortEventAlg::initialize() {
33  StatusCode sc = Algorithm::initialize(); // must be executed first
34  if ( sc.isFailure() ) return sc; // error printed already by Algorithm
35 
36  debug() << "==> Initialize" << endmsg;
37 
38  m_incidentSvc = service( "IncidentSvc", true );
39 
40  m_counter = 0;
41 
42  return StatusCode::SUCCESS;
43 }
44 
45 //=============================================================================
46 // Main execution
47 //=============================================================================
49 
50  debug() << "==> Execute" << endmsg;
51 
52  if ( ++m_counter == m_count ) { m_incidentSvc->fireIncident( Incident( name(), IncidentType::AbortEvent ) ); }
53 
54  return StatusCode::SUCCESS;
55 }
56 
57 //=============================================================================
58 // Finalize
59 //=============================================================================
61 
62  debug() << "==> Finalize" << endmsg;
63 
64  return Algorithm::finalize(); // must be called after all other actions
65 }
66 
67 //=============================================================================
AbortEventAlg::m_counter
long m_counter
Counter of events.
Definition: AbortEventAlg.h:41
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:526
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition: Algorithm.h:178
AbortEventAlg::execute
StatusCode execute() override
Algorithm execution.
Definition: AbortEventAlg.cpp:48
AbortEventAlg
Definition: AbortEventAlg.h:26
IIncidentSvc.h
StatusCode
Definition: StatusCode.h:65
AbortEventAlg::m_count
Gaudi::Property< long > m_count
Definition: AbortEventAlg.h:36
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
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
AbortEventAlg::m_incidentSvc
SmartIF< IIncidentSvc > m_incidentSvc
Pointer to the incident service.
Definition: AbortEventAlg.h:39
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
AbortEventAlg::finalize
StatusCode finalize() override
Algorithm finalization.
Definition: AbortEventAlg.cpp:60
Incident.h
Incident
Definition: Incident.h:27
AbortEventAlg.h