view m-toolbox/classes/+utils/@models/mainFnc.m @ 33:5e7477b94d94 database-connection-manager

Add known repositories list to LTPDAPreferences
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children bc767aaa99a8
line wrap: on
line source

% MAINFNC is the main function call for all built-in models.
% 
% CALL:
%     varargout = mainFnc(inputs, modelFilename, getModelDescription, getModelDocumentation, getVersion, versionTable)
% 
% A typical call from the built-in model main function will look like:
% 
%   varargout = utils.models.mainFnc(varargin(:), ...
%     mfilename, ...
%     @getModelDescription, ...
%     @getModelDocumentation, ...
%     @getVersion, ...
%     @versionTable);
% 
% INPUTS:
%                 inputs - cell-array of inputs to the built-in model
%          modelFilename - the full filename of the model (typically you use mfilename)
%    getModelDescription - a function handle to the getModelDescription function
%  getModelDocumentation - a function handle to the getModelDocumentation function
%             getVersion - a function handle to the getVersion function
%           versionTable - a function handle to the versionTable function
% 
% VERSION: $Id: mainFnc.m,v 1.3 2011/04/29 14:25:14 hewitson Exp $
% 
% 
function varargout = mainFnc(inputs, modelFilename, getModelDescription, getModelDocumentation, getVersion, versionTable)
  
  % Process inputs
  [info, pl, constructorInfo, fcn] = utils.models.processModelInputs(inputs, ...
    modelFilename, ...
    getModelDescription, ...
    getModelDocumentation, ...
    getVersion, ...
    versionTable);
  
  if ~isempty(info)
    varargout{1} = {info};
    return;
  end
  
  % Build the object
  hpl = copy(pl, 1);
  out = fcn(pl);
  
  % Set the method version string in the minfo object
  if ~isempty(constructorInfo) && utils.helper.isSubclassOf(class(out), 'ltpda_uoh')
    % If this is a user-call via a constructor, then we add history
    out = addHistoryStep(out, constructorInfo, hpl);
  end
  
  if nargout > 0
    varargout{1} = {out, pl};
  else
    error('!!! Invalid number of output')
  end
  
end