comparison m-toolbox/classes/@plist/getOptionsForParam.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 % GETOPTIONSFORPARAM Returns the options for the specified parameter key.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: GETOPTIONSFORPARAM Returns the options for the specified
5 % parameter key.
6 %
7 % CALL: obj = obj.getOptionsForParam('key');
8 % obj = obj.getOptionsForParam(plist('key'));
9 % obj = getOptionsForParam(obj, 'key');
10 %
11 % INPUTS: obj - One parameter list (plist).
12 % key - Parameter key
13 %
14 % <a href="matlab:utils.helper.displayMethodInfo('plist', 'getOptionsForParam')">Parameters Description</a>
15 %
16 % VERSION: $Id: getOptionsForParam.m,v 1.7 2011/04/08 08:56:21 hewitson Exp $
17 %
18 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19
20 function varargout = getOptionsForParam(varargin)
21
22 %%% Check if this is a call for parameters
23 if utils.helper.isinfocall(varargin{:})
24 varargout{1} = getInfo(varargin{3});
25 return
26 end
27
28 if nargin ~= 2
29 error('### This method works only with two inputs (plist + key name).');
30 end
31 if ~(isa(varargin{1}, 'plist') || numel(varargin{1} ~= 1))
32 error('### This method accepts only one plist as an input.')
33 end
34 if ~(ischar(varargin{2}) || isa(varargin{2}, 'plist'))
35 error('### The second input must be a ')
36 end
37
38 pl = varargin{1};
39 key = varargin{2};
40 val = [];
41
42 if isa(key, 'plist')
43 key = key.find('key');
44 end
45
46 for ii = 1:pl.nparams
47 if strcmpi(pl.params(ii).key, key)
48 if isa(pl.params(ii).val, 'paramValue')
49 val = pl.params(ii).val.getOptions();
50 else
51 val = {pl.params(ii).val};
52 end
53 break;
54 end
55 end
56
57 % Single output
58 varargout{1} = val;
59 end
60
61
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 % Local Functions %
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 %
68 % FUNCTION: getInfo
69 %
70 % DESCRIPTION: Get Info Object
71 %
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73
74 function ii = getInfo(varargin)
75 if nargin == 1 && strcmpi(varargin{1}, 'None')
76 sets = {};
77 pl = [];
78 else
79 sets = {'Default'};
80 pl = getDefaultPlist;
81 end
82 % Build info object
83 ii = minfo(mfilename, 'plist', 'ltpda', utils.const.categories.helper, '$Id: getOptionsForParam.m,v 1.7 2011/04/08 08:56:21 hewitson Exp $', sets, pl);
84 end
85
86 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
87 %
88 % FUNCTION: getDefaultPlist
89 %
90 % DESCRIPTION: Get Default Plist
91 %
92 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93
94
95 function pl = getDefaultPlist()
96
97 pl = plist();
98
99 % Key
100 p = param({'key', 'The key of the parameter to retrieve the options from.'}, paramValue.EMPTY_STRING);
101 pl.append(p);
102
103 end
104
105
106