comparison m-toolbox/classes/+utils/@models/processModelInputs.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 % PROCESSMODELINPUTS processes the various input options for built-in
2 % models.
3 %
4 % The function requires various pieces of information about the model:
5 %
6 % [info, pl, constructorInfo, fcn] = ...
7 % processModelInputs(options, ...
8 % modelname, ...
9 % getModelDescription, ...
10 % getModelDocumentation, ...
11 % getVersion, ...
12 % versionTable)
13 %
14 % options - the options passed by the constructor to the model
15 %
16 %
17
18 function [info, pl, constructorInfo, fcn] = processModelInputs(options, modelname, getModelDescription, getModelDocumentation, getVersion, versionTable)
19
20 info = [];
21 pl = [];
22 constructorInfo = [];
23 fcn = [];
24
25 if ischar(options{1})
26 if strcmpi(options{1}, 'describe') || strcmpi(options{1}, 'description')
27 if numel(options) == 2 && ischar(options{2})
28 version = options{2};
29 else
30 vt = versionTable();
31 version = vt{1};
32 end
33 info = utils.models.getDescription(getModelDescription, versionTable, version, getVersion);
34 elseif strcmpi(options{1}, 'doc')
35 info = getModelDocumentation();
36 if isempty(info)
37 info = 'no documentation';
38 end
39 elseif strcmpi(options{1}, 'versionTable')
40 info = versionTable();
41 elseif strcmpi(options{1}, 'version')
42 info = getVersion();
43 elseif strcmpi(options{1}, 'plist') % for backwards compatibility
44 if numel(options) == 2 && ischar(options{2})
45 info = utils.models.getDefaultPlist(getModelDescription, versionTable, options{2});
46 else
47 info = utils.models.getDefaultPlist(getModelDescription, versionTable);
48 end
49 elseif strcmpi(options{1}, 'info')
50 if numel(options) == 2 && ischar(options{2})
51 ver = options{2};
52 else
53 pl = utils.models.getDefaultPlist(getModelDescription, versionTable);
54 ver = pl.find('version');
55 end
56 info = utils.models.getInfo(modelname, getModelDescription, versionTable, ver, getVersion);
57 else
58 error('incorrect inputs');
59 end
60 return
61 end
62
63 % Inputs and default values
64 userPlist = options{1};
65 version = userPlist.find('version');
66 if isempty(version)
67 vers = versionTable();
68 version = vers{1};
69 end
70 if numel(options) > 1
71 constructorInfo = options{2};
72 pl = combine(userPlist, constructorInfo.plists, utils.models.getDefaultPlist(getModelDescription, versionTable, version));
73 else
74 constructorInfo = '';
75 pl = combine(userPlist, utils.models.getDefaultPlist(getModelDescription, versionTable, version));
76 end
77
78 % Build the object
79 fcn = utils.models.functionForVersion(getModelDescription, versionTable, version);
80
81 if ~isempty(constructorInfo)
82 constructorInfo.addChildren(utils.models.getInfo(modelname, getModelDescription, versionTable, version, getVersion));
83 end
84
85 end