comparison m-toolbox/test/template_test_models/ao_model_b.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %
3 % DESCRIPTION: Builtin model for B
4 %
5 % This model builds an AO with a number in it.
6 %
7 %
8 % CALL:
9 % p = ao(plist('built-in','b'))
10 %
11 % INPUTS:
12 %
13 %
14 %
15 % OUTPUTS:
16 % - p: an AO object representing a
17 %
18 %
19 % VERSIONS:
20 % 'alpha' = Reason: this version returns an AO with value 1
21 % Who: Martin
22 % When: 06-09-10
23 % 'beta' = Reason: this version returns an AO with value 2
24 % Who: Martin
25 % When: 06-09-10
26 %
27 %
28 % REFERENCES:
29 %
30 %
31 % VERSION: $Id: ao_model_b.m,v 1.3 2010/09/15 10:30:04 hewitson Exp $
32 %
33 % HISTORY:
34 %
35 %
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 function varargout = ao_model_b(varargin)
38
39 % Process inputs
40 [info, pl, constructorInfo, fcn] = utils.models.processModelInputs(varargin(:), mfilename, @getModelDescription, @getModelDocumentation, @getVersion, @versionTable);
41 if ~isempty(info)
42 varargout{1} = info;
43 return;
44 end
45
46 % Build the object
47 out = fcn();
48
49 % Set the method version string in the minfo object
50 if ~isempty(constructorInfo)
51 % If this is a user-call via a constructor, then we add history
52 out = addHistoryStep(out, constructorInfo, pl);
53 end
54
55 if nargout > 0
56 varargout{1} = out;
57 varargout{2} = pl;
58 else
59 error('!!! Invalid number of output')
60 end
61 end
62
63 %--------------------------------------------------------------------------
64 % AUTHORS EDIT THIS PART
65 %--------------------------------------------------------------------------
66
67 function desc = getModelDescription
68 desc = 'A model which builds a single value AO.';
69 end
70
71 function doc = getModelDocumentation
72 doc = '';
73 end
74
75 function vt = versionTable()
76
77 vt = {'alpha', @versionAlpha, ...
78 'beta', @versionBeta};
79
80 end
81
82 % This version uses:
83 % model b, version 'alpha'
84 % model c, version 'initial'
85 %
86 function varargout = versionAlpha(varargin)
87
88 if nargin == 1 && ischar(varargin{1})
89 switch varargin{1}
90 case 'plist'
91 varargout{1} = plist('a', 1, 'b', 2, 'c', 3);
92 case 'description'
93 varargout{1} = 'returns an AO with value 1';
94 case 'info'
95 varargout{1} = [];
96 otherwise
97 error('unknown inputs');
98 end
99 return;
100 end
101
102 % build model
103 varargout{1} = ao(1);
104
105 end
106
107 % This version uses:
108 % model b, version 'alpha'
109 % model c, version 'second'
110 %
111 function varargout = versionBeta(varargin)
112
113 if nargin == 1 && ischar(varargin{1})
114 switch varargin{1}
115 case 'plist'
116 varargout{1} = plist('a', 1);
117 case 'description'
118 varargout{1} = 'returns an AO with value 2';
119 case 'info'
120 varargout{1} = [];
121 otherwise
122 error('unknown inputs');
123 end
124 return;
125 end
126
127 % build model
128 varargout{1} = ao(2);
129 end
130
131 %--------------------------------------------------------------------------
132 % AUTHORS SHOULD NOT NEED TO EDIT BELOW HERE
133 %--------------------------------------------------------------------------
134
135
136 %--------------------------------------------------------------------------
137 % Get Version
138 %--------------------------------------------------------------------------
139 function v = getVersion
140
141 v = '$Id: ao_model_b.m,v 1.3 2010/09/15 10:30:04 hewitson Exp $';
142
143 end
144