Loading...
Searching...
No Matches
SetProperty.hpp
1#pragma once
2#include <Process/TypeConversion.hpp>
3
4#include <LocalTree/BaseCallbackWrapper.hpp>
5
6#include <score/tools/Debug.hpp>
7#include <score/tools/std/Invoke.hpp>
8
9#include <ossia/network/base/node.hpp>
10
11namespace LocalTree
12{
13template <typename T, typename SetFun>
15{
16 SetFun setFun;
17
18 SetPropertyWrapper(ossia::net::parameter_base& param_addr, SetFun prop)
19 : BaseCallbackWrapper{param_addr}
20 , setFun{prop}
21 {
22 callbackIt = addr.add_callback([this](const ossia::value& v) {
23 ossia::qt::run_async(qApp, [this, v] { setFun(v); });
24 });
25
26 // addr.set_value(typename ossia::qt_property_converter<T>::type{});
27 }
28};
29
30template <typename T, typename Callback>
31auto make_setProperty(ossia::net::parameter_base& addr, Callback prop)
32{
33 return std::make_unique<SetPropertyWrapper<T, Callback>>(addr, prop);
34}
35
36template <typename T, typename Callback>
37auto add_setProperty(ossia::net::node_base& n, const std::string& name, Callback cb)
38{
39 constexpr const auto t = ossia::qt_property_converter<T>::val;
40 auto node = n.create_child(name);
41 SCORE_ASSERT(node);
42
43 auto addr = node->create_parameter(t);
44 SCORE_ASSERT(addr);
45
46 addr->set_access(ossia::access_mode::SET);
47
48 return make_setProperty<T>(*addr, cb);
49}
50}
Definition BaseCallbackWrapper.hpp:11
Local tree provides a way to extend the tree given through the Engine::Network::LocalDevice.
Definition BaseCallbackWrapper.hpp:9
Definition SetProperty.hpp:15