2#include <ossia/network/base/node.hpp>
3#include <ossia/network/base/parameter.hpp>
4#include <ossia/network/value/value.hpp>
6namespace ossia::comparisons
11 friend bool operator==(
const T&, Impulse_T)
16 friend bool operator!=(
const T&, Impulse_T)
21 friend bool operator<=(
const T&, Impulse_T)
26 friend bool operator>=(
const T&, Impulse_T)
31 friend bool operator<(
const T&, Impulse_T)
36 friend bool operator>(
const T&, Impulse_T)
44 friend bool operator==(
const T&, String_T)
49 friend bool operator!=(
const T&, String_T)
54 friend bool operator<=(
const T&, String_T)
59 friend bool operator>=(
const T&, String_T)
64 friend bool operator<(
const T&, String_T)
69 friend bool operator>(
const T&, String_T)
77 template <
typename T,
typename Fun>
78 static bool apply(
const T& lhs,
const ossia::value& val, Fun fun)
86 bool operator()(impulse)
const {
return fun(lhs, Impulse_T{}); }
87 bool operator()(int32_t v)
const {
return fun(lhs, v); }
88 bool operator()(
float v)
const {
return fun(lhs, v); }
89 bool operator()(
bool v)
const {
return fun(lhs, v); }
90 bool operator()(
char v)
const {
return fun(lhs, v); }
91 bool operator()(
const std::vector<ossia::value>& v)
const
93 return (v.size() == 1) && (fun(lhs, v[0]));
96 bool operator()(
const std::string& v)
const {
return fun(lhs, String_T{}); }
97 bool operator()(vec2f v)
const {
return false; }
98 bool operator()(vec3f v)
const {
return false; }
99 bool operator()(vec4f v)
const {
return false; }
101 bool operator()()
const {
return false; }
105 return val.apply(vis);
111 template <
typename Fun>
112 static bool apply(
const std::string& lhs,
const ossia::value& val, Fun fun)
116 const std::string& lhs;
120 bool operator()(impulse)
const {
return fun(lhs, Impulse_T{}); }
121 bool operator()(
const std::string& v)
const {
return fun(lhs, v); }
122 bool operator()(int32_t v)
const {
return fun(v, String_T{}); }
123 bool operator()(
float v)
const {
return fun(v, String_T{}); }
124 bool operator()(
bool v)
const {
return fun(v, String_T{}); }
125 bool operator()(
char v)
const {
return fun(v, String_T{}); }
126 bool operator()(
const std::vector<ossia::value>& v)
const
128 return (v.size() == 1) && (fun(lhs, v[0]));
130 bool operator()(vec2f v)
const {
return fun(v, String_T{}); }
131 bool operator()(vec3f v)
const {
return fun(v, String_T{}); }
132 bool operator()(vec4f v)
const {
return fun(v, String_T{}); }
134 bool operator()()
const {
return false; }
138 return val.apply(vis);
142template <
typename Fun>
145 const std::vector<ossia::value>& lhs;
150 bool operator()(impulse)
const {
return fun(lhs, Impulse_T{}); }
151 bool operator()(
const std::vector<ossia::value>& t)
const
153 if(lhs.size() != t.size())
157 auto tit = t.begin();
158 for(
const auto& val : lhs)
160 result &= fun(val, *tit);
169 template <
typename T>
170 bool operator()(
const T& v)
const
173 return fun(lhs[0], rhs);
178 bool operator()()
const {
return false; }
180template <
typename Fun>
181auto make_list_visitor(
182 const std::vector<ossia::value>& lhs,
const ossia::value& val, Fun f)
184 return ListVisitor<Fun>{lhs, val, f};
189 template <
typename Fun>
191 apply(
const std::vector<ossia::value>& lhs,
const ossia::value& val, Fun fun)
193 auto vis = make_list_visitor(lhs, val, fun);
195 return val.apply(vis);
199template <
typename Fun>
200struct DestinationVisitor
202 const destination& lhs;
207 bool operator()(impulse)
const {
return fun(lhs.value.get(), Impulse_T{}); }
209 template <
typename T>
210 bool operator()(
const T& v)
const
212 return fun(lhs.address().value(lhs.index), rhs);
215 bool operator()()
const {
return false; }
218template <
typename Fun>
219auto make_destination_visitor(
const destination& lhs,
const ossia::value& val, Fun f)
221 return DestinationVisitor<Fun>{lhs, val, f};
224struct DestinationValue
226 template <
typename Fun>
227 static bool apply(
const destination& lhs,
const ossia::value& val, Fun fun)
229 return val.apply(make_destination_visitor(lhs, val, fun));
233template <std::
size_t N,
typename Fun>
236 const std::array<float, N>& lhs;
240 bool operator()(impulse)
const {
return fun(lhs, Impulse_T{}); }
241 bool operator()(
const std::array<float, N>& d)
const {
return fun(lhs, d); }
243 template <
typename T>
244 bool operator()(
const T& v)
const
249 bool operator()()
const {
return false; }
252template <
typename Vec_T,
typename Fun>
253auto make_vec_visitor(
const Vec_T& lhs, Fun f)
255 return VecVisitor<Vec_T::size_value, Fun>{lhs, f};
260 template <
typename Vec_T,
typename Fun>
261 static bool apply(
const Vec_T& lhs,
const ossia::value& val, Fun fun)
263 return val.apply(make_vec_visitor(lhs, fun));
The value class.
Definition value.hpp:173