2#include <ossia/detail/for_each.hpp>
3#include <ossia/detail/hash_map.hpp>
4#include <ossia/network/dataspace/dataspace.hpp>
5#include <ossia/network/dataspace/detail/dataspace_list.hpp>
10struct unit_text_visitor
12 OSSIA_INLINE std::string_view operator()(
const angle_u& dataspace)
14 return ossia::apply(*
this, dataspace);
16 OSSIA_INLINE std::string_view operator()(
const color_u& dataspace)
18 return ossia::apply(*
this, dataspace);
20 OSSIA_INLINE std::string_view operator()(
const distance_u& dataspace)
22 return ossia::apply(*
this, dataspace);
24 OSSIA_INLINE std::string_view operator()(
const gain_u& dataspace)
26 return ossia::apply(*
this, dataspace);
28 OSSIA_INLINE std::string_view operator()(
const position_u& dataspace)
30 return ossia::apply(*
this, dataspace);
32 OSSIA_INLINE std::string_view operator()(
const orientation_u& dataspace)
34 return ossia::apply(*
this, dataspace);
36 OSSIA_INLINE std::string_view operator()(
const speed_u& dataspace)
38 return ossia::apply(*
this, dataspace);
40 OSSIA_INLINE std::string_view operator()(
const timing_u& dataspace)
42 return ossia::apply(*
this, dataspace);
45 template <
typename Unit>
46 OSSIA_INLINE std::string_view operator()(Unit)
48 constexpr_return(ossia::unit_traits<Unit>::text()[0]);
51 OSSIA_INLINE std::string_view operator()(
const ossia::value&) {
return {}; }
53 OSSIA_INLINE std::string_view operator()() {
return {}; }
56struct unit_accessor_visitor
58 OSSIA_INLINE std::string_view operator()(
const angle_u& dataspace) {
return {}; }
59 OSSIA_INLINE std::string_view operator()(
const color_u& dataspace)
61 return ossia::apply(*
this, dataspace);
63 OSSIA_INLINE std::string_view operator()(
const distance_u& dataspace) {
return {}; }
64 OSSIA_INLINE std::string_view operator()(
const gain_u& dataspace) {
return {}; }
65 OSSIA_INLINE std::string_view operator()(
const position_u& dataspace)
67 return ossia::apply(*
this, dataspace);
69 OSSIA_INLINE std::string_view operator()(
const orientation_u& dataspace)
71 return ossia::apply(*
this, dataspace);
73 OSSIA_INLINE std::string_view operator()(
const speed_u& dataspace) {
return {}; }
74 OSSIA_INLINE std::string_view operator()(
const timing_u& dataspace) {
return {}; }
76 template <
typename Unit>
77 OSSIA_INLINE std::string_view operator()(Unit)
79 return Unit::array_parameters();
82 OSSIA_INLINE std::string_view operator()() {
return {}; }
85struct dataspace_text_visitor
87 template <
typename Dataspace>
88 OSSIA_INLINE std::string_view operator()(
const Dataspace& dataspace)
90 constexpr_return(ossia::dataspace_traits<Dataspace>::text()[0]);
93 OSSIA_INLINE std::string_view operator()() {
return {}; }
96using unit_pretty_text_map = ossia::hash_map<ossia::unit_t, std::string>;
97template <
typename Dataspace,
typename Unit>
98std::string make_pretty_unit_text()
100 using unit_type = Unit;
105 constexpr auto ds = dataspace_traits<Dataspace>::text()[0];
106 constexpr auto un = unit_traits<unit_type>::text()[0];
108 res.append(ds.data(), ds.size());
111 res.append(un.data(), un.size());
116struct unit_pretty_texts
118 unit_pretty_text_map map;
122 ossia::for_each_tagged(dataspace_u_list{}, [&](
auto t) {
123 using dataspace_type =
typename decltype(t)::type;
124 using dataspace_t =
typename matching_unit_u_list<dataspace_type>::type;
125 map[dataspace_t{}] = dataspace_traits<dataspace_type>::text()[0];
126 ossia::for_each_tagged(dataspace_type{}, [&](
auto u) {
127 using unit_type =
typename decltype(u)::type;
128 map[unit_type{}] = make_pretty_unit_text<dataspace_type, unit_type>();
The value class.
Definition value.hpp:173
Definition transitive_closure.hpp:27