2 #include <ossia/dataflow/exec_state_facade.hpp>
3 #include <ossia/dataflow/execution_state.hpp>
4 #include <ossia/detail/algorithms.hpp>
5 #include <ossia/network/common/path.hpp>
7 #include <AvndProcesses/Alphanum.hpp>
8 #include <halp/controls.hpp>
9 #include <halp/meta.hpp>
22 ossia::exec_state_facade ossia_state;
23 std::optional<ossia::traversal::path> m_path;
24 std::vector<ossia::net::node_base*> roots;
32 if(!p.ossia_state.impl)
41 p.m_path = ossia::traversal::make_path(value);
50 auto& p = *current_object;
51 ossia::execution_state& st = *p.ossia_state.impl;
52 const auto& rdev = st.exec_devices();
60 if(devices_observed.find(dev) == devices_observed.end())
62 devices_observed.insert(dev);
63 dev->on_node_created.connect<&PatternSelector::mark_dirty>(
this);
64 dev->on_node_removing.connect<&PatternSelector::mark_dirty>(
this);
66 p.roots.push_back(&dev->get_root_node());
69 for(
auto it = devices_observed.begin(); it != devices_observed.end();)
71 if(!ossia::contains(rdev, *it))
72 it = devices_observed.erase(it);
77 ossia::traversal::apply(*p.m_path, p.roots);
79 p.roots.begin(), p.roots.end(),
80 [](ossia::net::node_base* lhs, ossia::net::node_base* rhs) {
81 return doj::alphanum_compare{}(lhs->osc_address(), rhs->osc_address());
83 devices_dirty =
false;
89 for(
auto* dev : devices_observed)
91 dev->on_node_created.disconnect<&PatternSelector::mark_dirty>(
this);
92 dev->on_node_removing.disconnect<&PatternSelector::mark_dirty>(
this);
96 void mark_dirty(ossia::net::node_base&) { devices_dirty =
true; }
98 PatternObject* current_object{};
99 bool devices_dirty =
false;
101 ossia::flat_set<ossia::net::device_base*> devices_observed;
106 halp_meta(name,
"Pattern applier")
107 halp_meta(author,
"ossia team")
108 halp_meta(category,
"Control/Data processing")
109 halp_meta(description,
"Send a message to all nodes matching a pattern")
110 halp_meta(c_name,
"avnd_pattern_apply")
111 halp_meta(uuid,
"44a55ee1-c2c9-43d5-a655-8eaedaff394c")
112 halp_meta(manual_url,
"https://ossia.io/score-docs/processes/pattern-applier.html#pattern-applier")
116 halp::val_port<
"Input", ossia::value> input;
130 auto process = [
this](
const std::vector<ossia::value>& vec) {
131 const auto N = std::min(roots.size(), vec.size());
132 for(std::size_t i = 0; i < N; i++)
134 if(
auto p = roots[i]->get_parameter())
136 p->push_value(vec[i]);
141 if(
auto vvec = inputs.input.value.target<std::vector<ossia::value>>())
147 process(ossia::convert<std::vector<ossia::value>>(inputs.input.value));