OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
value_with_unit.hpp
1#pragma once
2#include <ossia/network/dataspace/dataspace.hpp>
3#include <ossia/network/dataspace/dataspace_base.hpp>
4#include <ossia/network/value/value.hpp>
5
6namespace ossia
7{
8
9#include <ossia/network/dataspace/dataspace_strong_variants.hpp>
12struct OSSIA_EXPORT value_with_unit final
13{
14 strong_value_variant v;
15 value_with_unit() = default;
16 value_with_unit(const value_with_unit& other) = default;
17 value_with_unit(value_with_unit&& other) = default;
18 value_with_unit& operator=(const value_with_unit& other) = default;
19 value_with_unit& operator=(value_with_unit&& other) = default;
20 template <typename T>
21 value_with_unit(const T& arg) noexcept
22 : v(arg)
23 {
24 }
25
26 auto which() const { return v.which(); }
27 operator bool() const { return bool(v); }
28
29 template <typename T>
30 const T* target() const noexcept
31 {
32 return v.target<T>();
33 }
34
35 template <typename T>
36 T* target() noexcept
37 {
38 return v.target<T>();
39 }
40
41 friend inline bool
42 operator==(const value_with_unit& lhs, const value_with_unit& rhs) noexcept
43 {
44 return lhs.v == rhs.v;
45 }
46 friend inline bool
47 operator!=(const value_with_unit& lhs, const value_with_unit& rhs) noexcept
48 {
49 return lhs.v != rhs.v;
50 }
51};
52}
Definition git_info.h:7
Definition value_with_unit.hpp:13