comparison m-toolbox/classes/@paramValue/paramValue.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 % PARAMVALUE object class constructor.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: Parameter value object class constructor.
5 % Create a parameter value object.
6 %
7 % SUPERCLASSES: ltpda_nuo < ltpda_obj
8 %
9 % CONSTRUCTORS:
10 %
11 % p = paramValue(); - creates an empty parameter value
12 % p = paramVAlue(pl) - creates a parameter value from a
13 % parameter list with the keys:
14 % 'valIndex', 'options' and 'selection'
15 % p = paramValue(valIdx, ...
16 % options) - creates a parameter value from
17 % value index and the options
18 % p = paramValue(valIdx, ...
19 % options, ...
20 % selectionMode) - creates a parameter value from
21 % value index, options and
22 % selection mode.
23 %
24 % VERSION: $Id: paramValue.m,v 1.29 2011/04/07 11:01:28 ingo Exp $
25 %
26 % SEE ALSO: ltpda_obj, ltpda_nuo, param, plist
27 %
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29
30 classdef (Sealed = true, Hidden = true) paramValue < ltpda_nuo
31
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 % Property definition %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35
36 %---------- Public (read/write) Properties ----------
37 properties
38 end
39
40 %---------- Protected read-only Properties ----------
41 properties (SetAccess = protected)
42 valIndex = -1; % Index to the value inside 'options'
43 options = {}; % Possible values for 'val' if they exist
44 selection = 0; % Selection mode for the 'options'
45 property = struct([]); % A list which contains all additional infromation about the value like: min, max, ...
46 end
47
48 %---------- Protected Properties ----------
49 properties (SetAccess = protected)
50 end
51
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 % Check property setting %
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55
56 methods
57 function set.valIndex(obj, val)
58 if isnumeric(val)
59 obj.valIndex = val;
60 else
61 error('### The value for the property ''valIndex'' must be a index (Interger) to the options. The value is from the class %s', class(val));
62 end
63 end
64 function set.options(obj, val)
65 if iscell(val)
66 obj.options = val;
67 else
68 error('### The value for the property ''options'' must be a cell with all possible values. The value is from the class %s', class(val));
69 end
70 end
71 function set.selection(obj, val)
72 if isnumeric(val)
73 obj.selection = val;
74 else
75 error('### The value for the property ''selection'' must be a Interger. The value is from the class %s', class(val));
76 end
77 end
78 end
79
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 % Constructor %
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83
84 methods
85 function obj = paramValue(varargin)
86
87 switch nargin
88 case 0
89 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 %%%%%%%%%%%%%%%%%%%%%%%%%%% no input %%%%%%%%%%%%%%%%%%%%%%%%%%%%
91 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92
93 % Do nothing
94
95 case 1
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97 %%%%%%%%%%%%%%%%%%%%%%%%%%% one input %%%%%%%%%%%%%%%%%%%%%%%%%%%
98 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99
100 if isa(varargin{1}, 'paramValue')
101 %%%%%%%%%% obj = paramValue(paramValue) %%%%%%%%%%
102 obj = copy(varargin{1}, 1);
103
104 elseif isa(varargin{1}, 'plist')
105 %%%%%%%%%% obj = paramValue(plist) %%%%%%%%%%
106
107 if nparams(varargin{1}) == 0
108 %%%%%%%%%% obj = paramValue(plist()) %%%%%%%%%%
109 %%% is the plist is empty then return an empty paramValue object
110
111 else
112 %%%%%%%%%% pl = plist('valIndex', 1, 'OPTIONS', {'a', 'b'}, 'SELECTION', 0) %%%%%%%%%%
113 %%%%%%%%%% obj = paramValue(pl) %%%%%%%%%%
114 pl = varargin{1};
115 pl_valIndex = pl.find('valIndex');
116 pl_options = pl.find('options');
117 pl_selection = pl.find('selection');
118
119 % Set the value index to 1 if there is only one option.
120 if isempty(pl_valIndex) && numel(pl_options) == 1
121 pl_valIndex = 1;
122 end
123
124 if isempty(pl_valIndex)
125 error('### building a parameter from a plist requires one value index in the plist is called ''valIndex''');
126 end
127 if isempty(pl_options)
128 error('### building a parameter from a plist requires at least one option in the plist is calles ''options''');
129 end
130
131 obj.valIndex = pl_valIndex;
132 obj.options = pl_options;
133 if ~isempty(pl_selection)
134 obj.selection = pl_selection;
135 end
136 end
137
138 elseif isstruct(varargin{1})
139 %%%%%%%%%% obj = paramValue(struct) %%%%%%%%%%
140 obj = fromStruct(obj, varargin{1});
141
142 else
143 error('### Unknown single input paramValue constructor');
144 end
145
146 case 2
147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 %%%%%%%%%%%%%%%%%%%%%%%%%%% two inputs %%%%%%%%%%%%%%%%%%%%%%%%%%
149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150
151 %%%%%%%%%% obj = paramValue(valIndex, {options}) %%%%%%%%%%
152 obj.valIndex = varargin{1};
153 obj.options = varargin{2};
154
155 case 3;
156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157 %%%%%%%%%%%%%%%%%%%%%%%%%% three inputs %%%%%%%%%%%%%%%%%%%%%%%%%
158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159
160 %%%%%%%% obj = paramValue(valIndex, {options}, selection) %%%%%%%%
161 obj.valIndex = varargin{1};
162 obj.options = varargin{2};
163 if varargin{3} ~= obj.selection
164 obj.selection = varargin{3};
165 end
166 otherwise
167 error('### Unknown number of arguments.');
168 end
169
170 % Plausibility check.
171 if ~(obj.valIndex <= numel(obj.options))
172 error('### The valIndex must point to one element inside the ''options''. But valIndex is %d and the length of ''options'' is %d', obj.valIndex, numel(obj.options));
173 end
174
175 end
176 end
177
178
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180 % Methods (public) %
181 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182
183 methods
184 %%% Define Abstract methods
185 varargout = char(varargin)
186 varargout = copy(varargin)
187 varargout = display(varargin)
188
189 varargout = getVal(varargin)
190 varargout = getOptions(varargin)
191
192 varargout = setValIndex(varargin)
193 varargout = setValIndexAndOptions(varargin)
194 varargout = setOptions(varargin)
195 varargout = setSelection(varargin)
196
197 varargout = setProperty(varargin)
198 varargout = getProperty(varargin)
199 end
200
201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
202 % Methods (protected) %
203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204
205 methods (Access = protected)
206 varargout = fromStruct(varargin)
207 end
208
209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
210 % Methods (private) %
211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
212
213 methods (Access = private)
214 end
215
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
217 % Methods (Static, Public) %
218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
219
220 methods (Static = true)
221
222
223 % Param Value types
224 function out = EMPTY_STRING
225 out = '';
226 end
227 function out = EMPTY_DOUBLE
228 out = [];
229 end
230 function out = EMPTY_CELL
231 out = {};
232 end
233
234 function out = YES_NO
235 out = {1, {'yes', 'no'}, paramValue.SINGLE};
236 end
237 function out = NO_YES
238 out = {1, {'no', 'yes'}, paramValue.SINGLE};
239 end
240
241 function out = DATA_TYPES
242 out = {4,{'tsdata', 'fsdata', 'xydata', 'cdata'}, paramValue.SINGLE};
243 end
244
245 function out = WINDOW
246 prefs = getappdata(0, 'LTPDApreferences');
247 dwin = find(strcmpi(char(prefs.getMiscPrefs.getDefaultWindow), specwin.getTypes));
248 out = {dwin, specwin.getTypes, paramValue.SINGLE};
249 end
250
251 function out = STRING_VALUE(s)
252 out = {1, {s}, paramValue.OPTIONAL};
253 end
254
255 function out = DOUBLE_VALUE(v)
256 out = {1, {v}, paramValue.OPTIONAL};
257 end
258
259 function out = DETREND_ORDER
260 out = {1, {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, paramValue.SINGLE};
261 end
262
263 function out = TRUE_FALSE
264 out = {1, {true, false}, paramValue.SINGLE};
265 end
266
267 function out = FALSE_TRUE
268 out = {1, {false, true}, paramValue.SINGLE};
269 end
270
271 function out = TIMEFORMAT
272 prefs = getappdata(0, 'LTPDApreferences');
273 tf = {...
274 'dd-mm-yyyy HH:MM:SS', ...
275 'yyyy-mm-dd HH:MM:SS', ...
276 'dd-mm-yyyy HH:MM:SS.FFF', ...
277 'yyyy-mm-dd HH:MM:SS.FFF', ...
278 'HH:MM:SS dd-mm-yyyy', ...
279 'HH:MM:SS yyyy-mm-dd', ...
280 'HH:MM:SS.FFF dd-mm-yyyy', ...
281 'HH:MM:SS.FFF yyyy-mm-dd', ...
282 'dd.mm.yyyy HH:MM:SS', ...
283 'yyyy.mm.dd HH:MM:SS', ...
284 'dd.mm.yyyy HH:MM:SS.FFF', ...
285 'yyyy.mm.dd HH:MM:SS.FFF', ...
286 'HH:MM:SS dd.mm.yyyy', ...
287 'HH:MM:SS yyyy.mm.dd', ...
288 'HH:MM:SS.FFF dd.mm.yyyy', ...
289 'HH:MM:SS.FFF yyyy.mm.dd', ...
290 'MM:SS', ...
291 'MM:SS.FFF'};
292
293 idx = find(strcmp(char(prefs.getTimePrefs.getTimestringFormat), tf));
294 if isempty(idx)
295 tf = [{char(prefs.getTimePrefs.getTimestringFormat)} tf];
296 idx = 1;
297 end
298 out = {idx, tf, paramValue.OPTIONAL};
299 end
300
301 function out = TIMEZONE
302 prefs = getappdata(0, 'LTPDApreferences');
303 tz = utils.timetools.getTimezone;
304
305 idx = find(strcmp(prefs.getTimePrefs.getTimeTimezone(), tz));
306 out = {idx, tz, paramValue.SINGLE};
307 end
308
309 function res = OPTIONAL(); res = 0; end
310 function res = SINGLE(); res = 1; end
311 function res = MULTI(); res = 2; end
312 function str = getSelectionMode(val)
313 switch val
314 case 0
315 str = 'OPTIONAL';
316 case 1
317 str = 'SINGLE';
318 case 2
319 str = 'MULTI';
320 otherwise
321 str = '''selection'' is not valid!';
322 end
323 end
324
325 varargout = update_struct(varargin);
326
327 function out = VEROUT()
328 out = '$Id: paramValue.m,v 1.29 2011/04/07 11:01:28 ingo Exp $';
329 end
330
331 function ii = getInfo(varargin)
332 ii = utils.helper.generic_getInfo(varargin{:}, 'paramValue');
333 end
334
335 function out = SETS()
336 out = {'Default'};
337 end
338
339 function out = getDefaultPlist(set)
340 switch lower(set)
341 case 'default'
342 out = plist();
343 otherwise
344 error('### Unknown set [%s]', set');
345 end
346 end
347
348 function obj = initObjectWithSize(n,m)
349 obj = paramValue.newarray([n m]);
350 end
351
352 end
353
354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
355 % Methods (Static, Private) %
356 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
357
358 methods (Static = true, Access = private)
359 end
360
361 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
362 % Methods (static, hidden) %
363 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
364
365 methods (Static = true, Hidden = true)
366 varargout = loadobj(varargin)
367 end
368
369 end
370