SMACC2
Loading...
Searching...
No Matches
smacc2
include
smacc2
smacc_transition.hpp
Go to the documentation of this file.
1
// Copyright 2021 RobosoftAI Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
/*****************************************************************************************************************
16
*
17
* Authors: Pablo Inigo Blasco, Brett Aldrich
18
*
19
******************************************************************************************************************/
20
21
#pragma once
22
23
#include <
smacc2/introspection/introspection.hpp
>
24
#include <
smacc2/introspection/state_traits.hpp
>
25
namespace
smacc2
26
{
28
template
<
29
class
Event,
class
Destination,
typename
Tag,
class
TransitionContext,
30
void (TransitionContext::*pTransitionAction)(
const
Event &)>
31
class
Transition
32
{
33
public
:
34
typedef
Tag
TRANSITION_TAG
;
35
36
private
:
38
template
<
class
State>
39
struct
reactions
40
{
41
static
boost::statechart::result
react_without_action
(State & stt)
42
{
43
RCLCPP_DEBUG(stt.getLogger(),
"[Smacc Transition] REACT WITHOUT ACTION"
);
44
typedef
smacc2::Transition<Event, Destination, Tag, TransitionContext, pTransitionAction>
45
Transtype;
46
TRANSITION_TAG
mock;
47
specificNamedOnExit
(stt, mock);
48
49
stt.template notifyTransition<Transtype>();
50
return
stt.template transit<Destination>();
51
}
52
53
static
boost::statechart::result
react_with_action
(State & stt,
const
Event & evt)
54
{
55
RCLCPP_DEBUG(stt.getLogger(),
"[Smacc Transition] REACT WITH ACTION AND EVENT"
);
56
typedef
smacc2::Transition<Event, Destination, Tag, TransitionContext, pTransitionAction>
57
Transtype;
58
TRANSITION_TAG
mock;
59
specificNamedOnExit
(stt, mock);
60
stt.template notifyTransition<Transtype>();
61
return
stt.template transit<Destination>(pTransitionAction, evt);
62
}
63
};
64
65
public
:
67
// The following declarations should be private.
68
// They are only public because many compilers lack template friends.
70
template
<
class
State,
class
EventBase,
class
IdType>
71
static
boost::statechart::detail::reaction_result
react
(
72
State & stt,
const
EventBase & evt,
const
IdType & eventType)
73
{
74
typedef
boost::statechart::detail::reaction_dispatcher<
75
reactions<State>
, State, EventBase, Event, TransitionContext, IdType>
76
dispatcher;
77
return
dispatcher::react(stt, evt, eventType);
78
}
79
};
80
}
// namespace smacc2
smacc2::Transition
Definition
smacc_types.hpp:106
smacc2::Transition::react
static boost::statechart::detail::reaction_result react(State &stt, const EventBase &evt, const IdType &eventType)
Definition
smacc_transition.hpp:71
smacc2::Transition::TRANSITION_TAG
Tag TRANSITION_TAG
Definition
smacc_transition.hpp:34
introspection.hpp
smacc2
Definition
callback_counter_semaphore.hpp:30
smacc2::specificNamedOnExit
void specificNamedOnExit(TState &st, TTransitionTagName tn, std::true_type)
Definition
state_traits.hpp:44
state_traits.hpp
smacc2::Transition::reactions
Definition
smacc_transition.hpp:40
smacc2::Transition::reactions::react_with_action
static boost::statechart::result react_with_action(State &stt, const Event &evt)
Definition
smacc_transition.hpp:53
smacc2::Transition::reactions::react_without_action
static boost::statechart::result react_without_action(State &stt)
Definition
smacc_transition.hpp:41
Generated by
1.12.0