1 from Tools.CList import CList
4 # Render Converter Converter Source
6 # a bidirectional connection
9 self.downstream_elements = CList()
13 def connectDownstream(self, downstream):
14 self.downstream_elements.append(downstream)
15 if self.master is None:
16 self.master = downstream
18 def connectUpstream(self, upstream):
19 assert self.source is None
20 self.source = upstream
23 def connect(self, upstream):
24 self.connectUpstream(upstream)
25 upstream.connectDownstream(self)
27 # we disconnect from down to up
28 def disconnectAll(self):
29 # we should not disconnect from upstream if
30 # there are still elements depending on us.
31 assert len(self.downstream_elements) == 0, "there are still downstream elements left"
32 self.source.disconnectDownstream(self)
34 def disconnectDownstream(self, downstream):
35 self.downstream_elements.remove(downstream)
36 if self.master == downstream:
39 if len(self.downstream_elements) == 0:
42 # default action: push downstream
43 def changed(self, *args, **kwargs):
44 self.downstream_elements.changed(*args, **kwargs)
46 def reconnectUpstream(self, new_upstream):
47 assert self.source is not None
48 self.source = new_upstream