The Gaudi Framework  master (37c0b60a)
AlgExecStateSvc.h
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 #ifndef GAUDICORESVC_ALGEXECSTATESVC_H
12 #define GAUDICORESVC_ALGEXECSTATESVC_H 1
13 
15 #include <GaudiKernel/IAlgorithm.h>
16 #include <GaudiKernel/Service.h>
17 
18 #include <mutex>
19 #include <unordered_map>
20 #include <vector>
21 
26 class AlgExecStateSvc : public extends<Service, IAlgExecStateSvc> {
27 public:
28  using extends::extends;
29 
31 
33  const AlgExecState& algExecState( const Gaudi::StringKey& algName, const EventContext& ctx ) const override;
34  AlgExecState& algExecState( IAlgorithm* iAlg, const EventContext& ctx ) override;
35  const AlgStateMap_t& algExecStates( const EventContext& ctx ) const override;
36 
37  void reset( const EventContext& ctx ) override;
38 
40  void addAlg( const Gaudi::StringKey& algName ) override;
41 
42  const EventStatus::Status& eventStatus( const EventContext& ctx ) const override;
43 
44  void setEventStatus( const EventStatus::Status& sc, const EventContext& ctx ) override;
45 
46  void updateEventStatus( const bool& b, const EventContext& ctx ) override;
47 
48  unsigned int algErrorCount( const IAlgorithm* iAlg ) const override;
49  void resetErrorCount( const IAlgorithm* iAlg ) override;
50  unsigned int incrementErrorCount( const IAlgorithm* iAlg ) override;
51 
52  void dump( std::ostringstream& ost, const EventContext& ctx ) const override;
53 
54 private:
55  // one vector entry per event slot
58 
61 
63 
64  void init();
65  void checkInit() const;
67  bool m_isInit{ false };
68 
70 };
71 
72 #endif
AlgExecStateSvc::incrementErrorCount
unsigned int incrementErrorCount(const IAlgorithm *iAlg) override
Definition: AlgExecStateSvc.cpp:247
AlgExecStateSvc::init
void init()
Definition: AlgExecStateSvc.cpp:22
AlgExecStateSvc::algExecState
const AlgExecState & algExecState(const Gaudi::StringKey &algName, const EventContext &ctx) const override
Definition: AlgExecStateSvc.cpp:104
AlgExecStateSvc::m_eventStatus
std::vector< EventStatus::Status > m_eventStatus
Definition: AlgExecStateSvc.h:59
std::vector
STL class.
AlgExecStateSvc::checkInit
void checkInit() const
Definition: AlgExecStateSvc.cpp:53
AlgExecStateSvc::m_preInitAlgs
std::vector< Gaudi::StringKey > m_preInitAlgs
Definition: AlgExecStateSvc.h:60
AlgExecStateSvc::eventStatus
const EventStatus::Status & eventStatus(const EventContext &ctx) const override
Definition: AlgExecStateSvc.cpp:178
AlgExecStateSvc::addAlg
void addAlg(const Gaudi::StringKey &algName) override
Definition: AlgExecStateSvc.cpp:76
AlgExecStateSvc::resetErrorCount
void resetErrorCount(const IAlgorithm *iAlg) override
Definition: AlgExecStateSvc.cpp:235
AlgExecStateSvc::m_mut
std::mutex m_mut
Definition: AlgExecStateSvc.h:69
AlgExecStateSvc
A service that keeps track of the execution state of Algorithm.
Definition: AlgExecStateSvc.h:26
std::once_flag
AlgExecStateSvc::dump
void dump(std::ostringstream &ost, const EventContext &ctx) const override
Definition: AlgExecStateSvc.cpp:62
AlgExecStateSvc::AlgStateMap_t
IAlgExecStateSvc::AlgStateMap_t AlgStateMap_t
Definition: AlgExecStateSvc.h:30
Gaudi::StringKey
Definition: StringKey.h:44
AlgExecStateSvc::updateEventStatus
void updateEventStatus(const bool &b, const EventContext &ctx) override
Definition: AlgExecStateSvc.cpp:192
GaudiPython.Pythonizations.ctx
ctx
Definition: Pythonizations.py:578
AlgExecStateSvc::algErrorCount
unsigned int algErrorCount(const IAlgorithm *iAlg) const override
Definition: AlgExecStateSvc.cpp:222
IAlgorithm
Definition: IAlgorithm.h:38
AlgExecStateSvc::m_algSubSlotStates
std::vector< std::vector< AlgStateMap_t > > m_algSubSlotStates
Definition: AlgExecStateSvc.h:57
IAlgExecStateSvc::addAlg
virtual void addAlg(const Gaudi::StringKey &algName)=0
AlgExecStateSvc::m_isInit
bool m_isInit
Definition: AlgExecStateSvc.h:67
AlgExecStateSvc::m_algStates
std::vector< AlgStateMap_t > m_algStates
Definition: AlgExecStateSvc.h:56
AlgExecStateSvc::setEventStatus
void setEventStatus(const EventStatus::Status &sc, const EventContext &ctx) override
Definition: AlgExecStateSvc.cpp:185
std::map
STL class.
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
AlgExecStateSvc::m_errorCount
std::unordered_map< Gaudi::StringKey, std::atomic< unsigned int > > m_errorCount
Definition: AlgExecStateSvc.h:62
AlgExecStateSvc::reset
void reset(const EventContext &ctx) override
Definition: AlgExecStateSvc.cpp:204
AlgExecStateSvc::m_initFlag
std::once_flag m_initFlag
Definition: AlgExecStateSvc.h:66
Service.h
std::ostringstream
STL class.
AlgExecStateSvc::algExecStates
const AlgStateMap_t & algExecStates(const EventContext &ctx) const override
Definition: AlgExecStateSvc.cpp:171
EventContext
Definition: EventContext.h:34
EventStatus::Status
Status
Definition: IAlgExecStateSvc.h:72
std::mutex
STL class.
IAlgExecStateSvc::algExecState
virtual const AlgExecState & algExecState(const Gaudi::StringKey &algName, const EventContext &ctx) const =0
IAlgorithm.h
AlgExecState
Definition: IAlgExecStateSvc.h:36
IAlgExecStateSvc.h
std::unordered_map
STL class.