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
use super::external_connections::ExternalConnections;
use super::graph_connections::GraphConnections;
use super::refresh::Refresh;
use crate::computed::graph_id::GraphId;
use std::collections::BTreeSet;
pub struct Graph {
pub(crate) refresh: Refresh,
pub(crate) connections: GraphConnections,
pub(crate) external_connections: ExternalConnections,
}
impl Graph {
pub fn new() -> Graph {
let external_connections = ExternalConnections::default();
let refresh: Refresh = Refresh::new();
Graph {
refresh,
connections: GraphConnections::new(),
external_connections,
}
}
pub(crate) fn remove_client(&self, client_id: GraphId) {
self.set_parent_for_client(client_id, BTreeSet::new());
}
pub(crate) fn push_context(&self, client_id: GraphId, parents: BTreeSet<GraphId>) {
self.set_parent_for_client(client_id, parents);
}
pub(crate) fn set_parent_for_client(
&self,
client_id: GraphId,
parents_list: BTreeSet<GraphId>,
) {
let edge_list = self
.connections
.set_parent_for_client(client_id, parents_list);
for (id, active) in edge_list {
self.external_connections.set_connection(id, active);
if !active {
self.refresh.clear_cache(&id);
}
// TODO - Keeping this comment here for a while
// match id.get_type() {
// GraphIdKind::Value => {
// self.external_connections.set_connection(id, active);
// }
// GraphIdKind::Computed => {
// self.external_connections.set_connection(id, active);
// if active {
// } else {
// self.refresh.clear_cache(&id);
// }
// }
// GraphIdKind::Client => {
// if active {
// } else {
// self.refresh.clear_cache(&id);
// }
// }
// }
}
}
}