2#include <ossia/detail/flat_set.hpp>
3#include <ossia/detail/optional.hpp>
31struct OSSIA_EXPORT domain_base
33 using value_type =
typename value_trait<T>::value_type;
34 std::optional<value_type>
min;
35 std::optional<value_type>
max;
36 std::vector<value_type> values;
38 domain_base() noexcept { }
40 domain_base(
const domain_base& other)
43 , values{other.values}
47 domain_base(domain_base&& other) noexcept
48 :
min{std::move(other.min)}
49 ,
max{std::move(other.max)}
50 , values{std::move(other.values)}
54 domain_base& operator=(
const domain_base& other)
58 values = other.values;
62 domain_base& operator=(domain_base&& other)
noexcept
64 min = std::move(other.min);
65 max = std::move(other.max);
66 values = std::move(other.values);
70 friend bool operator==(
const domain_base<T>& lhs,
const domain_base<T>& rhs)
noexcept
72 return lhs.min == rhs.min && lhs.max == rhs.max && lhs.values == rhs.values;
74 friend bool operator!=(
const domain_base<T>& lhs,
const domain_base<T>& rhs)
noexcept
76 return lhs.min != rhs.min || lhs.max != rhs.max || lhs.values != rhs.values;
79 domain_base(value_type v1, value_type v2) noexcept
84 domain_base(value_type v1, value_type v2,
const ossia::flat_set<value_type>& vals)
90 domain_base(value_type v1, value_type v2, ossia::flat_set<value_type>&& vals) noexcept
93 , values{std::move(vals)}
99struct OSSIA_EXPORT domain_base<impulse>
101 using value_type = ossia::impulse;
103 operator==(
const domain_base<impulse>& lhs,
const domain_base<impulse>& rhs)
108 operator!=(
const domain_base<impulse>& lhs,
const domain_base<impulse>& rhs)
115struct OSSIA_EXPORT domain_base<bool>
117 using value_type = bool;
118 static const constexpr bool min =
false;
119 static const constexpr bool max =
true;
120 friend bool operator==(
const domain_base<bool>& lhs,
const domain_base<bool>& rhs)
124 friend bool operator!=(
const domain_base<bool>& lhs,
const domain_base<bool>& rhs)
131struct OSSIA_EXPORT domain_base<std::string>
133 std::vector<std::string> values;
135 operator==(
const domain_base<std::string>& lhs,
const domain_base<std::string>& rhs)
137 return lhs.values == rhs.values;
140 operator!=(
const domain_base<std::string>& lhs,
const domain_base<std::string>& rhs)
142 return lhs.values != rhs.values;
146struct OSSIA_EXPORT vector_domain
149 using value_type = std::vector<ossia::value>;
152 std::vector<ossia::flat_set<ossia::value>> values;
154 vector_domain() noexcept { }
155 vector_domain(
const vector_domain& other) noexcept
158 , values(other.values)
162 vector_domain(vector_domain&& other) noexcept
163 :
min(std::move(other.min))
164 ,
max(std::move(other.max))
165 , values(std::move(other.values))
169 vector_domain& operator=(
const vector_domain& other)
173 values = other.values;
177 vector_domain& operator=(vector_domain&& other)
noexcept
179 min = std::move(other.min);
180 max = std::move(other.max);
181 values = std::move(other.values);
185 vector_domain(std::nullopt_t, std::nullopt_t) { }
187 vector_domain(
const value_type& v1,
const value_type& v2)
192 vector_domain(value_type&& v1, value_type&& v2)
198 const value_type& v1,
const value_type& v2,
199 const std::vector<ossia::flat_set<ossia::value>>& vals)
206 value_type&& v1, value_type&& v2,
207 std::vector<ossia::flat_set<ossia::value>>&& vals)
210 , values(std::move(vals))
214 friend bool operator==(
const vector_domain& lhs,
const vector_domain& rhs)
216 return lhs.min == rhs.min && lhs.max == rhs.max && lhs.values == rhs.values;
218 friend bool operator!=(
const vector_domain& lhs,
const vector_domain& rhs)
220 return lhs.min != rhs.min || lhs.max != rhs.max || lhs.values != rhs.values;
224#if !defined(OSSIA_FREESTANDING)
225template <std::
size_t N>
226struct OSSIA_EXPORT vecf_domain
228 using value_type = std::array<float, N>;
229 std::array<std::optional<float>, N>
min;
230 std::array<std::optional<float>, N>
max;
231 std::array<ossia::flat_set<float>, N> values;
233 vecf_domain() noexcept { }
234 vecf_domain(
const vecf_domain& other) noexcept
235 :
min{std::move(other.min)}
236 ,
max{std::move(other.max)}
237 , values{std::move(other.values)}
241 vecf_domain(vecf_domain&& other) noexcept
242 :
min{std::move(other.min)}
243 ,
max{std::move(other.max)}
244 , values{std::move(other.values)}
248 vecf_domain& operator=(
const vecf_domain& other)
252 values = other.values;
256 vecf_domain& operator=(vecf_domain&& other)
noexcept
258 min = std::move(other.min);
259 max = std::move(other.max);
260 values = std::move(other.values);
265 const std::array<std::optional<float>, N>& v1,
266 const std::array<std::optional<float>, N>& v2)
272 vecf_domain(
const std::array<float, N>& v1,
const std::array<float, N>& v2)
274 for(std::size_t i = 0; i < N; i++)
281 const std::array<std::optional<float>, N>& v1,
282 const std::array<std::optional<float>, N>& v2,
283 const std::array<ossia::flat_set<float>, N>& vals)
290 const std::array<std::optional<float>, N>& v1,
291 const std::array<std::optional<float>, N>& v2,
292 std::array<ossia::flat_set<float>, N>&& vals)
295 , values{std::move(vals)}
299 friend bool operator==(
const vecf_domain& lhs,
const vecf_domain& rhs)
301 return lhs.min == rhs.min && lhs.max == rhs.max && lhs.values == rhs.values;
303 friend bool operator!=(
const vecf_domain& lhs,
const vecf_domain& rhs)
305 return lhs.min != rhs.min || lhs.max != rhs.max || lhs.values != rhs.values;
310struct OSSIA_EXPORT domain_base<
ossia::value>
313 std::optional<value_type>
min;
314 std::optional<value_type>
max;
315 std::vector<value_type> values;
317 domain_base() noexcept { }
318 domain_base(
const domain_base& other) noexcept
321 , values{other.values}
325 domain_base(domain_base&& other) noexcept
326 :
min{std::move(other.min)}
327 ,
max{std::move(other.max)}
328 , values{std::move(other.values)}
332 domain_base& operator=(
const domain_base& other)
336 values = other.values;
340 domain_base& operator=(domain_base&& other)
noexcept
342 min = std::move(other.min);
343 max = std::move(other.max);
344 values = std::move(other.values);
348 domain_base(
const value_type& v1,
const value_type& v2)
353 domain_base(value_type&& v1, value_type&& v2)
359 const value_type& v1,
const value_type& v2,
const std::vector<value_type>& vals)
365 domain_base(value_type&& v1, value_type&& v2, std::vector<value_type>&& vals)
368 , values{std::move(vals)}
373 operator==(
const domain_base<ossia::value>& lhs,
const domain_base<ossia::value>& rhs)
375 return lhs.min == rhs.min && lhs.max == rhs.max && lhs.values == rhs.values;
378 operator!=(
const domain_base<ossia::value>& lhs,
const domain_base<ossia::value>& rhs)
380 return lhs.min != rhs.min || lhs.max != rhs.max || lhs.values != rhs.values;
385template <std::
size_t N>
386struct OSSIA_EXPORT vecf_domain : ossia::domain_base<float>
388 using ossia::domain_base<
float>::domain_base;
389 vecf_domain(
const std::array<float, N>& v1,
const std::array<float, N>& v2)
395 const std::array<std::optional<float>, N>& v1,
396 const std::array<std::optional<float>, N>& v2)
401 friend bool operator==(
const vecf_domain& lhs,
const vecf_domain& rhs)
403 return lhs.min == rhs.min && lhs.max == rhs.max && lhs.values == rhs.values;
405 friend bool operator!=(
const vecf_domain& lhs,
const vecf_domain& rhs)
407 return lhs.min != rhs.min || lhs.max != rhs.max || lhs.values != rhs.values;
411struct OSSIA_EXPORT domain_base<
ossia::value> : ossia::domain_base<float>
413 using ossia::domain_base<
float>::domain_base;
415 operator==(
const domain_base<ossia::value>& lhs,
const domain_base<ossia::value>& rhs)
417 return lhs.min == rhs.min && lhs.max == rhs.max && lhs.values == rhs.values;
420 operator!=(
const domain_base<ossia::value>& lhs,
const domain_base<ossia::value>& rhs)
422 return lhs.min != rhs.min || lhs.max != rhs.max || lhs.values != rhs.values;
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 T clamp(T d, const T min, const T max) noexcept
clamp Returns the value bounded by a min and a max
Definition math.hpp:154
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