1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! # Inspection
//!
//! Metadata from the structs in this module can be used to visualise and/or
//! manipulate a graph based on the whole graph structure.
use crate::graph::NodeId;
/// The metadata of a Graph
// TODO: Feedback edges
#[derive(Debug, Clone)]
pub struct GraphInspection {
/// All the nodes currently in the Graph (including those pending removal)
pub nodes: Vec<NodeInspection>,
/// Nodes that are not connected to any graph output in any chain
pub unconnected_nodes: Vec<usize>,
/// Node indices that are in the Graph, but will be removed as soon as it is safe.
pub nodes_pending_removal: Vec<usize>,
/// The indices of nodes connected to the graph output(s)
pub graph_output_input_edges: Vec<EdgeInspection>,
/// Number of inputs to the graph
pub num_inputs: usize,
/// Number of outputs from the graph
pub num_outputs: usize,
/// The ID of the graph
pub graph_id: crate::graph::GraphId,
}
impl GraphInspection {
/// Create an empty GraphInspection
pub fn empty() -> Self {
Self {
nodes: vec![],
unconnected_nodes: vec![],
nodes_pending_removal: vec![],
graph_output_input_edges: vec![],
num_inputs: 0,
num_outputs: 0,
graph_id: 0,
}
}
}
#[derive(Debug, Clone)]
/// Metadata about a node in a graph
pub struct NodeInspection {
/// The name of the node (usually the name of the Gen inside it)
pub name: String,
/// The address of the node, useable to schedule changes to the node or free it
pub address: NodeId,
/// The names of the inputs channels to the node
pub input_channels: Vec<String>,
/// The names of the output channels from the node
pub output_channels: Vec<String>,
/// Edges going into this node
pub input_edges: Vec<EdgeInspection>,
/// If this node is a Graph, this contains the inspection of the inner graph
pub graph_inspection: Option<GraphInspection>,
}
#[derive(Debug, Clone, Copy)]
/// Metadata for an edge.
#[allow(missing_docs)]
pub struct EdgeInspection {
pub source: EdgeSource,
pub from_index: usize,
pub to_index: usize,
}
#[derive(Debug, Clone, Copy)]
/// Edge source type used for inspection. The index of a node is only valid for that specific GraphInspection.
#[allow(missing_docs)]
pub enum EdgeSource {
Node(usize),
Graph,
}