scenario_simulator_v2 C++ API
triggering_entities_rule.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__TRIGGERING_ENTITIES_RULE_HPP_
16 #define OPENSCENARIO_INTERPRETER__SYNTAX__TRIGGERING_ENTITIES_RULE_HPP_
17 
18 #include <algorithm>
19 #include <iostream>
20 #include <utility>
21 
23 {
24 inline namespace syntax
25 {
26 /* ---- TriggeringEntitiesRule -------------------------------------------------
27  *
28  * <xsd:simpleType name="TriggeringEntitiesRule">
29  * <xsd:union>
30  * <xsd:simpleType>
31  * <xsd:restriction base="xsd:string">
32  * <xsd:enumeration value="any"/>
33  * <xsd:enumeration value="all"/>
34  * </xsd:restriction>
35  * </xsd:simpleType>
36  * <xsd:simpleType>
37  * <xsd:restriction base="parameter"/>
38  * </xsd:simpleType>
39  * </xsd:union>
40  * </xsd:simpleType>
41  *
42  * -------------------------------------------------------------------------- */
44 {
45  enum value_type {
46  all,
47  any,
49  } value;
50 
52 
53  constexpr operator value_type() const noexcept { return value; }
54 
55  template <typename... Ts>
56  constexpr auto apply(Ts &&... xs) const -> decltype(auto)
57  {
58  switch (value) {
59  case all:
60  return std::all_of(std::forward<decltype(xs)>(xs)...);
61 
62  case any:
63  return std::any_of(std::forward<decltype(xs)>(xs)...);
64 
65  case none:
66  return std::none_of(std::forward<decltype(xs)>(xs)...);
67 
68  default:
69  return false;
70  }
71  }
72 
73  auto description() const -> std::string;
74 };
75 
76 auto operator>>(std::istream &, TriggeringEntitiesRule &) -> std::istream &;
77 
78 auto operator<<(std::ostream &, const TriggeringEntitiesRule &) -> std::ostream &;
79 } // namespace syntax
80 } // namespace openscenario_interpreter
81 
82 #endif // OPENSCENARIO_INTERPRETER__SYNTAX__TRIGGERING_ENTITIES_RULE_HPP_
Definition: escape_sequence.hpp:22
Definition: cache.hpp:27
Definition: junit5.hpp:25
Definition: triggering_entities_rule.hpp:44
constexpr auto apply(Ts &&... xs) const -> decltype(auto)
Definition: triggering_entities_rule.hpp:56
auto description() const -> std::string
Definition: triggering_entities_rule.cpp:26
enum openscenario_interpreter::syntax::TriggeringEntitiesRule::value_type value
value_type
Definition: triggering_entities_rule.hpp:45
@ none
Definition: triggering_entities_rule.hpp:48
@ any
Definition: triggering_entities_rule.hpp:47
@ all
Definition: triggering_entities_rule.hpp:46