view m-toolbox/test/template_test_models/ao_model_c.m @ 41:6def6533cb16 database-connection-manager

Report authentication errors to user
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 18:04:34 +0100
parents f0afece42f48
children
line wrap: on
line source

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: Builtin model for C
%
% This model builds an AO with a vector in it.
%
%
% CALL:
%           p = ao(plist('built-in','c'))
%
% INPUTS:
%
%
%
% OUTPUTS:
%           - p: an AO object representing a
%
%
% VERSIONS:
%      'initial' = Reason: this version returns an AO with values 3,4,5
%                     Who: Martin
%                    When: 06-09-10
%       'second' = Reason: this version returns an AO with values 6,7,8
%                     Who: Martin
%                    When: 06-09-10
%
%
% REFERENCES:
%
%
% VERSION:     $Id: ao_model_c.m,v 1.3 2010/09/15 10:30:04 hewitson Exp $
%
% HISTORY:
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = ao_model_c(varargin)
  
  % Process inputs
  [info, pl, constructorInfo, fcn] = utils.models.processModelInputs(varargin(:), mfilename, @getModelDescription, @getModelDocumentation, @getVersion, @versionTable);
  if ~isempty(info)
    varargout{1} = info;
    return;
  end
  
  % Build the object
  out = fcn();
  
  % Set the method version string in the minfo object
  if ~isempty(constructorInfo)
    % If this is a user-call via a constructor, then we add history
    out = addHistoryStep(out, constructorInfo, pl);
  end
  
  if nargout > 0
    varargout{1} = out;
    varargout{2} = pl;
  else
    error('!!! Invalid number of output')
  end
end

%--------------------------------------------------------------------------
% AUTHORS EDIT THIS PART
%--------------------------------------------------------------------------

% This is the main description for the model. Additional descriptions of
% each version should be added in the version function.
function desc = getModelDescription
  desc = 'A model which builds a 3 element vector AO.';
end

function doc = getModelDocumentation
  doc = '';
end

% A lookup table which defines which function to call for a given version
% name.
function vt = versionTable()
  
  vt = {'initial', @initialVersion, ...
    'second', @secondVersion};
  
end

% This version uses:
%  model b, version 'alpha'
%  model c, version 'initial'
%
function varargout = initialVersion(varargin)
  
  if nargin == 1 && ischar(varargin{1})
    switch varargin{1}
      case 'plist'
        varargout{1} = plist();
      case 'description'
        varargout{1} = 'returns an AO with values 3,4,5';
      case 'info'
        varargout{1} = [];
      otherwise
        error('unknown inputs');
    end
    return;
  end
  
  % build model  
  varargout{1} = ao([3 4 5]);
  
end

% This version uses:
%  model b, version 'alpha'
%  model c, version 'second'
%
function varargout = secondVersion(varargin)
  
  if nargin == 1 && ischar(varargin{1})
    switch varargin{1}
      case 'plist'
        varargout{1} = plist('a', 1);
      case 'description'
        varargout{1} = 'returns an AO with values 6,7,8';
      case 'info'
        varargout{1} = [];
      otherwise
        error('unknown inputs');
    end
    return;
  end
  
  % build model
  varargout{1} = ao([6 7 8]);
end

%--------------------------------------------------------------------------
% AUTHORS SHOULD NOT NEED TO EDIT BELOW HERE
%--------------------------------------------------------------------------


%--------------------------------------------------------------------------
% Get Version
%--------------------------------------------------------------------------
function v = getVersion
  
  v = '$Id: ao_model_c.m,v 1.3 2010/09/15 10:30:04 hewitson Exp $';
  
end