2 #include <ossia/detail/flat_set.hpp>
3 #include <ossia/detail/optional.hpp>
31 struct 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 { }
39 domain_base(
const domain_base& other) noexcept
42 , values{other.values}
46 domain_base(domain_base&& other) noexcept
47 :
min{std::move(other.min)}
48 ,
max{std::move(other.max)}
49 , values{std::move(other.values)}
53 domain_base& operator=(
const domain_base& other)
57 values = other.values;
61 domain_base& operator=(domain_base&& other) noexcept
63 min = std::move(other.min);
64 max = std::move(other.max);
65 values = std::move(other.values);
69 friend bool operator==(
const domain_base<T>& lhs,
const domain_base<T>& rhs)
71 return lhs.min == rhs.min && lhs.max == rhs.max && lhs.values == rhs.values;
73 friend bool operator!=(
const domain_base<T>& lhs,
const domain_base<T>& rhs)
75 return lhs.min != rhs.min || lhs.max != rhs.max || lhs.values != rhs.values;
78 domain_base(value_type v1, value_type v2)
83 domain_base(value_type v1, value_type v2,
const ossia::flat_set<value_type>& vals)
89 domain_base(value_type v1, value_type v2, ossia::flat_set<value_type>&& vals)
92 , values{std::move(vals)}
98 struct OSSIA_EXPORT domain_base<impulse>
100 using value_type = ossia::impulse;
102 operator==(
const domain_base<impulse>& lhs,
const domain_base<impulse>& rhs)
107 operator!=(
const domain_base<impulse>& lhs,
const domain_base<impulse>& rhs)
114 struct OSSIA_EXPORT domain_base<bool>
116 using value_type = bool;
117 static const constexpr
bool min =
false;
118 static const constexpr
bool max =
true;
119 friend bool operator==(
const domain_base<bool>& lhs,
const domain_base<bool>& rhs)
123 friend bool operator!=(
const domain_base<bool>& lhs,
const domain_base<bool>& rhs)
130 struct OSSIA_EXPORT domain_base<std::string>
132 std::vector<std::string> values;
134 operator==(
const domain_base<std::string>& lhs,
const domain_base<std::string>& rhs)
136 return lhs.values == rhs.values;
139 operator!=(
const domain_base<std::string>& lhs,
const domain_base<std::string>& rhs)
141 return lhs.values != rhs.values;
145 struct OSSIA_EXPORT vector_domain
148 using value_type = std::vector<ossia::value>;
151 std::vector<ossia::flat_set<ossia::value>> values;
153 vector_domain() noexcept { }
154 vector_domain(
const vector_domain& other) noexcept
157 , values(other.values)
161 vector_domain(vector_domain&& other) noexcept
162 :
min(std::move(other.min))
163 ,
max(std::move(other.max))
164 , values(std::move(other.values))
168 vector_domain& operator=(
const vector_domain& other)
172 values = other.values;
176 vector_domain& operator=(vector_domain&& other) noexcept
178 min = std::move(other.min);
179 max = std::move(other.max);
180 values = std::move(other.values);
184 vector_domain(std::nullopt_t, std::nullopt_t) { }
186 vector_domain(
const value_type& v1,
const value_type& v2)
191 vector_domain(value_type&& v1, value_type&& v2)
197 const value_type& v1,
const value_type& v2,
198 const std::vector<ossia::flat_set<ossia::value>>& vals)
205 value_type&& v1, value_type&& v2,
206 std::vector<ossia::flat_set<ossia::value>>&& vals)
209 , values(std::move(vals))
213 friend bool operator==(
const vector_domain& lhs,
const vector_domain& rhs)
215 return lhs.min == rhs.min && lhs.max == rhs.max && lhs.values == rhs.values;
217 friend bool operator!=(
const vector_domain& lhs,
const vector_domain& rhs)
219 return lhs.min != rhs.min || lhs.max != rhs.max || lhs.values != rhs.values;
223 template <std::
size_t N>
224 struct OSSIA_EXPORT vecf_domain
226 using value_type = std::array<float, N>;
227 std::array<std::optional<float>, N>
min;
228 std::array<std::optional<float>, N>
max;
229 std::array<ossia::flat_set<float>, N> values;
231 vecf_domain() noexcept { }
232 vecf_domain(
const vecf_domain& other) noexcept
233 :
min{std::move(other.min)}
234 ,
max{std::move(other.max)}
235 , values{std::move(other.values)}
239 vecf_domain(vecf_domain&& other) noexcept
240 :
min{std::move(other.min)}
241 ,
max{std::move(other.max)}
242 , values{std::move(other.values)}
246 vecf_domain& operator=(
const vecf_domain& other)
250 values = other.values;
254 vecf_domain& operator=(vecf_domain&& other) noexcept
256 min = std::move(other.min);
257 max = std::move(other.max);
258 values = std::move(other.values);
263 const std::array<std::optional<float>, N>& v1,
264 const std::array<std::optional<float>, N>& v2)
270 vecf_domain(
const std::array<float, N>& v1,
const std::array<float, N>& v2)
272 for(std::size_t i = 0; i < N; i++)
279 const std::array<std::optional<float>, N>& v1,
280 const std::array<std::optional<float>, N>& v2,
281 const std::array<ossia::flat_set<float>, N>& vals)
288 const std::array<std::optional<float>, N>& v1,
289 const std::array<std::optional<float>, N>& v2,
290 std::array<ossia::flat_set<float>, N>&& vals)
293 , values{std::move(vals)}
297 friend bool operator==(
const vecf_domain& lhs,
const vecf_domain& rhs)
299 return lhs.min == rhs.min && lhs.max == rhs.max && lhs.values == rhs.values;
301 friend bool operator!=(
const vecf_domain& lhs,
const vecf_domain& rhs)
303 return lhs.min != rhs.min || lhs.max != rhs.max || lhs.values != rhs.values;
308 struct OSSIA_EXPORT domain_base<
ossia::value>
311 std::optional<value_type>
min;
312 std::optional<value_type>
max;
313 std::vector<value_type> values;
315 domain_base() noexcept { }
316 domain_base(
const domain_base<value_type>& other) noexcept
317 :
min{std::move(other.min)}
318 ,
max{std::move(other.max)}
319 , values{std::move(other.values)}
323 domain_base(domain_base<value_type>&& other) noexcept
324 :
min{std::move(other.min)}
325 ,
max{std::move(other.max)}
326 , values{std::move(other.values)}
330 domain_base& operator=(
const domain_base& other)
334 values = other.values;
338 domain_base& operator=(domain_base&& other) noexcept
340 min = std::move(other.min);
341 max = std::move(other.max);
342 values = std::move(other.values);
346 domain_base(
const value_type& v1,
const value_type& v2)
351 domain_base(value_type&& v1, value_type&& v2)
357 const value_type& v1,
const value_type& v2,
const std::vector<value_type>& vals)
363 domain_base(value_type&& v1, value_type&& v2, std::vector<value_type>&& vals)
366 , values{std::move(vals)}
371 operator==(
const domain_base<ossia::value>& lhs,
const domain_base<ossia::value>& rhs)
373 return lhs.min == rhs.min && lhs.max == rhs.max && lhs.values == rhs.values;
376 operator!=(
const domain_base<ossia::value>& lhs,
const domain_base<ossia::value>& rhs)
378 return lhs.min != rhs.min || lhs.max != rhs.max || lhs.values != rhs.values;
The value class.
Definition: value.hpp:173
constexpr OSSIA_INLINE 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
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