


PLIST Plist class object constructor.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: PLIST Parameter-List Object class object constructor.
Create a plist object.
SUPER CLASSES: ltpda_uo < ltpda_obj
PROPERTIES:
Inherit Properties (read only)
name - name of object
created - creation time (time-object)
prov - contains a instance of the provenance class.
hist - history of the object (history object)
version - cvs-version string.
Protected Properties (read only)
params - list of param-objects
PLIST METHODS:
Defined Abstract methods:
char - returns one character string which represents the object
copy - copies an object
display - displays an object
string - converts an object to a command string which will
recreate the plist object.
update_struct - updates a object structure to the current tbx-version
Public methods:
append - append a param-object, plist-object or a key/value pair to
the parameter list.
combine - combine multiple parameter lists (plist objects) into a
single plist.
find - Returns the value corresponding to the first parameters in
the list with search-key.
isparam - look for a given key in the parameter lists.
nparams - returns the number of param objects in the list.
pset - set or add a key/value pairor a param-object into
the parameter list.
pzmresp - shadow function for the pzmodel/resp.
remove - remove a parameter from the parameter list.
resp - shadows miir/iirResp and pzmodel/resp.
CONSTRUCTORS:
pl = plist() - create an empty plist object.
pl = plist(p) - create a plist with elements p
where p is an array of param objects.
pl = plist('key', val) - create a plist with the key/value pair
pl = plist('key1', val1, ... - create a plist with more key/value pairs
'key2', 'val2')
pl = plist('file.xml') - load a plist-object from xml-file
pl = plist('file.mat') - load a plist-object from mat-file
pl = plist(pl) - copies the input plist.
PARAMETERS:
If no recognised parameters are found in the input plist, the input
plist is simply returned. This is the copy constructor.
'Hostname' - construct a plist by retrieving it from an LTPDA repository
specified by the given hostname. Only those objects which
are plists are returned.
Additional parameters:
'Database' - The database name [default: 'ltpda']
'ID' - A vector of object IDs.
M-FILE INFO: The following call returns an minfo object that contains
information about the plist constructor:
>> info = plist.getInfo
or >> info = plist.getInfo('plist')
You can get information about class methods by calling:
>> info = plist.getInfo(method)
e.g. >> info = plist.getInfo('eq')
You can also restrict the sets of parameters contained in
the minfo object by calling:
>> info = plist.getInfo(method, set)
e.g. >> info = plist.getInfo('plist', 'Default')
VERSION: $Id: plist.m,v 1.47 2008/08/22 14:17:26 ingo Exp $
HISTORY: 30-01-07 M Hewitson
Creation
SEE ALSO: ltpda_obj, ltpda_uo, param
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


