SMACC2
Loading...
Searching...
No Matches
smacc_types.hpp
Go to the documentation of this file.
1// Copyright 2025 Robosoft 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 <boost/intrusive_ptr.hpp>
24#include <boost/statechart/transition.hpp>
25
26#include <utility>
27
28namespace smacc2
29{
30// Creates an event owned from its first line; pass the result to postEvent().
31template <typename EventType, typename... Args>
32boost::intrusive_ptr<EventType> makeEvent(Args &&... args)
33{
34 // The one hand-written new for events: they count their own references (MISRA C++:2023 21.6.2 deviation).
35 return boost::intrusive_ptr<EventType>(new EventType(std::forward<Args>(args)...));
36}
37
38class ISmaccState;
39class ISmaccStateMachine;
40class ISmaccClient;
41class ISmaccUpdatable;
42class ISmaccComponent;
43class ISmaccClientBehavior;
44class SmaccClientBehavior;
45class SmaccAsyncClientBehavior;
46class SignalDetector;
47
48class StateReactor;
49class SmaccEventGenerator;
50
51namespace client_bases
52{
53class ISmaccActionClient;
54class ISmaccSubscriber;
55} // namespace client_bases
56
57namespace introspection
58{
59class SmaccStateMachineInfo;
60class SmaccStateInfo;
61class StateReactorHandler;
62struct SmaccStateReactorInfo;
63struct SmaccEventGeneratorInfo;
64class TypeInfo;
65} // namespace introspection
66
67// ----TAGS FOR TRANSITIONS -----
68
69namespace default_transition_tags
70{
71// you can also use these other labels in order to have
72// a better code readability and also to improve the visual representation
73// in the viewer
74struct DEFAULT
75{
76};
77
78struct ABORT
79{
80};
81
82struct SUCCESS
83{
84};
85
86struct CANCEL
87{
88};
89
90// Kept on purpose: placeholders for the preempted and rejected outcomes (ROS 1 actions had them; ROS 2 result codes do not).
91/*
92struct PREEMPT
93{
94};
95
96
97struct REJECT
98{
99};*/
100
102{
103};
105{
106};
107
111} // namespace default_transition_tags
112
113template <
114 class Event, class Destination, typename Tag = default_transition_tags::default_transition_name,
115 class TransitionContext = boost::statechart::detail::no_context<Event>,
116 void (TransitionContext::*pTransitionAction)(const Event &) =
117 &boost::statechart::detail::no_context<Event>::no_function>
119
120} // namespace smacc2
boost::intrusive_ptr< EventType > makeEvent(Args &&... args)