OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
value_bounding.hpp
1#pragma once
2#include <ossia/network/domain/domain.hpp>
3#include <ossia/network/value/value.hpp>
4
5namespace ossia
6{
7
8template <typename Value_T>
9inline ossia::value
10bound_value(const ossia::domain& dom, Value_T&& base_val, ossia::bounding_mode mode)
11{
12 if(dom)
13 {
14 auto res = ossia::apply_domain(dom, mode, std::forward<Value_T>(base_val));
15 if(res.valid())
16 return res;
17 else
18 return {};
19 }
20 else
21 {
22 return std::forward<Value_T>(base_val);
23 }
24}
25
26template <typename Addr_T>
27inline ossia::value bound_value(const Addr_T& addr, const ossia::value& v)
28{
29 auto val = bound_value(addr.get_domain(), v, addr.get_bounding());
30 auto filtered = addr.filter_value(val);
31 if(!filtered)
32 return val;
33 return {};
34}
35
36template <typename Addr_T>
37inline ossia::value bound_value(const Addr_T& addr, ossia::value&& v)
38{
39 auto val = bound_value(addr.get_domain(), std::move(v), addr.get_bounding());
40 auto filtered = addr.filter_value(val);
41 if(!filtered)
42 return val;
43 return {};
44}
45
46}
The value class.
Definition value.hpp:173
Definition git_info.h:7
bounding_mode
Address behaviors at crossing domain boundaries.
Definition parameter_properties.hpp:56
domain A domain of values
Definition domain_base.hpp:23