2#include <ossia/detail/flat_set.hpp>
3#include <ossia/detail/small_vector.hpp>
18 return value::make<typename T::value_type>(*
value.min);
34struct domain_min_visitor_helper<domain_base<impulse>>
36 OSSIA_INLINE
ossia::value operator()(
const domain_base<impulse>& value)
const
43struct domain_min_visitor_helper<domain_base<std::string>>
45 OSSIA_INLINE
ossia::value operator()(
const domain_base<std::string>& value)
const
52struct domain_min_visitor_helper<domain_base<
ossia::value>>
54 OSSIA_INLINE
ossia::value operator()(
const domain_base<ossia::value>& value)
const
66struct domain_min_visitor_helper<vector_domain>
68 OSSIA_INLINE
ossia::value operator()(
const vector_domain& value)
const
74template <std::
size_t N>
75struct domain_min_visitor_helper<vecf_domain<N>>
77 OSSIA_INLINE
ossia::value operator()(
const vecf_domain<N>& value)
const
81 std::array<float, N> arr;
82#if !defined(OSSIA_FREESTANDING)
83 for(
auto& val : value.
min)
85 return
ossia::value{};
87 for(std::size_t i = 0; i < N; i++)
89 arr[i] = *value.min[i];
103 return value::make<typename T::value_type>(*
value.max);
119struct domain_max_visitor_helper<domain_base<impulse>>
121 OSSIA_INLINE
ossia::value operator()(
const domain_base<impulse>& value)
const
128struct domain_max_visitor_helper<domain_base<std::string>>
130 OSSIA_INLINE
ossia::value operator()(
const domain_base<std::string>& value)
const
137struct domain_max_visitor_helper<domain_base<
ossia::value>>
139 OSSIA_INLINE
ossia::value operator()(
const domain_base<ossia::value>& value)
const
151struct domain_max_visitor_helper<vector_domain>
153 OSSIA_INLINE
ossia::value operator()(
const vector_domain& value)
const
159template <std::
size_t N>
160struct domain_max_visitor_helper<vecf_domain<N>>
162 OSSIA_INLINE
ossia::value operator()(
const vecf_domain<N>& value)
const
164 std::array<float, N> arr;
165#if !defined(OSSIA_FREESTANDING)
166 for(
auto& val : value.
max)
168 return
ossia::value{};
170 for(std::size_t i = 0; i < N; i++)
172 arr[i] = *value.max[i];
180using float_minmax = std::pair<std::optional<float>, std::optional<float>>;
182struct domain_float_minmax_visitor_helper
184 OSSIA_INLINE float_minmax operator()(
const T& value)
const
188 ret.first = *value.min;
190 ret.second = *value.max;
196struct domain_float_minmax_visitor_helper<domain_base<bool>>
198 OSSIA_INLINE float_minmax operator()(
const domain_base<bool>& value)
const
200 return std::make_pair(0.f, 1.f);
205struct domain_float_minmax_visitor_helper<domain_base<impulse>>
207 OSSIA_INLINE float_minmax operator()(
const domain_base<impulse>& value)
const
214struct domain_float_minmax_visitor_helper<domain_base<std::string>>
216 OSSIA_INLINE float_minmax operator()(
const domain_base<std::string>& value)
const
223struct domain_float_minmax_visitor_helper<domain_base<
ossia::value>>
225 OSSIA_INLINE float_minmax operator()(
const domain_base<ossia::value>& value)
const
232 ret.first = ossia::convert<float>(*value.min);
234 ret.second = ossia::convert<float>(*value.max);
240struct domain_float_minmax_visitor_helper<vector_domain>
242 OSSIA_INLINE float_minmax operator()(
const vector_domain& value)
const {
return {}; }
245template <std::
size_t N>
246struct domain_float_minmax_visitor_helper<vecf_domain<N>>
248 OSSIA_INLINE float_minmax operator()(
const vecf_domain<N>& value)
const {
return {}; }
253struct domain_min_visitor
255 template <
typename T>
256 OSSIA_INLINE
ossia::value operator()(
const domain_base<T>& value)
const
258 return detail::domain_min_visitor_helper<domain_base<T>>{}(value);
261 OSSIA_INLINE
ossia::value operator()(
const vector_domain& value)
const
263 return detail::domain_min_visitor_helper<vector_domain>{}(value);
266 template <std::
size_t N>
267 OSSIA_INLINE
ossia::value operator()(
const vecf_domain<N>& value)
const
269 return detail::domain_min_visitor_helper<vecf_domain<N>>{}(value);
272 template <
typename... T>
279struct domain_max_visitor
281 template <
typename T>
282 OSSIA_INLINE
ossia::value operator()(
const domain_base<T>& value)
const
284 return detail::domain_max_visitor_helper<domain_base<T>>{}(value);
287 OSSIA_INLINE
ossia::value operator()(
const vector_domain& value)
const
289 return detail::domain_max_visitor_helper<vector_domain>{}(value);
292 template <std::
size_t N>
293 OSSIA_INLINE
ossia::value operator()(
const vecf_domain<N>& value)
const
295 return detail::domain_max_visitor_helper<vecf_domain<N>>{}(value);
298 template <
typename... T>
305struct domain_float_minmax_visitor
307 using return_type = detail::float_minmax;
308 template <
typename T>
309 OSSIA_INLINE return_type operator()(
const domain_base<T>& value)
const
311 return detail::domain_float_minmax_visitor_helper<domain_base<T>>{}(value);
314 OSSIA_INLINE return_type operator()(
const vector_domain& value)
const
316 return detail::domain_float_minmax_visitor_helper<vector_domain>{}(value);
319 template <std::
size_t N>
320 OSSIA_INLINE return_type operator()(
const vecf_domain<N>& value)
const
322 return detail::domain_float_minmax_visitor_helper<vecf_domain<N>>{}(value);
325 template <
typename... T>
326 OSSIA_INLINE return_type operator()(
const T&...)
const
331struct domain_set_min_visitor
333 OSSIA_INLINE
void operator()(domain_base<int32_t>& domain, int32_t incoming)
335 domain.min = incoming;
337 OSSIA_INLINE
void operator()(domain_base<float>& domain,
float incoming)
339 domain.min = incoming;
341 OSSIA_INLINE
void operator()(domain_base<int32_t>& domain,
float incoming)
343 domain.min = incoming;
345 OSSIA_INLINE
void operator()(domain_base<float>& domain, int32_t incoming)
347 domain.min = incoming;
349 OSSIA_INLINE
void operator()(domain_base<bool>& domain,
bool incoming) { }
351 operator()(vector_domain& domain,
const std::vector<ossia::value>& incoming)
353 domain.min = incoming;
356 template <std::
size_t N>
357 OSSIA_INLINE
void operator()(vecf_domain<N>& domain,
float incoming)
359#if !defined(OSSIA_FREESTANDING)
360 for(std::size_t i = 0; i < N; i++)
361 domain.min[i] = incoming;
365 template <std::
size_t N>
366 OSSIA_INLINE
void operator()(vecf_domain<N>& domain,
int incoming)
368#if !defined(OSSIA_FREESTANDING)
369 for(std::size_t i = 0; i < N; i++)
370 domain.min[i] = incoming;
374 template <std::
size_t N>
376 operator()(vecf_domain<N>& domain,
const std::array<float, N>& incoming)
378#if !defined(OSSIA_FREESTANDING)
379 for(std::size_t i = 0; i < N; i++)
380 domain.min[i] = incoming[i];
384 template <std::
size_t N>
386 operator()(vecf_domain<N>& domain,
const std::vector<ossia::value>& incoming)
388#if !defined(OSSIA_FREESTANDING)
389 if(incoming.size() == N)
391 auto conv = ossia::convert<std::array<float, N>>(incoming);
392 for(std::size_t i = 0; i < N; i++)
393 domain.min[i] = conv[i];
397 for(std::size_t i = 0; i < N; i++)
398 domain.min[i] = std::nullopt;
403 template <
typename T>
404 OSSIA_INLINE
void operator()(domain_base<ossia::value>& domain,
const T& incoming)
406#if !defined(OSSIA_FREESTANDING)
414 template <
typename... U>
415 OSSIA_INLINE
void operator()(domain_base<int32_t>& domain, U&&...)
417 domain.min = std::nullopt;
419 template <
typename... U>
420 OSSIA_INLINE
void operator()(domain_base<float>& domain, U&&...)
422 domain.min = std::nullopt;
424 template <
typename... U>
425 OSSIA_INLINE
void operator()(domain_base<bool>& domain, U&&...)
428 template <
typename... U>
429 OSSIA_INLINE
void operator()(vector_domain& domain, U&&...)
433 template <std::size_t N,
typename... U>
434 OSSIA_INLINE
void operator()(vecf_domain<N>& domain, U&&...)
436#if !defined(OSSIA_FREESTANDING)
437 for(std::size_t i = 0; i < N; i++)
438 domain.min[i] = std::nullopt;
441 template <
typename... U>
442 OSSIA_INLINE
void operator()(domain_base<ossia::value>& domain, U&&...)
444 domain.min = std::nullopt;
447 template <
typename T,
typename... U>
448 OSSIA_INLINE
void operator()(
const domain_base<T>& domain, U&&...)
453struct domain_set_max_visitor
455 OSSIA_INLINE
void operator()(domain_base<int32_t>& domain, int32_t incoming)
457 domain.max = incoming;
459 OSSIA_INLINE
void operator()(domain_base<float>& domain,
float incoming)
461 domain.max = incoming;
463 OSSIA_INLINE
void operator()(domain_base<int32_t>& domain,
float incoming)
465 domain.max = incoming;
467 OSSIA_INLINE
void operator()(domain_base<float>& domain, int32_t incoming)
469 domain.max = incoming;
471 OSSIA_INLINE
void operator()(domain_base<bool>& domain,
bool incoming) { }
473 operator()(vector_domain& domain,
const std::vector<ossia::value>& incoming)
475 domain.max = incoming;
478 template <std::
size_t N>
479 OSSIA_INLINE
void operator()(vecf_domain<N>& domain,
float incoming)
481#if !defined(OSSIA_FREESTANDING)
482 for(std::size_t i = 0; i < N; i++)
483 domain.max[i] = incoming;
487 template <std::
size_t N>
488 OSSIA_INLINE
void operator()(vecf_domain<N>& domain,
int incoming)
490#if !defined(OSSIA_FREESTANDING)
491 for(std::size_t i = 0; i < N; i++)
492 domain.max[i] = incoming;
496 template <std::
size_t N>
498 operator()(vecf_domain<N>& domain,
const std::array<float, N>& incoming)
500#if !defined(OSSIA_FREESTANDING)
501 for(std::size_t i = 0; i < N; i++)
502 domain.max[i] = incoming[i];
506 template <std::
size_t N>
508 operator()(vecf_domain<N>& domain,
const std::vector<ossia::value>& incoming)
510#if !defined(OSSIA_FREESTANDING)
511 if(incoming.size() == N)
513 auto conv = ossia::convert<std::array<float, N>>(incoming);
514 for(std::size_t i = 0; i < N; i++)
515 domain.max[i] = conv[i];
519 for(std::size_t i = 0; i < N; i++)
520 domain.max[i] = std::nullopt;
525 template <
typename T>
526 OSSIA_INLINE
void operator()(domain_base<ossia::value>& domain,
const T& incoming)
528#if !defined(OSSIA_FREESTANDING)
534 template <
typename... U>
535 OSSIA_INLINE
void operator()(domain_base<int32_t>& domain, U&&...)
537 domain.max = std::nullopt;
539 template <
typename... U>
540 OSSIA_INLINE
void operator()(domain_base<float>& domain, U&&...)
542 domain.max = std::nullopt;
544 template <
typename... U>
545 OSSIA_INLINE
void operator()(domain_base<bool>& domain, U&&...)
548 template <
typename... U>
549 OSSIA_INLINE
void operator()(vector_domain& domain, U&&...)
553 template <std::size_t N,
typename... U>
554 OSSIA_INLINE
void operator()(vecf_domain<N>& domain, U&&...)
556#if !defined(OSSIA_FREESTANDING)
557 for(std::size_t i = 0; i < N; i++)
558 domain.max[i] = std::nullopt;
561 template <
typename... U>
562 OSSIA_INLINE
void operator()(domain_base<ossia::value>& domain, U&&...)
564 domain.max = std::nullopt;
567 template <
typename T,
typename... U>
568 OSSIA_INLINE
void operator()(
const domain_base<T>& domain, U&&...)
573struct domain_minmax_creation_visitor
575 template <
typename T>
576 OSSIA_INLINE domain operator()(T
min, T
max)
578 return domain_base<T>(
min,
max);
581 OSSIA_INLINE domain operator()(
bool min,
bool max) {
return domain_base<bool>{}; }
583 template <std::
size_t N>
585 operator()(
const std::array<float, N>& lhs,
const std::array<float, N>& rhs)
587 return vecf_domain<N>(lhs, rhs);
591 operator()(
const std::vector<ossia::value>&
min,
const std::vector<ossia::value>&
max)
593 return vector_domain(
min,
max);
596 operator()(std::vector<ossia::value>&&
min, std::vector<ossia::value>&&
max)
598 return vector_domain(std::move(
min), std::move(
max));
601 OSSIA_INLINE domain operator()(impulse, impulse) {
return domain_base<impulse>{}; }
603 OSSIA_INLINE domain operator()(
const std::string&,
const std::string&)
605 return domain_base<std::string>();
607 OSSIA_INLINE domain operator()(
const value_map_type&,
const value_map_type&)
613 template <
typename T,
typename U>
614 OSSIA_INLINE domain operator()(
const T&,
const U&)
620struct domain_min_creation_visitor
622 template <
typename T>
623 OSSIA_INLINE domain operator()(T
min)
626 dom.min = std::move(
min);
630 OSSIA_INLINE domain operator()(
bool min) {
return domain_base<bool>{}; }
632 template <std::
size_t N>
633 OSSIA_INLINE domain operator()(
const std::array<float, N>&
min)
636#if !defined(OSSIA_FREESTANDING)
637 for(std::size_t i = 0; i < N; i++)
645 OSSIA_INLINE domain operator()(
const std::vector<ossia::value>&
min)
651 OSSIA_INLINE domain operator()(
const value_map_type&
min) {
return {}; }
652 OSSIA_INLINE domain operator()(std::vector<ossia::value>&&
min)
654 return vector_domain(std::move(
min), std::vector<ossia::value>(
min.size()));
657 OSSIA_INLINE domain operator()(impulse) {
return domain_base<impulse>{}; }
659 OSSIA_INLINE domain operator()(
const std::string&)
661 return domain_base<std::string>();
665struct domain_max_creation_visitor
667 template <
typename T>
668 OSSIA_INLINE domain operator()(T
max)
671 dom.max = std::move(
max);
675 OSSIA_INLINE domain operator()(
bool max) {
return domain_base<bool>{}; }
677 template <std::
size_t N>
678 OSSIA_INLINE domain operator()(
const std::array<float, N>&
max)
681#if !defined(OSSIA_FREESTANDING)
682 for(std::size_t i = 0; i < N; i++)
690 OSSIA_INLINE domain operator()(
const std::vector<ossia::value>&
max)
696 OSSIA_INLINE domain operator()(std::vector<ossia::value>&&
max)
698 return vector_domain(std::move(
max), std::vector<ossia::value>(
max.size()));
701 OSSIA_INLINE domain operator()(
const value_map_type&
min) {
return {}; }
702 OSSIA_INLINE domain operator()(impulse) {
return domain_base<impulse>{}; }
704 OSSIA_INLINE domain operator()(
const std::string&)
706 return domain_base<std::string>();
718 const ossia::small_vector<ossia::value, 2>& values;
719 template <
typename T>
720 domain operator()(
const T&)
724 for(
auto&
value : values)
726 if(
auto r =
value.target<T>())
727 dom.values.push_back(*r);
732 domain operator()(
bool) {
return domain_base<bool>{}; }
734 domain operator()(
const std::vector<ossia::value>& orig)
737 ossia::flat_set<ossia::value> vals;
739 for(
const auto&
value : values)
743 = std::vector<ossia::flat_set<ossia::value>>(orig.size(), std::move(vals));
748 OSSIA_INLINE
domain operator()(
const value_map_type&
min) {
return {}; }
750 template <std::
size_t N>
751 domain operator()(
const std::array<float, N>&)
754#if !defined(OSSIA_FREESTANDING)
755 ossia::flat_set<float> vals;
757 for(
const auto&
value : values)
758 if(
auto r =
value.target<
float>())
761 for(std::size_t i = 0; i < N - 1; i++)
762 res.values[i] = vals;
763 res.values[N - 1] = std::move(vals);
The value class.
Definition value.hpp:173
OSSIA_INLINE constexpr auto min(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
min function tailored for values
Definition math.hpp:125
OSSIA_INLINE constexpr auto max(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
max function tailored for values
Definition math.hpp:96
Max ///.
Definition min_max.hpp:99
Min ///.
Definition min_max.hpp:14
The domain_value_set_creation_visitor struct.
Definition min_max.hpp:717
domain A domain of values
Definition domain_base.hpp:23