OSSIA
Open Scenario System for Interactive Application
domain_functions.hpp
1 #pragma once
2 #include <ossia/detail/config.hpp>
3 
4 #include <ossia/detail/small_vector.hpp>
5 #include <ossia/detail/span.hpp>
6 #include <ossia/network/common/parameter_properties.hpp>
7 #include <ossia/network/value/value_base.hpp>
8 
9 #include <optional>
10 #include <utility>
11 #include <vector>
12 namespace ossia
13 {
14 class value;
15 template <typename T>
16 struct domain_base;
17 struct domain;
18 struct vector_domain;
19 template <std::size_t N>
20 struct vecf_domain;
21 
22 OSSIA_EXPORT value
23 apply_domain(const domain& dom, bounding_mode b, const ossia::value& val);
24 OSSIA_EXPORT value apply_domain(const domain& dom, bounding_mode b, ossia::value&& val);
25 
26 OSSIA_EXPORT value get_min(const domain& dom);
27 OSSIA_EXPORT value get_max(const domain& dom);
28 OSSIA_EXPORT std::pair<std::optional<float>, std::optional<float>>
29 get_float_minmax(const domain& dom);
30 
31 OSSIA_EXPORT void set_min(domain& dom, const ossia::value& val);
32 OSSIA_EXPORT void set_max(domain& dom, const ossia::value& val);
33 
34 OSSIA_EXPORT void set_values(domain& dom, const std::vector<ossia::value>& val);
35 OSSIA_EXPORT std::vector<ossia::value> get_values(const ossia::domain& dom);
36 
37 // TODO we should find a way to prevent invalid domains here, e.g. min=int,
38 // max=float
39 OSSIA_EXPORT
40 domain make_domain(const ossia::value& lhs, const ossia::value& rhs);
41 
42 OSSIA_EXPORT domain make_domain(std::vector<std::string> s);
43 OSSIA_EXPORT domain make_domain(tcb::span<const char*>);
44 
45 OSSIA_EXPORT domain make_domain_from_osc(
46  const ossia::small_vector<ossia::value, 2>& val, const ossia::value& cur);
47 OSSIA_EXPORT domain make_domain(
48  const ossia::value& min, const ossia::value& max,
49  const std::vector<ossia::value>& vals);
50 OSSIA_EXPORT domain make_domain(const std::vector<ossia::value>& vals);
51 
52 OSSIA_EXPORT
53 ossia::domain make_domain_from_minmax(
54  const std::vector<ossia::value>& min, const std::vector<ossia::value>& max,
55  ossia::val_type v);
56 
57 OSSIA_EXPORT domain init_domain(ossia::val_type type);
58 
59 template <typename T>
60 bool operator!=(const domain_base<T>& lhs, const domain_base<T>& rhs)
61 {
62  return !(lhs == rhs);
63 }
64 }
65 
66 OSSIA_EXPORT
67 std::ostream& operator<<(std::ostream&, const ossia::domain&);
The value class.
Definition: value.hpp:173
Definition: git_info.h:7
val_type
Enum to represent the types that a value can take.
Definition: parameter_properties.hpp:16
bounding_mode
Address behaviors at crossing domain boundaries.
Definition: parameter_properties.hpp:56
constexpr OSSIA_INLINE 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
constexpr OSSIA_INLINE 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
domain A domain of values
Definition: domain_base.hpp:23