OSSIA
Open Scenario System for Interactive Application
dataflow.hpp
1 #pragma once
2 #include <ossia/dataflow/dataflow_fwd.hpp>
3 #include <ossia/network/base/node.hpp>
4 #include <ossia/network/common/path.hpp>
5 
6 #include <vector>
7 
8 namespace ossia
9 {
10 struct do_nothing_for_nodes
11 {
12  void operator()(ossia::net::node_base* node, bool) const noexcept { }
13 };
14 
15 template <typename Fun, typename NodeFun, typename DeviceList_T>
16 bool apply_to_destination(
17  const destination_t& address, const DeviceList_T& devices, Fun f, NodeFun nf)
18 {
19  switch(address.which().index())
20  {
21  // ossia::net::parameter_base*
22  case destination_t::index_of<ossia::net::parameter_base*>().index(): {
23  f(*address.target<ossia::net::parameter_base*>(), true);
24  return true;
25  }
26 
27  // ossia::traversal::path
28  case destination_t::index_of<ossia::traversal::path>().index(): {
29  std::vector<ossia::net::node_base*> roots{};
30 
31  for(auto n : devices)
32  roots.push_back(&n->get_root_node());
33 
34  auto& p = *address.target<ossia::traversal::path>();
35  ossia::traversal::apply(p, roots);
36 
37  const bool unique = roots.size() == 1;
38  for(auto n : roots)
39  if(auto addr = n->get_parameter())
40  f(addr, unique);
41  else
42  nf(n, unique);
43  return unique;
44  }
45 
46  // ossia::net::node_base*
47  case destination_t::index_of<ossia::net::node_base*>().index(): {
48  nf(*address.target<ossia::net::node_base*>(), true);
49  return true;
50  }
51  default: {
52  return true;
53  }
54  }
55 }
56 }
The node_base class.
Definition: network/base/node.hpp:48
The parameter_base class.
Definition: ossia/network/base/parameter.hpp:48
Definition: git_info.h:7