2 #include <ossia/detail/hash.hpp>
3 #include <ossia/network/dataspace/angle.hpp>
4 #include <ossia/network/dataspace/color.hpp>
5 #include <ossia/network/dataspace/dataspace_fwd.hpp>
6 #include <ossia/network/dataspace/distance.hpp>
7 #include <ossia/network/dataspace/gain.hpp>
8 #include <ossia/network/dataspace/orientation.hpp>
9 #include <ossia/network/dataspace/position.hpp>
10 #include <ossia/network/dataspace/speed.hpp>
11 #include <ossia/network/dataspace/time.hpp>
16 #include <ossia/network/dataspace/dataspace_base_variants.hpp>
27 unit_t() noexcept =
default;
37 unit_t(degree_u t) noexcept
41 unit_t(radian_u t) noexcept
87 unit_t(distance_u t) noexcept
95 unit_t(kilometer_u t) noexcept
99 unit_t(decimeter_u t) noexcept
103 unit_t(centimeter_u t) noexcept
107 unit_t(millimeter_u t) noexcept
111 unit_t(micrometer_u t) noexcept
115 unit_t(nanometer_u t) noexcept
119 unit_t(picometer_u t) noexcept
140 unit_t(linear_u t) noexcept
144 unit_t(midigain_u t) noexcept
148 unit_t(decibel_u t) noexcept
152 unit_t(decibel_raw_u t) noexcept
157 unit_t(orientation_u t) noexcept
161 unit_t(quaternion_u t) noexcept
162 : v{orientation_u{t}}
165 unit_t(euler_u t) noexcept
166 : v{orientation_u{t}}
170 : v{orientation_u{t}}
174 unit_t(position_u t) noexcept
178 unit_t(cartesian_3d_u t) noexcept
182 unit_t(cartesian_2d_u t) noexcept
186 unit_t(spherical_u t) noexcept
190 unit_t(polar_u t) noexcept
202 unit_t(opengl_u t) noexcept
206 unit_t(cylindrical_u t) noexcept
215 unit_t(speed_u t) noexcept
219 unit_t(meter_per_second_u t) noexcept
223 unit_t(miles_per_hour_u t) noexcept
227 unit_t(kilometer_per_hour_u t) noexcept
235 unit_t(foot_per_hour_u t) noexcept
239 unit_t(foot_per_second_u t) noexcept
244 unit_t(timing_u t) noexcept
248 unit_t(second_u t) noexcept
264 unit_t(frequency_u t) noexcept
272 unit_t(midi_pitch_u t) noexcept
276 unit_t(millisecond_u t) noexcept
280 unit_t(playback_speed_u t) noexcept
285 template <
typename T>
286 unit_t(T unit,
typename T::is_unit* =
nullptr) noexcept
291 auto which()
const noexcept {
return v.which(); }
293 explicit operator bool()
const noexcept {
return bool(v); }
297 return unit.v == other.v;
302 return unit.v != other.v;
306 template <
typename T>
309 template <
typename U>
310 static char test(
typename U::is_unit* x);
312 template <
typename U>
313 static long test(U* x);
315 static const bool value =
sizeof(test<T>(0)) == 1;
318 template <
typename T,
typename U>
319 typename std::enable_if_t<is_unit<T>::value && is_unit<U>::value,
bool> operator==(T, U)
323 template <
typename T,
typename U>
324 typename std::enable_if_t<is_unit<T>::value && is_unit<U>::value,
bool> operator!=(T, U)
329 template <
typename T>
330 typename std::enable_if_t<is_unit<T>::value,
bool> operator==(T, T)
334 template <
typename T>
335 typename std::enable_if_t<is_unit<T>::value,
bool> operator!=(T, T)
340 template <
typename T,
typename =
void>
341 struct is_array_unit :
public std::false_type
345 template <
typename T>
346 struct is_array_unit<T, decltype(T{}.array_parameters())> :
public std::true_type
350 static const constexpr
int dataspace_count = 8;
351 static const constexpr
int unit_count = 2 + 9 + 11 + 4 + 3 + 9 + 6 + 9;
356 struct hash<
ossia::distance_u>
358 std::size_t operator()(
const ossia::distance_u& k)
const {
return k.which(); }
361 struct hash<
ossia::position_u>
363 std::size_t operator()(
const ossia::position_u& k)
const {
return k.which(); }
366 struct hash<
ossia::speed_u>
368 std::size_t operator()(
const ossia::speed_u& k)
const {
return k.which(); }
371 struct hash<
ossia::orientation_u>
373 std::size_t operator()(
const ossia::orientation_u& k)
const {
return k.which(); }
376 struct hash<
ossia::angle_u>
378 std::size_t operator()(
const ossia::angle_u& k)
const {
return k.which(); }
381 struct hash<
ossia::color_u>
383 std::size_t operator()(
const ossia::color_u& k)
const {
return k.which(); }
386 struct hash<
ossia::gain_u>
388 std::size_t operator()(
const ossia::gain_u& k)
const {
return k.which(); }
391 struct hash<
ossia::timing_u>
393 std::size_t operator()(
const ossia::timing_u& k)
const {
return k.which(); }
397 struct hash<
ossia::unit_t>
401 std::size_t seed = 0;
402 if(v.v.which() != v.v.npos)
404 ossia::hash_combine(seed, v.v.which());
405 ossia::apply_nonnull([&](
auto& d) { ossia::hash_combine(seed, d.which()); }, v.v);
The value class.
Definition: value.hpp:173
Definition: dataspace.hpp:24