scenario_simulator_v2 C++ API
storyboard_element_state.hpp
Go to the documentation of this file.
1 // Copyright 2015 TIER IV, Inc. All rights reserved.
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 #ifndef OPENSCENARIO_INTERPRETER__SYNTAX__STORYBOARD_ELEMENT_STATE_HPP_
16 #define OPENSCENARIO_INTERPRETER__SYNTAX__STORYBOARD_ELEMENT_STATE_HPP_
17 
18 #include <iostream>
20 
22 {
23 inline namespace syntax
24 {
25 /* ---- StoryboardElementState -------------------------------------------------
26  *
27  * <xsd:simpleType name="StoryboardElementState">
28  * <xsd:union>
29  * <xsd:simpleType>
30  * <xsd:restriction base="xsd:string">
31  * <xsd:enumeration value="startTransition"/>
32  * <xsd:enumeration value="endTransition"/>
33  * <xsd:enumeration value="stopTransition"/>
34  * <xsd:enumeration value="skipTransition"/>
35  * <xsd:enumeration value="completeState"/>
36  * <xsd:enumeration value="runningState"/>
37  * <xsd:enumeration value="standbyState"/>
38  * </xsd:restriction>
39  * </xsd:simpleType>
40  * <xsd:simpleType>
41  * <xsd:restriction base="parameter"/>
42  * </xsd:simpleType>
43  * </xsd:union>
44  * </xsd:simpleType>
45  *
46  * -------------------------------------------------------------------------- */
48 {
49  enum value_type {
50 
51  /* ---- NOTE ---------------------------------------------------------------
52  *
53  * This is the default initialization state of a StoryboardElement. When
54  * it is in this state, the runtime instantiation of the StoryboardElement
55  * is ready to execute once given a startTrigger. A runtime instantiation
56  * of any StoryboardElement is created once its parent element is in the
57  * standbyState. From the standbyState, the Story element instantaneously
58  * transitions into the runningState.
59  *
60  * Default constructor select this.
61  *
62  * ---------------------------------------------------------------------- */
64 
65  /* ---- NOTE ---------------------------------------------------------------
66  *
67  * The runningState symbolizes that the execution of the runtime
68  * instantiation is now ongoing and has not yet accomplished its goal.
69  *
70  * The concept of accomplishing a goal varies depending on the type of
71  * StoryboardElement under consideration:
72  *
73  * Action
74  * An Action's goal is a function of the Action type and cannot be
75  * generalized. Accomplishing an Action's goal will involve meeting some
76  * arbitrary prerequisites related with the Action type (for example, a
77  * SpeedAction accomplishes its goal when the considered Entity is
78  * travelling at the prescribed speed). If an Action is acting on an
79  * EntitySelection, all instances of Entity within the selection have to
80  * complete in order to reach the completeState of the Action.
81  *
82  * Event
83  * An Event's goal is accomplished when all its Actions are in the
84  * completeState.
85  *
86  * Maneuver
87  * A Maneuver's goal is accomplished when all its Events are in the
88  * completeState.
89  *
90  * ManeuverGroup
91  * A ManeuverGroup's goal is accomplished when all its Maneuvers are in
92  * the completeState.
93  *
94  * Act
95  * An Act's goal is accomplished when all its ManeuverGroups are in the
96  * completeState.
97  *
98  * Story
99  * A Story's goal is accomplished when all its Acts are in the
100  * completeState.
101  *
102  * ---------------------------------------------------------------------- */
104 
105  /* ---- NOTE ---------------------------------------------------------------
106  *
107  * The completeState signals that the runtime instantiation of the
108  * StoryboardElement cannot reach a running state without external
109  * interference. If the affected runtime instantiation of the
110  * StoryboardElement is defined with a maximumExecutionCount, to be
111  * complete implies that there are no more executions left to run, or a
112  * stopTransition has occurred.
113  *
114  * Checking for completeness involves verifying if the given runtime
115  * instantiation of the StoryboardElement still has executions left upon
116  * finishing the runningState. This check returns false if there are
117  * executions left. This check returns true if there are no executions
118  * left, or if the maximumExecutionCount is not defined in the
119  * StoryboardElement.
120  *
121  * Resetting the completeState can only be achieved externally by the
122  * parent StoryboardElement whose child is in the completeState. This may
123  * only occur if the parent initiates a new execution.
124  *
125  * ---------------------------------------------------------------------- */
127 
128  /* ---- NOTE ---------------------------------------------------------------
129  *
130  * The startTransition symbolizes that the execution of the runtime
131  * instantiation is now starting. The startTransition can be used in
132  * conditions to trigger based on this transition.
133  *
134  * ---------------------------------------------------------------------- */
136 
137  /* ---- NOTE ---------------------------------------------------------------
138  *
139  * The endTransition occurs when the runtime instantiation of the
140  * StoryboardElement accomplishes its goal. Once the endTransition occurs,
141  * a check for completeness is made. A positive outcome moves the state
142  * machine to the completeState, whereas a negative outcome moves the
143  * state machine to the standbyState. The endTransition can be used in
144  * conditions to trigger based on this transition.
145  *
146  * ---------------------------------------------------------------------- */
148 
149  /* ---- NOTE ---------------------------------------------------------------
150  *
151  * The stopTransition marks the reception of a stopTrigger or the
152  * storyboard element is overridden (applicable for Event and Action).
153  * This implies that the stopTransition cannot be reached other than with
154  * an external intervention to the runtime instantiation of the
155  * StoryboardElement.
156  *
157  * When a runtime instantiation of a StoryboardElement goes through a
158  * stopTransition, all of its child elements are also forced to go through
159  * the same transition. The stopTransition can be used in conditions to
160  * trigger based on this transition.
161  *
162  * ---------------------------------------------------------------------- */
164 
165  /* ---- NOTE ---------------------------------------------------------------
166  *
167  * Transition marking the moment an element is asked to move to the
168  * runningState but is instead skipped so it remains in the standbyState
169  * (only for Event instances). The skipTransition can be used in
170  * conditions to trigger based on this transition.
171  *
172  * ---------------------------------------------------------------------- */
174  } value;
175 
177 
179 
180  constexpr operator value_type() const noexcept { return value; }
181 };
182 
183 auto operator>>(std::istream &, StoryboardElementState &) -> std::istream &;
184 
185 auto operator<<(std::ostream &, const StoryboardElementState &) -> std::ostream &;
186 
187 // clang-format off
188 extern const Object start_transition;
189 extern const Object end_transition;
190 extern const Object stop_transition;
191 extern const Object skip_transition;
192 extern const Object complete_state;
193 extern const Object running_state;
194 extern const Object standby_state;
195 // clang-format on
196 } // namespace syntax
197 } // namespace openscenario_interpreter
198 
199 #endif // OPENSCENARIO_INTERPRETER__SYNTAX__STORYBOARD_ELEMENT_STATE_HPP_
auto operator>>(std::istream &, Boolean &) -> std::istream &
Definition: boolean.cpp:52
const Object standby_state
Definition: storyboard_element_state.cpp:79
const Object end_transition
Definition: storyboard_element_state.cpp:76
const Object running_state
Definition: storyboard_element_state.cpp:80
const Object complete_state
Definition: storyboard_element_state.cpp:81
const Object start_transition
Definition: storyboard_element_state.cpp:75
auto operator<<(std::ostream &, const Boolean &) -> std::ostream &
Definition: boolean.cpp:46
const Object skip_transition
Definition: storyboard_element_state.cpp:78
const Object stop_transition
Definition: storyboard_element_state.cpp:77
Definition: escape_sequence.hpp:22
Definition: storyboard_element_state.hpp:48
StoryboardElementState(value_type value)
Definition: storyboard_element_state.hpp:178
value_type
Definition: storyboard_element_state.hpp:49
@ completeState
Definition: storyboard_element_state.hpp:126
@ startTransition
Definition: storyboard_element_state.hpp:135
@ stopTransition
Definition: storyboard_element_state.hpp:163
@ runningState
Definition: storyboard_element_state.hpp:103
@ skipTransition
Definition: storyboard_element_state.hpp:173
@ standbyState
Definition: storyboard_element_state.hpp:63
@ endTransition
Definition: storyboard_element_state.hpp:147
enum openscenario_interpreter::syntax::StoryboardElementState::value_type value