view m-toolbox/classes/@timespan/setEndT.m @ 39:11e3ed9d2115
database-connection-manager
Implement databases listing in database connection dialog
author
Daniele Nicolodi <nicolodi@science.unitn.it>
date
Mon, 05 Dec 2011 16:20:06 +0100 (2011-12-05)
parents
f0afece42f48
children
line source
+ − % SETENDT sets the 'endT' property of the timespan objects.
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ − %
+ − % DESCRIPTION: SETENDT sets the 'endT' property of the timespan objects.
+ − %
+ − % CALL: objs.setEndT(val);
+ − % objs.setEndT(val1, val2);
+ − % objs.setEndT(plist('endt', val));
+ − % objs = objs.setEndT(val);
+ − %
+ − % INPUTS: objs: Can be a vector, matrix, list, or a mix of them.
+ − % val: String or numeric values
+ − % 1. Single string e.g. '14:00:00'
+ − % Each timespan object in objs get this value.
+ − % 2. Single string in a cell-array e.g. {12345}
+ − % Each timespan object in objs get this value.
+ − % 3. cell-array with the same number of strings as in objs
+ − % e.g. {'14:00:00', 123, '15:00:00'} and 3 timespan objects in objs
+ − % Each timespan objects in objs get its corresponding
+ − % value from the cell-array
+ − %
+ − % <a href="matlab:utils.helper.displayMethodInfo('timespan', 'setEndT')">Parameters Description</a>
+ − %
+ − % VERSION: $Id: setEndT.m,v 1.14 2011/09/16 11:40:35 hewitson Exp $
+ − %
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ −
+ − function varargout = setEndT(varargin)
+ −
+ − % Check if this is a call from a class method
+ − callerIsMethod = utils.helper.callerIsMethod;
+ −
+ − if callerIsMethod
+ − as = varargin{1};
+ − values = varargin(2:end);
+ −
+ − else
+ − % 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.PROC3, '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 timespan objects
+ − [as, ts_invars, rest] = utils.helper.collect_objects(varargin(:), 'timespan', in_names);
+ − [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist');
+ −
+ − % Define property name
+ − pName = 'endT';
+ −
+ − % Get values for the timespan objects
+ − [as, values] = processSetterValues(as, pls, rest, pName);
+ −
+ − % Combine input plists and default PLIST
+ − pls = combine(pls, getDefaultPlist());
+ −
+ − end % callerIsMethod
+ −
+ − % Decide on a deep copy or a modify
+ − bs = copy(as, nargout);
+ −
+ − % Loop over timespan objects
+ − for j=1:numel(bs)
+ −
+ − %%% If the time is a string then convert the string into a time-object.
+ − tt = values{1};
+ − if ischar(tt)
+ − tt = time(tt);
+ − elseif isnumeric(tt)
+ − tt = time(tt);
+ − end
+ −
+ − bs(j).endT = tt;
+ − if ~callerIsMethod
+ − plh = pls.pset(pName, values{j});
+ − bs(j).addHistory(getInfo('None'), plh, ts_invars(j), bs(j).hist);
+ − end
+ − end
+ −
+ − % Set output
+ − if nargout == numel(bs)
+ − % List of outputs
+ − for ii = 1:numel(bs)
+ − varargout{ii} = bs(ii);
+ − end
+ − else
+ − % Single output
+ − varargout{1} = bs;
+ − end
+ − end
+ −
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ − % Local Functions %
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ − %--------------------------------------------------------------------------
+ − % Get Info Object
+ − %--------------------------------------------------------------------------
+ − function ii = getInfo(varargin)
+ −
+ − if nargin == 1 && strcmpi(varargin{1}, 'None')
+ − sets = {};
+ − pl = [];
+ − else
+ − sets = {'Default'};
+ − pl = getDefaultPlist;
+ − end
+ − % Build info object
+ − ii = minfo(mfilename, mfilename('class'), 'ltpda', utils.const.categories.helper, '$Id: setEndT.m,v 1.14 2011/09/16 11:40:35 hewitson Exp $', sets, pl);
+ − end
+ −
+ − %--------------------------------------------------------------------------
+ − % Get Default Plist
+ − %--------------------------------------------------------------------------
+ − function plout = getDefaultPlist()
+ − persistent pl;
+ − if exist('pl', 'var')==0 || isempty(pl)
+ − pl = buildplist();
+ − end
+ − plout = pl;
+ − end
+ −
+ − function pl = buildplist()
+ − pl = plist({'endT', 'End time of the time span.'}, paramValue.EMPTY_STRING);
+ − end