


PARAM Parameter object class constructor.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: PARAM Parameter object class constructor.
Create a parameter object.
SUPER CLASSES: ltpda_nuo < ltpda_obj
PROPERTIES:
Inherit Properties (read only)
version - cvs-version string.
Protected Properties (read only)
key - key of the key/value pair
val - value of the key/value pair
PARAM METHODS:
Defined Abstract methods:
char - returns one character string which represents the object
copy - copies an object
display - displays an object
update_struct - updates a object structure to the current tbx-version
Public methods:
mux - concatenate param-objects into a vector.
setKey - set the 'key' property
setVal - set the 'val' property
setKeyVal - set the key/value pair
string - writes a command string that can be used to recreate the object
CONSTRUCTORS:
p = param(); - creates an empty parameter
p = param(pl) - creates a parameter from a
parameter list with the parameters:
- 'key' and 'val', or
- 'filename'
p = param(filename) - load a parameter from file
p = param('name', val) - creates a numeric parameter
p = param('name', 'val') - creates a string parameter
M-FILE INFO: The following call returns an minfo object that contains
information about the param constructor:
>> info = param.getInfo
or >> info = param.getInfo('param')
You can get information about class methods by calling:
>> info = param.getInfo(method)
e.g. >> info = param.getInfo('eq')
You can also restrict the sets of parameters contained in
the minfo object by calling:
>> info = param.getInfo(method, set)
e.g. >> info = param.getInfo('param', 'Default')
VERSION: $Id: param.m,v 1.43 2008/08/11 07:25:39 hewitson Exp $
HISTORY: 19-05-2008 Diepholz
Creation.
SEE ALSO: ltpda_obj, ltpda_nuo, plist
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


