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