OSSIA
Open Scenario System for Interactive Application
matching_type.hpp
1 #pragma once
2 #include <ossia/network/value/value.hpp>
3 
4 #include <QChar>
5 #include <QString>
6 
7 namespace ossia
8 {
9 template <typename>
10 struct qt_property_converter;
11 
12 template <>
13 struct qt_property_converter<float>
14 {
15  static constexpr const auto val = ossia::val_type::FLOAT;
16  using type = float;
17  static auto convert(float f) { return f; }
18 };
19 template <>
20 struct qt_property_converter<double>
21 {
22  static constexpr const auto val = ossia::val_type::FLOAT;
23  using type = float;
24  static auto convert(double f) { return f; }
25 };
26 template <>
27 struct qt_property_converter<int>
28 {
29  static constexpr const auto val = ossia::val_type::INT;
30  using type = int32_t;
31  static auto convert(int f) { return f; }
32 };
33 template <>
34 struct qt_property_converter<bool>
35 {
36  static constexpr const auto val = ossia::val_type::BOOL;
37  using type = bool;
38  static auto convert(bool f) { return f; }
39 };
40 template <>
41 struct qt_property_converter<ossia::impulse>
42 {
43  static constexpr const auto val = ossia::val_type::IMPULSE;
44  using type = ossia::impulse;
45  static auto convert(ossia::impulse) { return ossia::impulse{}; }
46 };
47 template <>
48 struct qt_property_converter<std::string>
49 {
50  static constexpr const auto val = ossia::val_type::STRING;
51  using type = std::string;
52  static auto convert(const std::string& f) { return f; }
53  static auto convert(std::string&& f) { return std::move(f); }
54 };
55 
56 template <>
57 struct qt_property_converter<QString>
58 {
59  static constexpr const auto val = ossia::val_type::STRING;
60  using type = std::string;
61  static auto convert(const QString& f) { return f.toStdString(); }
62 };
63 
64 template <>
65 struct qt_property_converter<char>
66 {
67  static constexpr const auto val = ossia::val_type::INT;
68  using type = int;
69  static int convert(char f) { return f; }
70 };
71 
72 template <>
73 struct qt_property_converter<QChar>
74 {
75  static constexpr const auto val = ossia::val_type::INT;
76  using type = int;
77  static auto convert(QChar f) { return f.toLatin1(); }
78 };
79 
80 template <>
81 struct qt_property_converter<ossia::vec2f>
82 {
83  static constexpr const auto val = ossia::val_type::VEC2F;
84  using type = ossia::vec2f;
85  static auto convert(const ossia::vec2f& t) { return t; }
86 };
87 
88 template <>
89 struct qt_property_converter<ossia::vec3f>
90 {
91  static constexpr const auto val = ossia::val_type::VEC3F;
92  using type = ossia::vec3f;
93  static auto convert(const ossia::vec3f& t) { return t; }
94 };
95 
96 template <>
97 struct qt_property_converter<ossia::vec4f>
98 {
99  static constexpr const auto val = ossia::val_type::VEC4F;
100  using type = ossia::vec4f;
101  static auto convert(const ossia::vec4f& t) { return t; }
102 };
103 
104 template <>
105 struct qt_property_converter<std::vector<ossia::value>>
106 {
107  static constexpr const auto val = ossia::val_type::LIST;
108  using type = std::vector<ossia::value>;
109  static auto convert(const std::vector<ossia::value>& t) { return t; }
110  static auto convert(std::vector<ossia::value>&& t) { return std::move(t); }
111 };
112 
113 template <>
114 struct qt_property_converter<value_map_type>
115 {
116  static constexpr const auto val = ossia::val_type::MAP;
117  using type = value_map_type;
118  static auto convert(const value_map_type& t) { return t; }
119  static auto convert(value_map_type&& t) { return std::move(t); }
120 };
121 }
Definition: git_info.h:7
@ IMPULSE
array<float, 4>
@ VEC3F
array<float, 2>
@ LIST
std::string
@ VEC4F
array<float, 3>
@ MAP
std::vector<value>
@ BOOL
ossia::impulse