The Gaudi Framework
master (57817a18)
Toggle main menu visibility
Loading...
Searching...
No Matches
FSMCallbackHolder.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2025 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
13
#include <
Gaudi/Interfaces/IFSMCallbackHolder.h
>
14
#include <
GaudiKernel/StateMachine.h
>
15
#include <
GaudiKernel/extends.h
>
16
#include <algorithm>
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
:
40
using
Parent
=
extends<BASE, IFSMCallbackHolder>
;
41
using
extends
<BASE,
IFSMCallbackHolder
>
::extends
;
42
43
void
registerCallBack
(
StateMachine::Transition
s,
IFSMCallbackHolder::CallBack
c )
override
{
44
m_callbacks
[s].push_back( std::move( c ) );
45
}
46
47
StatusCode
sysInitialize
()
override
{
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
:
61
void
handleCallBacks
(
StateMachine::Transition
state ) {
62
std::for_each(
m_callbacks
[state].begin(),
m_callbacks
[state].end(),
63
[](
IFSMCallbackHolder::CallBack
const
& c ) { c(); } );
64
}
65
66
std::map<StateMachine::Transition, std::vector<IFSMCallbackHolder::CallBack>>
m_callbacks
;
67
};
68
69
}
// namespace Gaudi
IFSMCallbackHolder.h
StateMachine.h
Gaudi::FSMCallbackHolder
Helper class to implement the IFSMCallbackHolder interface.
Definition
FSMCallbackHolder.h:37
Gaudi::FSMCallbackHolder::sysStop
StatusCode sysStop() override
Definition
FSMCallbackHolder.h:53
Gaudi::FSMCallbackHolder::Parent
extends< BASE, IFSMCallbackHolder > Parent
Definition
FSMCallbackHolder.h:40
Gaudi::FSMCallbackHolder::sysFinalize
StatusCode sysFinalize() override
Definition
FSMCallbackHolder.h:56
Gaudi::FSMCallbackHolder::sysInitialize
StatusCode sysInitialize() override
Definition
FSMCallbackHolder.h:47
Gaudi::FSMCallbackHolder::registerCallBack
void registerCallBack(StateMachine::Transition s, IFSMCallbackHolder::CallBack c) override
Definition
FSMCallbackHolder.h:43
Gaudi::FSMCallbackHolder< Gaudi::Algorithm >::m_callbacks
std::map< StateMachine::Transition, std::vector< IFSMCallbackHolder::CallBack > > m_callbacks
Definition
FSMCallbackHolder.h:66
Gaudi::FSMCallbackHolder::handleCallBacks
void handleCallBacks(StateMachine::Transition state)
Definition
FSMCallbackHolder.h:61
Gaudi::FSMCallbackHolder::sysStart
StatusCode sysStart() override
Definition
FSMCallbackHolder.h:50
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::andThen
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition
StatusCode.h:151
extends
Base class used to extend a class implementing other interfaces.
Definition
extends.h:19
extends.h
Gaudi::StateMachine::Transition
Transition
Allowed transitions between states.
Definition
StateMachine.h:32
Gaudi::StateMachine::STOP
@ STOP
Definition
StateMachine.h:36
Gaudi::StateMachine::INITIALIZE
@ INITIALIZE
Definition
StateMachine.h:34
Gaudi::StateMachine::START
@ START
Definition
StateMachine.h:35
Gaudi::StateMachine::FINALIZE
@ FINALIZE
Definition
StateMachine.h:37
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::IFSMCallbackHolder
Interface defining a CallBack registration functionality based on the State Machine of Gaudi.
Definition
IFSMCallbackHolder.h:22
Gaudi::IFSMCallbackHolder::CallBack
std::function< void()> CallBack
Definition
IFSMCallbackHolder.h:27
GaudiKernel
include
Gaudi
FSMCallbackHolder.h
Generated on
for The Gaudi Framework by
1.17.0