Mercurial > hg > ishara
view arrows/@aswitch/construct.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | 672052bd81f8 |
children |
line wrap: on
line source
function u=construct(s,sizes_in) nin=nargin(s.base); nout=nargout(s.base); running=0; current_arrow = s.base; current_unit = construct(current_arrow,sizes_in(1:nin)); current_proc = current_unit.process; u=mkunit(s); u.sizes_out = current_unit.sizes_out; u.starting = @starting; u.stopping = @stopping; u.dispose = @dispose; u.get_state = @get_state; u.set_state = @set_state; if nin==1 && nout==1, u.process=@proc_11; elseif nin==1 && nout==0, u.process=@proc_10; elseif nin==0 && nout==1, u.process=@proc_01; else, u.process=@proc_nn; end function starting, current_unit.starting(); running=1; end function stopping, current_unit.stopping(); running=0; end function dispose, current_unit.dispose(); end function s=get_state, s={current_arrow, current_unit.get_state()}; end function set_state(s), replace_running_unit(s{1},s{2}); end function y1=proc_11(x1,x), if ~isempty(x), replace_running_unit(x{1}); end y1=current_proc(x1); end function x=proc_10(x1,x), if ~isempty(x), replace_running_unit(x{1}); end current_proc(x1); end function y1=proc_01(x), if ~isempty(x), replace_running_unit(x{1}); end y1=current_proc(); end function varargout=proc_nn(varargin) x=varargin{end}; if ~isempty(x), replace_running_unit(x{1}); end [varargout{1:nout}]=current_proc(varargin{1:nin}); end function replace_running_unit(a,state) if running current_unit.stopping(); current_unit.dispose(); end current_arrow=a; current_unit=construct(a,sizes_in(1:nin)); current_proc=current_unit.process; if nargin>1, current_unit.set_state(state); end if running, current_unit.starting(); end end end