scenario_simulator_v2 C++ API
directional_dimension.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__DIRECTIONAL_DIMENSION_HPP_
16 #define OPENSCENARIO_INTERPRETER__SYNTAX__DIRECTIONAL_DIMENSION_HPP_
17 
19 {
20 inline namespace syntax
21 {
22 /*
23  DirectionalDimension (OpenSCENARIO XML 1.3)
24 
25  Defines the directions in the entity coordinate system.
26 
27  <xsd:simpleType name="DirectionalDimension">
28  <xsd:union>
29  <xsd:simpleType>
30  <xsd:restriction base="xsd:string">
31  <xsd:enumeration value="longitudinal"/>
32  <xsd:enumeration value="lateral"/>
33  <xsd:enumeration value="vertical"/>
34  </xsd:restriction>
35  </xsd:simpleType>
36  <xsd:simpleType>
37  <xsd:restriction base="parameter"/>
38  </xsd:simpleType>
39  </xsd:union>
40  </xsd:simpleType>
41 */
43 {
44  enum value_type {
45  /*
46  Longitudinal direction (along the x-axis).
47  */
48  longitudinal, // NOTE: DEFAULT VALUE
49 
50  /*
51  Lateral direction (along the y-axis).
52  */
54 
55  /*
56  Vertical direction (along the z-axis).
57  */
59  };
60 
62 
63  DirectionalDimension() = default;
64 
66 
67  constexpr operator value_type() const noexcept { return value; }
68 
69  friend auto operator>>(std::istream & istream, DirectionalDimension & datum) -> std::istream &
70  {
71  if (auto token = std::string(); istream >> token) {
72  if (token == "longitudinal") {
74  return istream;
75  } else if (token == "lateral") {
76  datum.value = DirectionalDimension::lateral;
77  return istream;
78  } else if (token == "vertical") {
79  datum.value = DirectionalDimension::vertical;
80  return istream;
81  } else {
83  }
84  } else {
85  datum.value = DirectionalDimension::value_type();
86  return istream;
87  }
88  }
89 
90  friend auto operator<<(std::ostream & ostream, const DirectionalDimension & datum)
91  -> std::ostream &
92  {
93  switch (datum) {
95  return ostream << "longitudinal";
97  return ostream << "lateral";
99  return ostream << "vertical";
100  default:
102  }
103  }
104 };
105 } // namespace syntax
106 } // namespace openscenario_interpreter
107 
108 #endif // OPENSCENARIO_INTERPRETER__SYNTAX__DIRECTIONAL_DIMENSION_HPP_
#define UNEXPECTED_ENUMERATION_VALUE_SPECIFIED(TYPE, VALUE)
Definition: error.hpp:47
#define UNEXPECTED_ENUMERATION_VALUE_ASSIGNED(TYPE, VALUE)
Definition: error.hpp:50
Definition: hypot.hpp:22
std::string string
Definition: junit5.hpp:26
Definition: directional_dimension.hpp:43
value_type
Definition: directional_dimension.hpp:44
@ vertical
Definition: directional_dimension.hpp:58
@ longitudinal
Definition: directional_dimension.hpp:48
@ lateral
Definition: directional_dimension.hpp:53
value_type value
Definition: directional_dimension.hpp:61
friend auto operator>>(std::istream &istream, DirectionalDimension &datum) -> std::istream &
Definition: directional_dimension.hpp:69
constexpr DirectionalDimension(value_type value)
Definition: directional_dimension.hpp:65
friend auto operator<<(std::ostream &ostream, const DirectionalDimension &datum) -> std::ostream &
Definition: directional_dimension.hpp:90