2 #include <State/Value.hpp>
3 #include <State/ValueConversion.hpp>
5 #include <Process/TypeConversion.hpp>
7 #include <LocalTree/BaseCallbackWrapper.hpp>
9 #include <score/tools/Debug.hpp>
10 #include <score/tools/std/Invoke.hpp>
12 #include <ossia/network/base/node.hpp>
14 #include <QApplication>
18 using qt_property_converter_T
19 = ossia::qt_property_converter<std::remove_const_t<std::remove_reference_t<T>>>;
21 template <
typename Property>
24 using model_t =
typename Property::model_type;
25 using param_t =
typename Property::param_type;
27 using converter_t = ossia::qt_property_converter<typename Property::param_type>;
28 PropertyWrapper(ossia::net::parameter_base& param_addr, model_t& obj, QObject* context)
33 &m_model, Property::notify, context,
35 auto newVal = converter_t::convert((m_model.*Property::get)());
38 auto res = addr.value();
42 addr.set_value_quiet(newVal);
50 Qt::QueuedConnection);
52 addr.set_value(converter_t::convert((m_model.*Property::get)()));
54 = addr.add_callback([=, m = QPointer<model_t>{&m_model}](
const ossia::value& v) {
55 ossia::qt::run_async(qApp, [m, v] {
57 ((*m).*Property::set)(::State::convert::value<param_t>(v));
63 template <
typename Property,
typename Object>
64 auto add_property(ossia::net::node_base& n, Object& obj, QObject* context)
66 SCORE_ASSERT(!std::string_view(Property::name).empty());
67 constexpr
const auto t
68 = ossia::qt_property_converter<typename Property::param_type>::val;
69 auto node = n.create_child(Property::name);
72 auto addr = node->create_parameter(t);
75 addr->set_access(ossia::access_mode::BI);
76 return std::make_unique<PropertyWrapper<Property>>(*addr, obj, context);
79 template <
typename Property,
typename Object>
81 ossia::net::node_base& n, Object& obj,
const std::string& name, QObject* context)
83 SCORE_ASSERT(!name.empty());
84 constexpr
const auto t
85 = ossia::qt_property_converter<typename Property::param_type>::val;
86 auto node = n.create_child(name);
89 auto addr = node->create_parameter(t);
92 addr->set_access(ossia::access_mode::BI);
93 return std::make_unique<PropertyWrapper<Property>>(*addr, obj, context);
Definition: BaseCallbackWrapper.hpp:11
Local tree provides a way to extend the tree given through the Engine::Network::LocalDevice.
Definition: BaseCallbackWrapper.hpp:9
Definition: Property.hpp:23