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.44 2008/09/03 16:35:22 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.44 2008/09/03 16:35:22 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 %---------- Protected Properties ---------- 0084 properties (SetAccess = protected) 0085 version = '$Id: param.m,v 1.44 2008/09/03 16:35:22 hewitson Exp $' 0086 end 0087 0088 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0089 % Check property setting % 0090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0091 0092 methods 0093 function obj = set.key(obj, val) 0094 if ischar(val) 0095 obj.key = upper(val); 0096 else 0097 error('### The value for the property ''key'' must be a string\n### but it is from the class %s', class(val)); 0098 end 0099 end 0100 end 0101 0102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0103 % Constructor % 0104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0105 0106 methods 0107 function obj = param(varargin) 0108 0109 %%% Call superclass 0110 obj = obj@ltpda_nuo(varargin{:}); 0111 0112 %%%%%%%%%% Set dafault values %%%%%%%%%% 0113 0114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% no input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0117 0118 if nargin == 0 0119 0120 % Do nothing 0121 0122 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% one input %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0125 elseif nargin == 1 0126 0127 %%%%%%%%%% obj = param(param) %%%%%%%%%% 0128 if isa(varargin{1}, 'param') 0129 obj = copy(varargin{1}, 1); 0130 0131 %%%%%%%%%% obj = param(plist) %%%%%%%%%% 0132 elseif isa(varargin{1}, 'plist') 0133 0134 %%%%%%%%%% obj = param(plist()) %%%%%%%%%% 0135 %%%%%%%%%% obj = param(plist('KEY', 'a', 'VAL', 1)) %%%%%%%%%% 0136 %%% is the plist is empty then return an empty param object 0137 if nparams(varargin{1}) == 0 0138 0139 else 0140 pl = varargin{1}; 0141 key = find(pl, 'key'); 0142 val = find(pl, 'val'); 0143 if isempty(key) 0144 error('### building a parameter from a plist requires one parameter in the plist is called ''key'''); 0145 end 0146 if isempty(val) 0147 error('### building a parameter from a plist requires one parameter in the plist is called ''val'''); 0148 end 0149 0150 obj.key = key; 0151 obj.val = val; 0152 end 0153 0154 %%%%%%%%%% obj = param(struct) %%%%%%%%%% 0155 elseif isstruct(varargin{1}) 0156 %%% Set properties which are declared in this class 0157 obj.key = varargin{1}.key; 0158 obj.val = varargin{1}.val; 0159 obj.version = varargin{1}.version; 0160 0161 %%%%%%%%%% obj = param('filename.xml') %%%%%%%%%% 0162 elseif ischar(varargin{1}) 0163 0164 filename = varargin{1}; 0165 [path, name, ext] = fileparts(filename); 0166 switch ext 0167 case '.mat' 0168 obj = load(filename); 0169 obj = obj.a; 0170 case '.xml' 0171 root_node = xmlread(filename); 0172 obj = utils.helper.xmlread(root_node, 'param'); 0173 otherwise 0174 error('### Unknown file type.'); 0175 end 0176 0177 else 0178 error('### unknown constructor type for param object.'); 0179 end 0180 0181 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0182 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% two inputs %%%%%%%%%%%%%%%%%%%%%%%%%%%% 0183 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0184 0185 elseif nargin == 2 0186 0187 obj.key = varargin{1}; 0188 obj.val = varargin{2}; 0189 0190 else 0191 error('### Unknown number of arguments.'); 0192 end 0193 0194 end 0195 end 0196 0197 0198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0199 % Methods (public) % 0200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0201 0202 methods 0203 varargout = mux(varargin); 0204 varargout = string(varargin) 0205 0206 %%% Define Abstract methods 0207 varargout = char(varargin) 0208 varargout = copy(varargin) 0209 varargout = display(varargin) 0210 0211 varargout = setKey(varargin) 0212 varargout = setVal(varargin) 0213 varargout = setKeyVal(varargin) 0214 end 0215 0216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0217 % Methods (protected) % 0218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0219 0220 methods (Access = protected) 0221 end 0222 0223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0224 % Methods (Static, Public) % 0225 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0226 0227 methods (Static = true) 0228 0229 varargout = update_struct(varargin); 0230 0231 function out = VEROUT() 0232 out = '$Id: param.m,v 1.44 2008/09/03 16:35:22 hewitson Exp $'; 0233 end 0234 0235 function ii = getInfo(varargin) 0236 ii = utils.helper.generic_getInfo(varargin{:}, 'param'); 0237 end 0238 0239 function out = SETS() 0240 out = {'Default'}; 0241 end 0242 0243 function out = getDefaultPlist(set) 0244 switch set 0245 case 'Default' 0246 out = plist(); 0247 otherwise 0248 error('### Unknown set [%s]', set'); 0249 end 0250 end 0251 0252 end 0253 0254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0255 % Methods (Static, Private) % 0256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0257 0258 methods (Static = true, Access = private) 0259 end 0260 0261 end 0262