OSSIA
Open Scenario System for Interactive Application
attributes.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <ossia/detail/string_view.hpp>
3 #include <ossia/network/base/node.hpp>
5 #include <ossia/network/base/parameter.hpp>
6 #include <ossia/network/common/parameter_properties.hpp>
7 #include <ossia/network/oscquery/detail/typetag.hpp>
8 
9 #include <boost/mp11/list.hpp>
10 
17 namespace ossia::oscquery
18 {
19 namespace detail
20 {
21 
22 // Attributes
23 constexpr auto name()
24 {
25  return "NAME";
26 }
27 constexpr auto osc_ip()
28 {
29  return "OSC_IP";
30 }
31 constexpr auto osc_port()
32 {
33  return "OSC_PORT";
34 }
35 constexpr auto ws_ip()
36 {
37  return "WS_IP";
38 }
39 constexpr auto ws_port()
40 {
41  return "WS_PORT";
42 }
43 constexpr auto transport()
44 {
45  return "TRANSPORT";
46 }
47 constexpr auto attribute_full_path()
48 {
49  return "FULL_PATH";
50 }
51 
52 constexpr auto attribute_typetag()
53 {
54  return "TYPE";
55 }
56 constexpr auto contents()
57 {
58  return "CONTENTS";
59 }
60 
61 constexpr auto attribute_value()
62 {
63  return "VALUE";
64 }
65 constexpr auto attribute_range()
66 {
67  return "RANGE";
68 }
69 constexpr auto attribute_clipmode()
70 {
71  return "CLIPMODE";
72 }
73 constexpr auto attribute_accessmode()
74 {
75  return "ACCESS";
76 }
77 constexpr auto attribute_description()
78 {
79  return "DESCRIPTION";
80 }
81 constexpr auto attribute_tags()
82 {
83  return "TAGS";
84 }
85 
86 // Not part of the OSCQuery spec :
87 constexpr auto attribute_unit()
88 {
89  return "UNIT";
90 }
91 constexpr auto attribute_refresh_rate()
92 {
93  return "REFRESH_RATE";
94 }
95 constexpr auto attribute_priority()
96 {
97  return "PRIORITY";
98 }
99 constexpr auto attribute_step_size()
100 {
101  return "STEP_SIZE";
102 }
103 constexpr auto attribute_instance_bounds()
104 {
105  return "INSTANCE_BOUNDS";
106 }
107 constexpr auto attribute_critical()
108 {
109  return "CRITICAL";
110 }
111 constexpr auto attribute_hidden()
112 {
113  return "HIDDEN";
114 }
115 constexpr auto attribute_disabled()
116 {
117  return "DISABLED";
118 }
119 constexpr auto attribute_extended_type()
120 {
121  return "EXTENDED_TYPE";
122 }
123 constexpr auto attribute_repetition_filter()
124 {
125  return "REPETITION_FILTER";
126 }
127 constexpr auto attribute_default_value()
128 {
129  return "DEFAULT_VALUE";
130 }
131 constexpr auto attribute_app_name()
132 {
133  return "APP_NAME";
134 }
135 constexpr auto attribute_app_version()
136 {
137  return "APP_VERSION";
138 }
139 constexpr auto attribute_app_creator()
140 {
141  return "APP_CREATOR";
142 }
143 
144 // Commands
145 constexpr auto command()
146 {
147  return "COMMAND";
148 }
149 constexpr auto data()
150 {
151  return "DATA";
152 }
153 
154 constexpr auto path_added()
155 {
156  return "PATH_ADDED";
157 }
158 constexpr auto path_removed()
159 {
160  return "PATH_REMOVED";
161 }
162 constexpr auto path_renamed()
163 {
164  return "PATH_RENAMED";
165 }
166 constexpr auto path_changed()
167 {
168  return "PATH_CHANGED";
169 }
170 constexpr auto attributes_changed()
171 {
172  return "ATTRIBUTES_CHANGED";
173 }
174 
175 // Queries
176 constexpr auto add_node()
177 {
178  constexpr_return(ossia::make_string_view("ADD_NODE"));
179 }
180 constexpr auto remove_node()
181 {
182  constexpr_return(ossia::make_string_view("REMOVE_NODE"));
183 }
184 constexpr auto rename_node()
185 {
186  constexpr_return(ossia::make_string_view("RENAME_NODE"));
187 }
188 constexpr auto node_name()
189 {
190  constexpr_return(ossia::make_string_view("NAME"));
191 }
192 constexpr auto start_osc_streaming()
193 {
194  constexpr_return(ossia::make_string_view("START_OSC_STREAMING"));
195 }
196 constexpr auto local_server_port()
197 {
198  constexpr_return(ossia::make_string_view("LOCAL_SERVER_PORT"));
199 }
200 constexpr auto local_sender_port()
201 {
202  constexpr_return(ossia::make_string_view("LOCAL_SENDER_PORT"));
203 }
204 constexpr auto listen()
205 {
206  constexpr_return(ossia::make_string_view("LISTEN"));
207 }
208 constexpr auto ignore()
209 {
210  constexpr_return(ossia::make_string_view("IGNORE"));
211 }
212 constexpr auto text_true()
213 {
214  constexpr_return(ossia::make_string_view("TRUE"));
215 }
216 constexpr auto text_false()
217 {
218  constexpr_return(ossia::make_string_view("FALSE"));
219 }
220 constexpr auto query_value()
221 {
222  constexpr_return(ossia::make_string_view("?VALUE"));
223 }
224 
225 struct OSSIA_EXPORT full_path_attribute
226 {
227  using type = std::string;
228  static auto text() { return detail::attribute_full_path(); }
229  static auto getter(const ossia::net::node_base& n) { return n.osc_address(); }
230 };
231 
232 struct OSSIA_EXPORT typetag_attribute
233 {
234  using type = std::string;
235  static auto text() { return ossia::net::text_value_type(); }
236  static auto getter(const ossia::net::node_base& n)
237  {
238  return oscquery::get_osc_typetag(n);
239  }
240  static auto setter(ossia::net::node_base& n, const std::string& t)
241  {
242  return oscquery::set_osc_typetag(n, t);
243  }
244 };
245 
246 template <typename Attr>
247 struct metadata;
248 
249 // oscquery-specific
250 template <>
251 struct metadata<full_path_attribute>
252 {
253  static constexpr auto key() { return detail::attribute_full_path(); }
254 };
255 template <>
256 struct metadata<typetag_attribute>
257 {
258  static constexpr auto key() { return detail::attribute_typetag(); }
259 };
260 
261 // common attributes
262 template <>
263 struct metadata<net::value_attribute>
264 {
265  static constexpr auto key() { return detail::attribute_value(); }
266 };
267 template <>
268 struct metadata<net::domain_attribute>
269 {
270  static constexpr auto key() { return detail::attribute_range(); }
271 };
272 template <>
273 struct metadata<net::access_mode_attribute>
274 {
275  static constexpr auto key() { return detail::attribute_accessmode(); }
276 };
277 template <>
278 struct metadata<net::bounding_mode_attribute>
279 {
280  static constexpr auto key() { return detail::attribute_clipmode(); }
281 };
282 template <>
283 struct metadata<net::unit_attribute>
284 {
285  static constexpr auto key() { return detail::attribute_unit(); }
286 };
287 template <>
288 struct metadata<net::default_value_attribute>
289 {
290  static constexpr auto key() { return detail::attribute_default_value(); }
291 };
292 template <>
293 struct metadata<net::tags_attribute>
294 {
295  static constexpr auto key() { return detail::attribute_tags(); }
296 };
297 template <>
298 struct metadata<net::refresh_rate_attribute>
299 {
300  static constexpr auto key() { return detail::attribute_refresh_rate(); }
301 };
302 template <>
303 struct metadata<net::priority_attribute>
304 {
305  static constexpr auto key() { return detail::attribute_priority(); }
306 };
307 template <>
308 struct metadata<net::value_step_size_attribute>
309 {
310  static constexpr auto key() { return detail::attribute_step_size(); }
311 };
312 template <>
313 struct metadata<net::instance_bounds_attribute>
314 {
315  static constexpr auto key() { return detail::attribute_instance_bounds(); }
316 };
317 template <>
318 struct metadata<net::critical_attribute>
319 {
320  static constexpr auto key() { return detail::attribute_critical(); }
321 };
322 template <>
323 struct metadata<net::hidden_attribute>
324 {
325  static constexpr auto key() { return detail::attribute_hidden(); }
326 };
327 template <>
328 struct metadata<net::disabled_attribute>
329 {
330  static constexpr auto key() { return detail::attribute_disabled(); }
331 };
332 template <>
333 struct metadata<net::extended_type_attribute>
334 {
335  static constexpr auto key() { return detail::attribute_extended_type(); }
336 };
337 template <>
338 struct metadata<net::description_attribute>
339 {
340  static constexpr auto key() { return detail::attribute_description(); }
341 };
342 template <>
343 struct metadata<net::repetition_filter_attribute>
344 {
345  static constexpr auto key() { return detail::attribute_repetition_filter(); }
346 };
347 template <>
348 struct metadata<net::app_version_attribute>
349 {
350  static constexpr auto key() { return detail::attribute_app_version(); }
351 };
352 template <>
353 struct metadata<net::app_creator_attribute>
354 {
355  static constexpr auto key() { return detail::attribute_app_creator(); }
356 };
357 template <>
358 struct metadata<net::app_name_attribute>
359 {
360  static constexpr auto key() { return detail::attribute_app_name(); }
361 };
362 
363 using base_attributes = boost::mp11::mp_list<
364  typetag_attribute, net::value_attribute, net::domain_attribute,
365  net::access_mode_attribute, net::bounding_mode_attribute,
366  net::repetition_filter_attribute, net::unit_attribute, net::default_value_attribute>;
367 
368 using base_attributes_without_type = boost::mp11::mp_list<
369  net::value_attribute, net::domain_attribute, net::access_mode_attribute,
370  net::bounding_mode_attribute, net::repetition_filter_attribute, net::unit_attribute,
371  net::default_value_attribute>;
372 
373 using extended_attributes = boost::mp11::mp_list<
374  net::tags_attribute, net::refresh_rate_attribute, net::priority_attribute,
375  net::value_step_size_attribute, net::instance_bounds_attribute,
376  net::critical_attribute, net::hidden_attribute, net::disabled_attribute,
377  net::extended_type_attribute, net::description_attribute, net::app_name_attribute,
378  net::app_creator_attribute, net::app_version_attribute>;
379 
380 using attributes_when_reading = boost::mp11::mp_list<
381  net::domain_attribute, net::access_mode_attribute, net::bounding_mode_attribute,
382  net::repetition_filter_attribute, net::tags_attribute, net::refresh_rate_attribute,
383  net::priority_attribute, net::value_step_size_attribute,
384  net::instance_bounds_attribute, net::critical_attribute, net::hidden_attribute,
385  net::disabled_attribute, net::description_attribute, net::app_name_attribute,
386  net::app_creator_attribute, net::app_version_attribute>;
387 
388 using all_attributes = boost::mp11::mp_list<
389  typetag_attribute, net::unit_attribute, net::extended_type_attribute,
390 
391  net::value_attribute, net::default_value_attribute,
392 
393  net::domain_attribute, net::access_mode_attribute, net::bounding_mode_attribute,
394  net::repetition_filter_attribute, net::tags_attribute, net::refresh_rate_attribute,
395  net::priority_attribute, net::value_step_size_attribute,
396  net::instance_bounds_attribute, net::critical_attribute, net::hidden_attribute,
397  net::disabled_attribute, net::description_attribute, net::app_name_attribute,
398  net::app_creator_attribute, net::app_version_attribute>;
399 }
400 enum class message_type
401 {
402  Device,
403  Namespace,
404  Value,
405  PathChanged,
406  PathAdded,
407  PathRemoved,
408  PathRenamed,
409  AttributesChanged,
410  HostInfo,
411  StartOscStreaming,
412  Listen,
413  Ignore
414 };
415 
416 using key_map_type = string_view_map<std::string_view>;
417 
419 OSSIA_EXPORT const key_map_type& ossia_to_oscquery_key();
420 
422 OSSIA_EXPORT const key_map_type& oscquery_to_ossia_key();
423 
425 OSSIA_EXPORT std::optional<std::string_view> ossia_to_oscquery_key(std::string_view);
426 
428 OSSIA_EXPORT std::optional<std::string_view> oscquery_to_ossia_key(std::string_view);
429 }
The node_base class.
Definition: network/base/node.hpp:48