this repo has no description
1use crate::{
2 runtime::nodes::RuntimeNode,
3 structs::{nodes::Node, parameter_types::ParameterType},
4};
5
6pub struct OSCTrigger {
7 outputs: Vec<Vec<(String, isize, isize)>>,
8 inputs: Vec<Option<(String, isize, isize)>>,
9
10 address: Option<String>
11}
12
13impl OSCTrigger {
14 pub fn new(node: Node) -> Box<Self> {
15 let value = &node.statics[0].value;
16
17 Box::new(Self {
18 outputs: node.outputs.iter().map(|x| {
19 x.connections.iter()
20 .map(|x| (x.node.clone(), x.index, x.value_type)).collect()}).collect(),
21
22 inputs: node.inputs.iter().map(|x| {
23 let y = x.connections.get(0);
24 if let Some(y) = y{
25 Some((y.node.clone(), y.index, y.value_type))
26 } else{
27 None
28 }
29 }).collect(),
30
31 address: if value.is_null() {
32 None
33 } else {
34 Some(value.as_str().unwrap().to_owned())
35 },
36 })
37 }
38}
39
40impl RuntimeNode for OSCTrigger {
41 fn outputs(&self) -> Vec<Vec<(String, isize, isize)>> {
42 self.outputs.clone()
43 }
44
45 fn inputs(&self) -> Vec<Option<(String, isize, isize)>> {
46 self.inputs.clone()
47 }
48
49 fn execute(&mut self, mut args: Vec<ParameterType>) -> Vec<ParameterType> {
50 if args.len() == 0{ return args }
51
52 let execute = if let Some(internal_address) = &self.address {
53 if let Ok(address) = args[0].as_string() {
54 address == *internal_address
55 } else{
56 false
57 }
58 } else{
59 false
60 };
61
62 args[0] = ParameterType::Flow(execute);
63 args
64 }
65
66 fn is_entrypoint(&self) -> bool {
67 true
68 }
69}