0001 % PARAM Parameter object class constructor. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: PARAM Parameter object class constructor. 0005 % Create a parameter object. 0006 % 0007 % SUPER CLASSES: ltpda_nuo < ltpda_obj 0008 % 0009 % PROPERTIES: 0010 % 0011 % Inherit Properties (read only) 0012 % version - cvs-version string. 0013 % 0014 % Protected Properties (read only) 0015 % key - key of the key/value pair 0016 % val - value of the key/value pair 0017 % 0018 % PARAM METHODS: 0019 % 0020 % Defined Abstract methods: 0021 % char - returns one character string which represents the object 0022 % copy - copies an object 0023 % display - displays an object 0024 % update_struct - updates a object structure to the current tbx-version 0025 % 0026 % Public methods: 0027 % mux - concatenate param-objects into a vector. 0028 % setKey - set the 'key' property 0029 % setVal - set the 'val' property 0030 % setKeyVal - set the key/value pair 0031 % string - writes a command string that can be used to recreate the object 0032 % 0033 % CONSTRUCTORS: 0034 % 0035 % p = param(); - creates an empty parameter 0036 % p = param(pl) - creates a parameter from a 0037 % parameter list with the parameters: 0038 % - 'key' and 'val', or 0039 % - 'filename' 0040 % p = param(filename) - load a parameter from file 0041 % p = param('name', val) - creates a numeric parameter 0042 % p = param('name', 'val') - creates a string parameter 0043 % 0044 % M-FILE INFO: The following call returns an minfo object that contains 0045 % information about the param constructor: 0046 % >> info = param.getInfo 0047 % or >> info = param.getInfo('param') 0048 % 0049 % You can get information about class methods by calling: 0050 % >> info = param.getInfo(method) 0051 % e.g. >> info = param.getInfo('eq') 0052 % 0053 % You can also restrict the sets of parameters contained in 0054 % the minfo object by calling: 0055 % >> info = param.getInfo(method, set) 0056 % e.g. >> info = param.getInfo('param', 'Default') 0057 % 0058 % VERSION: $Id: param.m,v 1.43 2008/08/11 07:25:39 hewitson Exp $ 0059 % 0060 % HISTORY: 19-05-2008 Diepholz 0061 % Creation. 0062 % 0063 % SEE ALSO: ltpda_obj, ltpda_nuo, plist 0064 % 0065 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0066 0067 classdef (Sealed = true) param < ltpda_nuo 0068 0069 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0070 % Property definition % 0071 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0072 0073 %---------- Public (read/write) Properties ---------- 0074 properties 0075 end 0076 0077 %---------- Protected read-only Properties ---------- 0078 properties (SetAccess = protected) 0079 key = ''; 0080 val = []; 0081 end 0082 0083 %---------- Private Properties ---------- 0084 properties (GetAccess = protected, SetAccess = protected) 0085 end 0086 0087 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0088 % Check property setting % 0089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0090 0091 methods 0092 function obj = set.key(obj, val) 0093 if ~ischar(val) 0094 error('### The value for the property ''key'' must be a string\n### but it is from the class %s', class(val)); 0095 end 0096 obj.key = upper(val); 0097 end 0098 end 0099 0100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0101 % Constructor % 0102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0103 0104 methods 0105 function obj = param(varargin) 0106 0107 import utils.const.* 0108 utils.helper.msg(msg.OMNAME, 'running %s/%s', mfilename('class'), mfilename); 0109 0110 %%% Call superclass 0111 obj = obj@ltpda_nuo(varargin{:}); 0112 0113 %%%%%%%%%% Set dafault values %%%%%%%%%% 0114 %%% Exept for a struct as an input 0115 if ~(nargin == 1 && isstruct(varargin{1})) 0116 % set version 0117 obj.setVersion('$Id: param.m,v 1.43 2008/08/11 07:25:39 hewitson Exp $'); 0118 end 0119 0120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% no input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0122 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0123 0124 if nargin == 0 0125 0126 % Do nothing 0127 utils.helper.msg(msg.OPROC1, 'empty constructor'); 0128 0129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% one input %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0132 elseif nargin == 1 0133 0134 %%%%%%%%%% obj = param(param) %%%%%%%%%% 0135 if isa(varargin{1}, 'param') 0136 utils.helper.msg(msg.OPROC1, 'copy constructor'); 0137 obj = copy(varargin{1}, 1); 0138 0139 %%%%%%%%%% obj = param(plist) %%%%%%%%%% 0140 elseif isa(varargin{1}, 'plist') 0141 0142 %%%%%%%%%% obj = param(plist()) %%%%%%%%%% 0143 %%%%%%%%%% obj = param(plist('KEY', 'a', 'VAL', 1)) %%%%%%%%%% 0144 %%% is the plist is empty then return an empty param object 0145 if nparams(varargin{1}) == 0 0146 0147 else 0148 utils.helper.msg(msg.OPROC1, 'constructing from key/value pair'); 0149 pl = varargin{1}; 0150 key = find(pl, 'key'); 0151 val = find(pl, 'val'); 0152 if isempty(key) 0153 error('### building a parameter from a plist requires one parameter in the plist is called ''key'''); 0154 end 0155 if isempty(val) 0156 error('### building a parameter from a plist requires one parameter in the plist is called ''val'''); 0157 end 0158 0159 obj.key = key; 0160 obj.val = val; 0161 end 0162 0163 %%%%%%%%%% obj = param(struct) %%%%%%%%%% 0164 elseif isstruct(varargin{1}) 0165 utils.helper.msg(msg.OPROC1, 'constructing from struct'); 0166 %%% Set properties which are declared in this class 0167 obj.key = varargin{1}.key; 0168 obj.val = varargin{1}.val; 0169 0170 %%%%%%%%%% obj = param('filename.xml') %%%%%%%%%% 0171 elseif ischar(varargin{1}) 0172 0173 filename = varargin{1}; 0174 utils.helper.msg(msg.OPROC1, 'constructing from file %s', filename); 0175 [path, name, ext] = fileparts(filename); 0176 switch ext 0177 case '.mat' 0178 obj = load(filename); 0179 obj = obj.a; 0180 case '.xml' 0181 root_node = xmlread(filename); 0182 obj = utils.helper.xmlread(root_node, 'param'); 0183 otherwise 0184 error('### Unknown file type.'); 0185 end 0186 0187 else 0188 error('### unknown constructor type for param object.'); 0189 end 0190 0191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% two inputs %%%%%%%%%%%%%%%%%%%%%%%%%%%% 0193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0194 0195 elseif nargin == 2 0196 0197 if isa(varargin{1}, 'database') 0198 utils.helper.msg(msg.OPROC1, 'constructing from database object'); 0199 0200 %%%%%%%%%% obj = param(key, value) %%%%%%%%%% 0201 else 0202 utils.helper.msg(msg.OPROC1, 'constructing from key/value pair'); 0203 obj.key = varargin{1}; 0204 obj.val = varargin{2}; 0205 end 0206 0207 else 0208 error('### Unknown number of arguments.'); 0209 end 0210 0211 end 0212 end 0213 0214 0215 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0216 % Methods (public) % 0217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0218 0219 methods 0220 varargout = mux(varargin); 0221 varargout = string(varargin) 0222 0223 %%% Define Abstract methods 0224 varargout = char(varargin) 0225 varargout = copy(varargin) 0226 varargout = display(varargin) 0227 0228 varargout = setKey(varargin) 0229 varargout = setVal(varargin) 0230 varargout = setKeyVal(varargin) 0231 end 0232 0233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0234 % Methods (protected) % 0235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0236 0237 methods (Access = protected) 0238 end 0239 0240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0241 % Methods (Static, Public) % 0242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0243 0244 methods (Static = true) 0245 0246 varargout = update_struct(varargin); 0247 0248 function out = VEROUT() 0249 out = '$Id: param.m,v 1.43 2008/08/11 07:25:39 hewitson Exp $'; 0250 end 0251 0252 function ii = getInfo(varargin) 0253 ii = utils.helper.generic_getInfo(varargin{:}, 'param'); 0254 end 0255 0256 function out = SETS() 0257 out = {'Default'}; 0258 end 0259 0260 function out = getDefaultPlist(set) 0261 switch set 0262 case 'Default' 0263 out = plist(); 0264 otherwise 0265 error('### Unknown set [%s]', set'); 0266 end 0267 end 0268 0269 end 0270 0271 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0272 % Methods (Static, Private) % 0273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0274 0275 methods (Static = true, Access = private) 0276 end 0277 0278 end 0279