1 from Tools.CList import CList
4 # Render Converter Converter Source
6 # a bidirectional connection
9 self.downstream_elements = CList()
10 self.upstream_elements = CList()
14 def connectDownstream(self, downstream):
15 self.downstream_elements.append(downstream)
16 if self.master is None:
17 self.master = downstream
19 def connectUpstream(self, upstream):
20 self.upstream_elements.append(upstream)
21 self.source = upstream # for single-source elements (i.e., most of them.)
24 def connect(self, upstream):
25 self.connectUpstream(upstream)
26 upstream.connectDownstream(self)
28 # we disconnect from down to up
29 def disconnectAll(self):
30 # we should not disconnect from upstream if
31 # there are still elements depending on us.
32 assert len(self.downstream_elements) == 0, "there are still downstream elements left"
34 # disconnect all upstream elements from us
35 for upstream in self.upstream_elements:
36 upstream.disconnectDownstream(self)
38 def disconnectDownstream(self, downstream):
39 self.downstream_elements.remove(downstream)
40 if self.master == downstream:
43 if len(self.downstream_elements) == 0:
46 # default action: push downstream
48 self.downstream_elements.changed()