scenario_simulator_v2 C++ API
action.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__ACTION_HPP_
16 #define OPENSCENARIO_INTERPRETER__SYNTAX__ACTION_HPP_
17 
18 #include <nlohmann/json.hpp>
23 #include <pugixml.hpp>
24 
26 {
27 inline namespace syntax
28 {
29 /* ---- Action -----------------------------------------------------------------
30  *
31  * <xsd:complexType name="Action">
32  * <xsd:choice>
33  * <xsd:element name="GlobalAction" type="GlobalAction"/>
34  * <xsd:element name="UserDefinedAction" type="UserDefinedAction"/>
35  * <xsd:element name="PrivateAction" type="PrivateAction"/>
36  * </xsd:choice>
37  * <xsd:attribute name="name" type="String" use="required"/>
38  * </xsd:complexType>
39  *
40  * -------------------------------------------------------------------------- */
41 struct Action : public Scope, public ComplexType, public StoryboardElement
42 {
43  bool overridden = false;
44 
45  explicit Action(const pugi::xml_node &, Scope &);
46 
48 
49  auto accomplished() const -> bool override;
50 
51  auto endsImmediately() const -> bool;
52 
53  auto run() -> void override;
54 
55  auto start() -> void override;
56 
57  auto stop() -> void override;
58 
59  friend auto operator<<(nlohmann::json &, const Action &) -> nlohmann::json &;
60 };
61 
63  Action, //
64  CASE(GlobalAction), //
66  CASE(PrivateAction), //
67 );
68 
70  const Action, //
71  CASE(GlobalAction), //
73  CASE(PrivateAction), //
74 );
75 } // namespace syntax
76 } // namespace openscenario_interpreter
77 
78 #endif // OPENSCENARIO_INTERPRETER__SYNTAX__ACTION_HPP_
Definition: scope.hpp:154
Definition: storyboard_element.hpp:37
auto override()
Definition: storyboard_element.hpp:89
virtual auto evaluate() -> Object
Definition: storyboard_element.hpp:188
#define CASE(IDENTIFIER)
DEFINE_LAZY_VISITOR(Action, CASE(GlobalAction), CASE(UserDefinedAction), CASE(PrivateAction),)
Definition: escape_sequence.hpp:22
Definition: action.hpp:42
auto accomplished() const -> bool override
Definition: action.cpp:35
auto start() -> void override
Definition: action.cpp:47
auto stop() -> void override
Definition: action.cpp:52
Action(const pugi::xml_node &, Scope &)
Definition: action.cpp:23
bool overridden
Definition: action.hpp:43
auto run() -> void override
Definition: action.cpp:42
auto endsImmediately() const -> bool
Definition: action.cpp:37
Definition: global_action.hpp:42
Definition: private_action.hpp:47
Definition: user_defined_action.hpp:36