Mercurial > hg > ltpda
view m-toolbox/m/etc/class_method_template.m @ 50:7d2e2e065cf1 database-connection-manager
Update unit tests
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 07 Dec 2011 17:24:37 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line source
% FOO description for function 'foo' in one line. Necessary for lookfor functionality. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % DESCRIPTION: FOO detailed description for the function 'foo' % % CALL: foo(a) % [a, b] = foo(a,pl) % % INPUTS: a - analysis object(s) % pl - parameter list(s) % % OUTPUTS: a - ??? % b - ??? % % <a href="matlab:web(CLASS.getInfo('foo').tohtml, '-helpbrowser')">Parameter Sets</a> % % VERSION: $Id: class_method_template.m,v 1.3 2011/05/22 22:30:32 mauro Exp $ % % SEE ALSO: ao/cos, ao/tan, ao/asin, acos, atan % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% REMARK: This is a method template for classes which are derived from the %%% ltpda_uoh class. function varargout = foo(varargin) %%% Check if this is a call for parameters if utils.helper.isinfocall(varargin{:}) varargout{1} = getInfo(varargin{3}); return end import utils.const.* utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename); %%% Collect input variable names in_names = cell(size(varargin)); for ii = 1:nargin,in_names{ii} = inputname(ii);end %%% Collect all AOs [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); pli = utils.helper.collect_objects(varargin(:), 'plist', in_names); %%% Decide on a deep copy or a modify %%% REMARK: If you create a new AO (call the constructor) then %%% it is not necessay to copy the input-AOs !!! bs = copy(as, nargout); %%% Combine plists pl = combine(pli, getDefaultPlist); %%% go through analysis objects for kk = 1:numel(bs) %%% store the input history inhist = bs(kk).hist; %%%%%%%%%% get x- and y-data %%%%%%%%%% %%%% REMARK: If you get the data in this way then are x and y always %%%% column vectors. x = bs(kk).x; y = bs(kk).y; dx = bs(kk).dx; dy = bs(kk).dy; %%%%%%%%%% some calculations %%%%%%%%%% bs(kk).setX(some_new_X_data); bs(kk).setY(some_new_Y_data); bs(kk).setFs(new_fs); bs(kk).setXunits(new_xunits); bs(kk).setYunits(new_yunits); %%% Set Name bs(kk).setName('new name'); %%% A better way to set the name bs(kk).name = 'new name'; %%% Add History bs(kk).addHistory(getInfo('Special set or all sets? You decide.'), pl, ao_invars(kk), inhist); end % Set output varargout = utils.helper.setoutputs(nargout, bs); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Local Functions % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % FUNCTION: getInfo % % DESCRIPTION: Get Info Object % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function ii = getInfo(varargin) if nargin == 1 && strcmpi(varargin{1}, 'None') sets = {}; pls = []; elseif nargin == 1 && ~isempty(varargin{1}) && ischar(varargin{1}) sets{1} = varargin{1}; pls = getDefaultPlist(sets{1}); else sets = {'set1', 'set2', 'set3'}; pls = []; for kk=1:numel(sets) pls = [pls getDefaultPlist(sets{kk})]; end end % Build info object ii = minfo(mfilename, 'CLASS', '', utils.const.categories.DEFINE_ME, '$Id: class_method_template.m,v 1.3 2011/05/22 22:30:32 mauro Exp $', sets, pls); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % FUNCTION: getDefaultPlist % % DESCRIPTION: Get Default Plist % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function plo = getDefaultPlist(set) switch set case 'set1' plo = plist(); % A p = param({'a','This is the documentation for the key ''A''.'}, paramValue.EMPTY_DOUBLE); plo.append(p); case 'set2' plo = plist(); % A p = param({'a','This is the documentation for the key ''A''.'}, paramValue.DOUBLE_VALUE(1)); plo.append(p); % B p = param({'b','This is the documentation for the key ''B''.'}, paramValue.DOUBLE_VALUE(2)); plo.append(p); case 'set3' plo = plist(); % KEY p = param({'key','This is the documentation for the key ''key''.'}, paramValue.STRING_VALUE('val') ); plo.append(p); otherwise error('### Unknown default plist for the set [%s]', set) end end