scenario_simulator_v2 C++ API
vehicle_category.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__VEHICLE_CATEGORY_HPP_
16 #define OPENSCENARIO_INTERPRETER__SYNTAX__VEHICLE_CATEGORY_HPP_
17 
18 #include <iostream>
19 #include <traffic_simulator_msgs/msg/entity_subtype.hpp>
20 
22 {
23 inline namespace syntax
24 {
25 /* ---- VehicleCategory --------------------------------------------------------
26  *
27  * <xsd:simpleType name="VehicleCategory">
28  * <xsd:union>
29  * <xsd:simpleType>
30  * <xsd:restriction base="xsd:string">
31  * <xsd:enumeration value="bicycle"/>
32  * <xsd:enumeration value="bus"/>
33  * <xsd:enumeration value="car"/>
34  * <xsd:enumeration value="motorbike"/>
35  * <xsd:enumeration value="semitrailer"/>
36  * <xsd:enumeration value="trailer"/>
37  * <xsd:enumeration value="train"/>
38  * <xsd:enumeration value="tram"/>
39  * <xsd:enumeration value="truck"/>
40  * <xsd:enumeration value="van"/>
41  * </xsd:restriction>
42  * </xsd:simpleType>
43  * <xsd:simpleType>
44  * <xsd:restriction base="parameter"/>
45  * </xsd:simpleType>
46  * </xsd:union>
47  * </xsd:simpleType>
48  *
49  * -------------------------------------------------------------------------- */
51 {
52  enum value_type {
53  car, // NOTE: This is the default value and should not be included in the sort.
54 
55  // NOTE: Sorted by lexicographic order.
57  bus,
64  van,
65  } value;
66 
67  explicit constexpr VehicleCategory(value_type value = car) : value(value) {}
68 
69  constexpr operator value_type() const noexcept { return value; }
70 
72  {
74  {
75  switch (value) { // NOTE: Sorted by lexicographic order.
76  case bicycle:
77  result.value = traffic_simulator_msgs::msg::EntitySubtype::BICYCLE;
78  break;
79  case bus:
80  result.value = traffic_simulator_msgs::msg::EntitySubtype::BUS;
81  break;
82  case car:
83  result.value = traffic_simulator_msgs::msg::EntitySubtype::CAR;
84  break;
85  case motorbike:
86  result.value = traffic_simulator_msgs::msg::EntitySubtype::MOTORCYCLE;
87  break;
88  case trailer:
89  result.value = traffic_simulator_msgs::msg::EntitySubtype::TRAILER;
90  break;
91  case truck:
92  result.value = traffic_simulator_msgs::msg::EntitySubtype::TRUCK;
93  break;
94  default: // semitrailer, train, tram, van
95  result.value = traffic_simulator_msgs::msg::EntitySubtype::UNKNOWN;
96  break;
97  }
98  }
99 
100  return result;
101  }
102 };
103 
104 auto operator>>(std::istream &, VehicleCategory &) -> std::istream &;
105 
106 auto operator<<(std::ostream &, const VehicleCategory &) -> std::ostream &;
107 } // namespace syntax
108 } // namespace openscenario_interpreter
109 
110 #endif // OPENSCENARIO_INTERPRETER__SYNTAX__VEHICLE_CATEGORY_HPP_
auto operator>>(std::istream &, Boolean &) -> std::istream &
Definition: boolean.cpp:52
auto operator<<(std::ostream &, const Boolean &) -> std::ostream &
Definition: boolean.cpp:46
Definition: escape_sequence.hpp:22
traffic_simulator_msgs::EntitySubtype EntitySubtype
Definition: helper_functions.hpp:30
Definition: vehicle_category.hpp:51
constexpr VehicleCategory(value_type value=car)
Definition: vehicle_category.hpp:67
value_type
Definition: vehicle_category.hpp:52
@ trailer
Definition: vehicle_category.hpp:60
@ bus
Definition: vehicle_category.hpp:57
@ train
Definition: vehicle_category.hpp:61
@ van
Definition: vehicle_category.hpp:64
@ semitrailer
Definition: vehicle_category.hpp:59
@ motorbike
Definition: vehicle_category.hpp:58
@ car
Definition: vehicle_category.hpp:53
@ bicycle
Definition: vehicle_category.hpp:56
@ truck
Definition: vehicle_category.hpp:63
@ tram
Definition: vehicle_category.hpp:62
enum openscenario_interpreter::syntax::VehicleCategory::value_type value