Mercurial > hg > ltpda
comparison m-toolbox/classes/@plist/getSelectionForParam.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 % GETSELECTIONFORPARAM Returns the selection mode for the specified parameter key. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: GETSELECTIONFORPARAM Returns the selection mode for the | |
5 % specified parameter key. | |
6 % | |
7 % CALL: obj = obj.getSelectionForParam('key'); | |
8 % obj = obj.getSelectionForParam(plist('key')); | |
9 % obj = getSelectionForParam(obj, 'key'); | |
10 % | |
11 % INPUTS: obj - can be a vector, matrix, list, or a mix of them. | |
12 % key - Parameter key | |
13 % | |
14 % <a href="matlab:utils.helper.displayMethodInfo('plist', 'getSelectionForParam')">Parameters Description</a> | |
15 % | |
16 % VERSION: $Id: getSelectionForParam.m,v 1.6 2011/04/08 08:56:21 hewitson Exp $ | |
17 % | |
18 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
19 | |
20 function varargout = getSelectionForParam(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 val = pl.params(ii).val.selection; | |
49 break; | |
50 end | |
51 end | |
52 | |
53 % Single output | |
54 varargout{1} = val; | |
55 end | |
56 | |
57 | |
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
59 % Local Functions % | |
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
61 | |
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
63 % | |
64 % FUNCTION: getInfo | |
65 % | |
66 % DESCRIPTION: Get Info Object | |
67 % | |
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
69 | |
70 function ii = getInfo(varargin) | |
71 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
72 sets = {}; | |
73 pl = []; | |
74 else | |
75 sets = {'Default'}; | |
76 pl = getDefaultPlist; | |
77 end | |
78 % Build info object | |
79 ii = minfo(mfilename, 'plist', 'ltpda', utils.const.categories.helper, '$Id: getSelectionForParam.m,v 1.6 2011/04/08 08:56:21 hewitson Exp $', sets, pl); | |
80 end | |
81 | |
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
83 % | |
84 % FUNCTION: getDefaultPlist | |
85 % | |
86 % DESCRIPTION: Get Default Plist | |
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 selection mode from.'}, paramValue.EMPTY_STRING); | |
96 pl.append(p); | |
97 | |
98 end |