OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
for_each_port.hpp
1#pragma once
2#include <ossia/dataflow/graph_node.hpp>
3#include <ossia/dataflow/port.hpp>
4namespace ossia
5{
6template <typename Fin>
7void for_each_inlet(const ossia::graph_node& node, Fin&& fin) noexcept
8{
9 for(auto port : node.root_inputs())
10 {
11 fin(*port);
12 for(auto sub : port->child_inlets)
13 {
14 fin(*sub);
15 }
16 }
17 for(auto port : node.root_outputs())
18 {
19 for(auto sub : port->child_inlets)
20 {
21 fin(*sub);
22 }
23 }
24}
25
26template <typename Fin>
27bool any_of_inlet(const ossia::graph_node& node, Fin&& fin) noexcept
28{
29 for(auto port : node.root_inputs())
30 {
31 if(fin(*port))
32 return true;
33
34 for(auto sub : port->child_inlets)
35 {
36 if(fin(*sub))
37 return true;
38 }
39 }
40 for(auto port : node.root_outputs())
41 {
42 for(auto sub : port->child_inlets)
43 {
44 if(fin(*sub))
45 return true;
46 }
47 }
48 return false;
49}
50
51template <typename Fin>
52bool all_of_inlet(const ossia::graph_node& node, Fin&& fin) noexcept
53{
54 for(auto port : node.root_inputs())
55 {
56 if(!fin(*port))
57 return false;
58
59 for(auto sub : port->child_inlets)
60 {
61 if(!fin(*sub))
62 return false;
63 }
64 }
65 for(auto port : node.root_outputs())
66 {
67 for(auto sub : port->child_inlets)
68 {
69 if(!fin(*sub))
70 return false;
71 }
72 }
73 return true;
74}
75
76template <typename Fout>
77void for_each_outlet(const ossia::graph_node& node, Fout&& fout) noexcept
78{
79 for(auto port : node.root_outputs())
80 {
81 fout(*port);
82 }
83}
84
85template <typename Fout>
86bool any_of_outlet(const ossia::graph_node& node, Fout&& fout) noexcept
87{
88 for(auto port : node.root_outputs())
89 {
90 if(fout(*port))
91 return true;
92 }
93 return false;
94}
95
96template <typename Fout>
97bool all_of_outlet(const ossia::graph_node& node, Fout&& fout) noexcept
98{
99 for(auto port : node.root_outputs())
100 {
101 if(!fout(*port))
102 return false;
103 }
104 return true;
105}
106
107}
Definition git_info.h:7