scenario_simulator_v2 C++ API
trigger.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__TRIGGER_HPP_
16 #define OPENSCENARIO_INTERPRETER__SYNTAX__TRIGGER_HPP_
17 
18 #include <boost/json.hpp>
21 #include <pugixml.hpp>
22 
24 {
25 inline namespace syntax
26 {
27 /* ---- Trigger ----------------------------------------------------------------
28  *
29  * <xsd:complexType name="Trigger">
30  * <xsd:sequence>
31  * <xsd:element name="ConditionGroup" type="ConditionGroup" minOccurs="0" maxOccurs="unbounded"/>
32  * </xsd:sequence>
33  * </xsd:complexType>
34  *
35  * -------------------------------------------------------------------------- */
36 struct Trigger : public std::list<ConditionGroup>
37 {
39 
40  // NOTE: Default constructed Trigger must be return FALSE.
41  Trigger() = default;
42 
43  explicit Trigger(const pugi::xml_node &, Scope &);
44 
45  explicit Trigger(const std::list<ConditionGroup> & condition_groups)
46  : std::list<ConditionGroup>(condition_groups)
47  {
48  }
49 
50  auto activeConditionGroupIndex() const -> iterator::difference_type;
51 
52  auto activeConditionGroupDescription() const -> std::vector<std::pair<std::string, std::string>>;
53 
54  auto evaluate() -> Object;
55 
56  // Utility function for some default triggers that are always evaluated to be true
57  static auto truthy() noexcept -> Trigger;
58 };
59 
60 auto operator<<(boost::json::object &, const Trigger &) -> boost::json::object &;
61 
62 static_assert(std::is_default_constructible<Trigger>::value);
63 
64 static_assert(std::is_nothrow_default_constructible<Trigger>::value);
65 } // namespace syntax
66 } // namespace openscenario_interpreter
67 
68 #endif // OPENSCENARIO_INTERPRETER__SYNTAX__TRIGGER_HPP_
Definition: scope.hpp:154
Definition: hypot.hpp:22
Definition: cache.hpp:27
Definition: condition_group.hpp:41
auto activeConditionGroupDescription() const -> std::vector< std::pair< std::string, std::string >>
Definition: trigger.cpp:58
Trigger(const std::list< ConditionGroup > &condition_groups)
Definition: trigger.hpp:45
bool current_value
Definition: trigger.hpp:38
static auto truthy() noexcept -> Trigger
Definition: trigger.cpp:27
auto evaluate() -> Object
Definition: trigger.cpp:29
auto activeConditionGroupIndex() const -> iterator::difference_type
Definition: trigger.cpp:49