The Gaudi Framework  master (37c0b60a)
FSMCallbackHolder.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 #pragma once
12 
15 #include <GaudiKernel/extends.h>
16 
17 #include <map>
18 #include <vector>
19 
20 namespace Gaudi {
21 
36  template <class BASE>
37  class FSMCallbackHolder : public extends<BASE, IFSMCallbackHolder> {
38 
39  public:
42 
44  m_callbacks[s].push_back( std::move( c ) );
45  }
46 
48  return Parent::sysInitialize().andThen( [&]() { handleCallBacks( StateMachine::INITIALIZE ); } );
49  }
50  StatusCode sysStart() override {
51  return Parent::sysStart().andThen( [&]() { handleCallBacks( StateMachine::START ); } );
52  }
53  StatusCode sysStop() override {
54  return Parent::sysStop().andThen( [&]() { handleCallBacks( StateMachine::STOP ); } );
55  }
56  StatusCode sysFinalize() override {
57  return Parent::sysFinalize().andThen( [&]() { handleCallBacks( StateMachine::FINALIZE ); } );
58  }
59 
60  private:
63  []( IFSMCallbackHolder::CallBack const& c ) { c(); } );
64  }
65 
67  };
68 
69 } // namespace Gaudi
std::for_each
T for_each(T... args)
StatusCode::andThen
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition: StatusCode.h:163
std::move
T move(T... args)
gaudirun.s
string s
Definition: gaudirun.py:346
Gaudi::StateMachine::FINALIZE
@ FINALIZE
Definition: StateMachine.h:38
gaudirun.c
c
Definition: gaudirun.py:525
extends.h
std::function
Gaudi::FSMCallbackHolder::sysInitialize
StatusCode sysInitialize() override
Definition: FSMCallbackHolder.h:47
Gaudi::StateMachine::INITIALIZE
@ INITIALIZE
Definition: StateMachine.h:35
IFSMCallbackHolder.h
StateMachine.h
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:136
StatusCode
Definition: StatusCode.h:65
Gaudi::FSMCallbackHolder
Helper class to implement the IFSMCallbackHolder interface.
Definition: FSMCallbackHolder.h:37
std::map
STL class.
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
Gaudi::FSMCallbackHolder::sysFinalize
StatusCode sysFinalize() override
Definition: FSMCallbackHolder.h:56
Gaudi::FSMCallbackHolder::sysStop
StatusCode sysStop() override
Definition: FSMCallbackHolder.h:53
Gaudi::StateMachine::Transition
Transition
Allowed transitions between states.
Definition: StateMachine.h:33
Gaudi::StateMachine::START
@ START
Definition: StateMachine.h:36
Gaudi::FSMCallbackHolder::m_callbacks
std::map< StateMachine::Transition, std::vector< IFSMCallbackHolder::CallBack > > m_callbacks
Definition: FSMCallbackHolder.h:66
IOTest.end
end
Definition: IOTest.py:125
compareRootHistos.state
state
Definition: compareRootHistos.py:496
Gaudi::FSMCallbackHolder::handleCallBacks
void handleCallBacks(StateMachine::Transition state)
Definition: FSMCallbackHolder.h:61
Gaudi::FSMCallbackHolder::registerCallBack
void registerCallBack(StateMachine::Transition s, IFSMCallbackHolder::CallBack c) override
Definition: FSMCallbackHolder.h:43
Gaudi::StateMachine::STOP
@ STOP
Definition: StateMachine.h:37
Gaudi::FSMCallbackHolder::sysStart
StatusCode sysStart() override
Definition: FSMCallbackHolder.h:50