diff sinks/@sinkcat/construct.m @ 0:672052bd81f8

Initial partial import.
author samer
date Wed, 19 Dec 2012 22:38:28 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sinks/@sinkcat/construct.m	Wed Dec 19 22:38:28 2012 +0000
@@ -0,0 +1,27 @@
+function s=construct(sig)
+	sc=construct(sig.sinks{1});
+	sx=sig.sinks(2:end);
+
+	s.start   = @start;
+	s.stop    = @stop;
+	s.dispose = @dispose;
+	s.writer  = @writer;
+
+	function start, sc.start(); end
+	function stop, sc.stop(); end
+	function dispose, sc.dispose(); end 
+
+	function r=writer(n)
+		rc=sc.writer(n);
+		r = @next;
+		function rem=next(x)
+			rem=rc(x);
+			while rem>0 && ~isempty(sx) % current signal exhausted, try next
+				sc.dispose();
+				sc=construct(sx{1}); sx=sx(2:end);
+				rem=sinkwriten(sc,n,x(end-rem+1:end));
+				rc=sc.writer(n);
+			end
+		end
+	end
+end