view m-toolbox/classes/@timespan/double.m @ 1:2014ba5b353a database-connection-manager

Remove old code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Sat, 03 Dec 2011 18:13:55 +0100
parents f0afece42f48
children
line wrap: on
line source

% DOUBLE overloads double() function for timespan objects.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: DOUBLE overloads double() function for timespan objects.
%              The result is the number of seconds spanned by the object
%
% CALL:        d = double(t);
%
% <a href="matlab:utils.helper.displayMethodInfo('timespan', 'double')">Parameters Description</a>
%
% VERSION:     $Id: double.m,v 1.7 2011/04/08 08:56:37 hewitson Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = double(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.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 time objects and plists
  ts = utils.helper.collect_objects(varargin(:), 'timespan', in_names);
  
  % go through timespan objects
  td = [];
  for jj = 1:numel(ts)
    td(jj) = (ts(jj).endT.utc_epoch_milli - ts(jj).startT.utc_epoch_milli) / 1000.0;
  end
  
  % Set output
  if nargout == numel(ts)
    % List of outputs
    for ii = 1:numel(ts)
      varargout{ii} = td(ii);
    end
  else
    % Single output
    varargout{1} = td;
  end
  
end

%--------------------------------------------------------------------------
% 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, 'timespan', 'ltpda', utils.const.categories.internal, '$Id: double.m,v 1.7 2011/04/08 08:56:37 hewitson Exp $', sets, pl);
  ii.setModifier(false);
  ii.setOutmin(0);
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.EMPTY_PLIST;
end