15 #ifndef OPENSCENARIO_INTERPRETER__SYNTAX__STORYBOARD_ELEMENT_HPP_
16 #define OPENSCENARIO_INTERPRETER__SYNTAX__STORYBOARD_ELEMENT_HPP_
27 #include <type_traits>
28 #include <unordered_map>
29 #include <unordered_set>
34 inline namespace syntax
83 template <StoryboardElementState::value_type State>
100 virtual auto accomplished() const ->
bool
102 return std::all_of(std::begin(
elements), std::end(
elements), [](
auto && element) {
104 return element.template as<StoryboardElement>()
109 virtual auto run() ->
void
117 virtual auto start() ->
void {}
119 virtual auto stop() ->
void
131 static std::size_t
id = 0;
132 return name.empty() ?
std::string(
"anonymous-") + std::to_string(++
id) : name;
135 std::unordered_set<std::string>
names;
139 [[maybe_unused]]
auto [iter, success] =
names.emplace(name);
143 template <
typename U,
typename Node,
typename... Ts>
146 if (
const auto name =
rename(readAttribute<String>(
"name", node, inner_scope));
unique(name)) {
147 auto element = make<U>(node, inner_scope, std::forward<decltype(
xs)>(
xs)...);
148 inner_scope.
insert(name, element);
152 "Detected redefinition of StoryboardElement named ", std::quoted(name),
" (class ",
157 template <
typename U,
typename Node,
typename... Ts>
161 not
unique(element.template as<U>().name)) {
163 "Detected redefinition of StoryboardElement named ",
164 std::quoted(element.template as<U>().name),
" (class ",
makeTypename(
typeid(U)),
")");
166 inner_scope.
insert(element.template as<U>().name, element);
176 callbacks[transition].push_back(callback);
183 callback(std::as_const(*
this));
267 if (run(), accomplished()) {
319 throw Error(
"UNIMPLEMENTED!");
336 if (not accomplished()) {
auto as() const -> U &
Definition: pointer.hpp:109
Definition: scope.hpp:154
auto insert(const Name &, const Object &) -> void
Definition: scope.cpp:129
Definition: simulator_core.hpp:521
Definition: storyboard_element.hpp:37
Object current_state
Definition: storyboard_element.hpp:45
Elements elements
Definition: storyboard_element.hpp:47
auto readStoryboardElement(const Node &node, Scope &inner_scope, Ts &&... xs)
Definition: storyboard_element.hpp:144
auto readCatalogedStoryboardElement(const Node &node, Scope &inner_scope, Ts &&... xs)
Definition: storyboard_element.hpp:158
auto state() const -> const auto &
Definition: storyboard_element.hpp:81
Trigger stop_trigger
Definition: storyboard_element.hpp:39
Trigger start_trigger
Definition: storyboard_element.hpp:49
StoryboardElement(const Trigger &start_trigger, const Trigger &stop_trigger)
Definition: storyboard_element.hpp:64
auto unique(const std::string &name)
Definition: storyboard_element.hpp:137
StoryboardElement(const std::size_t maximum_execution_count=1)
Definition: storyboard_element.hpp:76
StoryboardElement(const std::size_t maximum_execution_count, const Trigger &start_trigger)
Definition: storyboard_element.hpp:70
auto rename(const std::string &name) const
Definition: storyboard_element.hpp:129
auto transitionTo(const Object &state) -> bool
Definition: storyboard_element.hpp:179
virtual auto evaluate() -> Object
Definition: storyboard_element.hpp:188
void addTransitionCallback(StoryboardElementState::value_type transition, std::function< void(const StoryboardElement &)> callback)
Definition: storyboard_element.hpp:172
auto is() const
Definition: storyboard_element.hpp:84
const std::size_t maximum_execution_count
Definition: storyboard_element.hpp:41
StoryboardElement(const Trigger &stop_trigger)
Definition: storyboard_element.hpp:58
std::size_t current_execution_count
Definition: storyboard_element.hpp:43
std::unordered_set< std::string > names
Definition: storyboard_element.hpp:135
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
const Object stop_transition
Definition: storyboard_element_state.cpp:77
auto makeTypename(Ts &&... xs)
Definition: demangle.hpp:30
Definition: escape_sequence.hpp:22
std::list< Object > Elements
Definition: object.hpp:56
constexpr auto make(Ts &&... xs) -> decltype(auto)
Definition: object.hpp:59
Definition: junit5.hpp:25
std::string string
Definition: junit5.hpp:26
Definition: object.hpp:42
Definition: object.hpp:30
Definition: boolean.hpp:26
Definition: catalog_reference.hpp:45
Definition: condition_group.hpp:41
Definition: storyboard_element_state.hpp:48
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
Definition: trigger.hpp:37
auto evaluate() -> Object
Definition: trigger.cpp:27