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