0001 % PLIST Plist class object constructor. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: PLIST Parameter-List Object class object constructor. 0005 % Create a plist object. 0006 % 0007 % SUPER CLASSES: ltpda_uo < ltpda_obj 0008 % 0009 % PROPERTIES: 0010 % 0011 % Inherit Properties (read only) 0012 % name - name of object 0013 % created - creation time (time-object) 0014 % prov - contains a instance of the provenance class. 0015 % hist - history of the object (history object) 0016 % version - cvs-version string. 0017 % 0018 % Protected Properties (read only) 0019 % params - list of param-objects 0020 % 0021 % PLIST METHODS: 0022 % 0023 % Defined Abstract methods: 0024 % char - returns one character string which represents the object 0025 % copy - copies an object 0026 % display - displays an object 0027 % string - converts an object to a command string which will 0028 % recreate the plist object. 0029 % update_struct - updates a object structure to the current tbx-version 0030 % 0031 % Public methods: 0032 % append - append a param-object, plist-object or a key/value pair to 0033 % the parameter list. 0034 % combine - combine multiple parameter lists (plist objects) into a 0035 % single plist. 0036 % find - Returns the value corresponding to the first parameters in 0037 % the list with search-key. 0038 % isparam - look for a given key in the parameter lists. 0039 % nparams - returns the number of param objects in the list. 0040 % pset - set or add a key/value pairor a param-object into 0041 % the parameter list. 0042 % pzmresp - shadow function for the pzmodel/resp. 0043 % remove - remove a parameter from the parameter list. 0044 % resp - shadows miir/iirResp and pzmodel/resp. 0045 % 0046 % CONSTRUCTORS: 0047 % 0048 % pl = plist() - create an empty plist object. 0049 % pl = plist(p) - create a plist with elements p 0050 % where p is an array of param objects. 0051 % pl = plist('key', val) - create a plist with the key/value pair 0052 % pl = plist('key1', val1, ... - create a plist with more key/value pairs 0053 % 'key2', 'val2') 0054 % pl = plist('file.xml') - load a plist-object from xml-file 0055 % pl = plist('file.mat') - load a plist-object from mat-file 0056 % pl = plist(pl) - copies the input plist. 0057 % 0058 % PARAMETERS: 0059 % 0060 % If no recognised parameters are found in the input plist, the input 0061 % plist is simply returned. This is the copy constructor. 0062 % 0063 % 'Hostname' - construct a plist by retrieving it from an LTPDA repository 0064 % specified by the given hostname. Only those objects which 0065 % are plists are returned. 0066 % Additional parameters: 0067 % 'Database' - The database name [default: 'ltpda'] 0068 % 'ID' - A vector of object IDs. 0069 % 0070 % M-FILE INFO: The following call returns an minfo object that contains 0071 % information about the plist constructor: 0072 % >> info = plist.getInfo 0073 % or >> info = plist.getInfo('plist') 0074 % 0075 % You can get information about class methods by calling: 0076 % >> info = plist.getInfo(method) 0077 % e.g. >> info = plist.getInfo('eq') 0078 % 0079 % You can also restrict the sets of parameters contained in 0080 % the minfo object by calling: 0081 % >> info = plist.getInfo(method, set) 0082 % e.g. >> info = plist.getInfo('plist', 'Default') 0083 % 0084 % VERSION: $Id: plist.m,v 1.47 2008/08/22 14:17:26 ingo Exp $ 0085 % 0086 % HISTORY: 30-01-07 M Hewitson 0087 % Creation 0088 % 0089 % SEE ALSO: ltpda_obj, ltpda_uo, param 0090 % 0091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0092 0093 classdef plist < ltpda_uo 0094 0095 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0096 % Property definition % 0097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0098 0099 %---------- Public (read/write) Properties ---------- 0100 properties 0101 end 0102 0103 %---------- Protected read-only Properties ---------- 0104 properties (SetAccess = protected) 0105 params = []; 0106 end 0107 0108 %---------- Private Properties ---------- 0109 properties (GetAccess = protected, SetAccess = protected) 0110 end 0111 0112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0113 % Check property setting % 0114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0115 0116 methods 0117 function obj = set.params(obj, val) 0118 if ~(isa(val, 'param') || isempty(val)) 0119 error('### The value for the property ''key'' must be a string\n### but it is from the class %s', class(val)); 0120 end 0121 obj.params = val; 0122 end 0123 end 0124 0125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0126 % Constructor % 0127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0128 0129 methods 0130 function pl = plist(varargin) 0131 0132 import utils.const.* 0133 utils.helper.msg(msg.OMNAME, 'running %s/%s', mfilename('class'), mfilename); 0134 0135 %%% Call superclass 0136 pl = pl@ltpda_uo(varargin{:}); 0137 0138 %%%%%%%%%% Set dafault values %%%%%%%%%% 0139 %%% Exept for a struct as an input 0140 if ~(nargin == 1 && isstruct(varargin{1})) 0141 % Set version 0142 pl.setVersion('$Id: plist.m,v 1.47 2008/08/22 14:17:26 ingo Exp $'); 0143 end 0144 0145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% no input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0148 0149 %%%%%%%%%% pl = plist() %%%%%%%%%% 0150 % create default parameter list object 0151 if nargin == 0 0152 utils.helper.msg(msg.OPROC1, 'empty constructor'); 0153 elseif nargin == 1 0154 0155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% one input %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0158 0159 %%%%%%%%%% p = param(plist) %%%%%%%%%% 0160 if isa(varargin{1}, 'plist') 0161 pli = varargin{1}; 0162 0163 %%% if the plist is empty then return an empty plist object 0164 if isempty(varargin{1}.params) 0165 else 0166 0167 % Retrieve from repository? 0168 hostname = find(pli, 'hostname'); 0169 if ~isempty(hostname) 0170 utils.helper.msg(msg.OPROC1, 'retrieving from repository %s', hostname); 0171 pl = pl.fromRepository(pli); 0172 else 0173 utils.helper.msg(msg.OPROC1, 'copying from %s', varargin{1}.name); 0174 pl = copy(varargin{1}, 1); 0175 end 0176 end 0177 0178 %%%%%%%%%%% From file %%%%%%%%%%%%%%%%%%%%%%%% 0179 elseif ischar(varargin{1}) 0180 0181 filename = varargin{1}; 0182 utils.helper.msg(msg.OPROC1, 'constructing from file %s', filename); 0183 [path, name, ext] = fileparts(filename); 0184 switch ext 0185 case '.mat' 0186 pl = load(filename); 0187 pl = pl.a; 0188 case '.xml' 0189 root_node = xmlread(filename); 0190 pl = utils.helper.xmlread(root_node, 'plist'); 0191 otherwise 0192 error('### Unknown file type.'); 0193 end 0194 0195 %%%%%%%%%% pl = plist(struct) %%%%%%%%%% 0196 elseif isstruct(varargin{1}) 0197 0198 utils.helper.msg(msg.OPROC1, 'constructing from struct'); 0199 %%% Set properties which are declared in this class 0200 pl.params = utils.helper.struct2obj(varargin{1}.params, 'param'); 0201 0202 %%%%%%%%%% pl = plist(param) %%%%%%%%%% 0203 elseif isa(varargin{1}, 'param') 0204 0205 utils.helper.msg(msg.OPROC1, 'constructing from param'); 0206 %%% Use only upper case characters for the 'key' 0207 param_list = varargin{1}; 0208 for kk = 1:length(param_list) 0209 param_list(kk) = param_list(kk).setKey(upper(param_list(kk).key)); 0210 end 0211 0212 pl.params = param_list; 0213 0214 else 0215 error ('### unknown arguments to construct a parameter list') 0216 end 0217 0218 elseif nargin == 2 0219 0220 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% two inputs %%%%%%%%%%%%%%%%%%%%%%%%%%%% 0222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0223 0224 %%%%%%%%%%% From DATABASE %%%%%%%%%%% 0225 if isa(varargin{1}, 'database') 0226 0227 utils.helper.msg(msg.OPROC1, 'constructing from database object'); 0228 pl = retrieve(varargin{1}, varargin{2:end}); 0229 0230 %%%%%%%%%% pl = plist('key1', val1) %%%%%%%%%% 0231 else 0232 utils.helper.msg(msg.OPROC1, 'constructing from key/value pair'); 0233 pl.params = param(upper(varargin{1}), varargin{2}); 0234 end 0235 0236 elseif nargin > 2 0237 0238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% more inputs %%%%%%%%%%%%%%%%%%%%%%%%%%% 0240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0241 0242 utils.helper.msg(msg.OPROC1, 'constructing from key/value pairs'); 0243 0244 %%%%%%%%%% pl = plist('key1, val1, 'key2', 'val2' , ...) %%%%%%%%%% 0245 param_list = []; 0246 argin = varargin; 0247 while length(argin) >= 2 0248 key = upper(argin{1}); 0249 val = argin{2}; 0250 argin = argin(3:end); 0251 0252 if ~isempty(pl.params) 0253 found = any(strcmpi(key, {pl.params(:).key})); 0254 if found 0255 error('### Do not use the same key [%s] twice.\n### REMARK: The key is not case sensitive.', key); 0256 end 0257 end 0258 % add to list 0259 param_list = [param_list param(key, val)]; 0260 end 0261 pl.params = param_list; 0262 else 0263 error('### Unknown number of constructor arguments.'); 0264 end 0265 0266 end % End constructor 0267 end 0268 0269 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0270 % Methods (public) % 0271 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0272 0273 methods 0274 %%% Define Abstract methods 0275 varargout = char(varargin); 0276 varargout = copy(varargin) 0277 varargout = display(varargin); 0278 varargout = string(varargin); 0279 0280 %%% Define other methods 0281 varargout = append(varargin); 0282 varargout = combine(varargin); 0283 varargout = find(varargin); 0284 varargout = isparam(varargin); 0285 varargout = nparams(varargin); 0286 varargout = pset(varargin); 0287 % varargout = pzmresp(varargin); 0288 varargout = remove(varargin) 0289 varargout = resp(varargin); 0290 end 0291 0292 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0293 % Methods (protected) % 0294 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0295 0296 methods (Access = protected) 0297 varargout = fromRepository(varargin) 0298 end 0299 0300 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0301 % Methods (Static, Public) % 0302 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0303 0304 methods (Static = true) 0305 0306 varargout = update_struct(varargin); 0307 0308 function out = VEROUT() 0309 out = '$Id: plist.m,v 1.47 2008/08/22 14:17:26 ingo Exp $'; 0310 end 0311 0312 function ii = getInfo(varargin) 0313 ii = utils.helper.generic_getInfo(varargin{:}, 'plist'); 0314 end 0315 0316 function out = SETS() 0317 out = {'From Repository'}; 0318 end 0319 0320 function out = getDefaultPlist(set) 0321 switch set 0322 case 'From Repository' 0323 out = plist('hostname', 'localhost', 'database', 'ltpda', 'ID', []); 0324 0325 otherwise 0326 error('### Unknown set [%s] to get the default plist.', set); 0327 end 0328 end 0329 0330 end 0331 0332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0333 % Methods (Static, Private) % 0334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0335 0336 methods (Static = true, Access = private) 0337 end 0338 0339 end % Class 0340 0341