view m-toolbox/classes/+utils/@models/getDefaultPlist.m @ 40:977eb37f31cb database-connection-manager

User friendlier errors from utils.mysql.connect
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 18:04:03 +0100
parents f0afece42f48
children
line wrap: on
line source

% GETDEFAULTPLIST returns a default plist for the model 
% 
% CALL: utils.models.functionForVersion(@getModelDescription, @versionTable)
% CALL: utils.models.functionForVersion(@getModelDescription, @versionTable, version, @getFileVersion)
% 
function pl = getDefaultPlist(varargin)
    
  getModelDescription = varargin{1};
  versionTable = varargin{2};
  options = {};
  if nargin > 2
    if ischar(varargin{3})
      options = varargin(3);
    else
      options = varargin{3};
    end
  end
  
  % default plist for all model versions
  vt = versionTable();
  idx = 1; % we take the first version as default
  versions = vt(1:2:end);
  if numel(options)>=1 && ischar(options{1})
    idx = find(strcmp(options{1}, versions));
    if ~utils.helper.ismember(options{1}, versions)
      error('requested version does not exist');
    end
  end
  version = versions{idx};
  pl = plist({'VERSION', 'Model version'}, {idx, vt(1:2:end), paramValue.SINGLE});
    
  
  % add plist for this version
  fcn = utils.models.functionForVersion(getModelDescription, versionTable, version);
  pl.combine(fcn('plist'));
  pl.setName(sprintf('Parameter List for version: %s', version));
end