COMBINE multiple parameter lists (plist objects) into a single plist. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: COMBINE multiple parameter lists (plist objects) into a single plist. Duplicate parameters are given priority in the order in which they appear in the input. CALL: pl = combine(p1, p2, p3); pl = combine(p1, [p2 p3], p4) EXAMPLES: >> pl1 = plist('A', 1); >> pl2 = plist('A', 3); >> plo = plist(pl1, pl2) Then plo will contain a parameter 'A' with value 1. M-FILE INFO: Get information about this methods by calling >> plist.getInfo('combine') Get information about a specified set-plist by calling: >> plist.getInfo('combine', 'set') VERSION: $Id: combine.m,v 1.17 2008/09/04 15:29:31 ingo Exp $ HISTORY: 28-04-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % COMBINE multiple parameter lists (plist objects) into a single plist. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: COMBINE multiple parameter lists (plist objects) into a single 0005 % plist. Duplicate parameters are given priority in the order 0006 % in which they appear in the input. 0007 % 0008 % CALL: pl = combine(p1, p2, p3); 0009 % pl = combine(p1, [p2 p3], p4) 0010 % 0011 % EXAMPLES: >> pl1 = plist('A', 1); 0012 % >> pl2 = plist('A', 3); 0013 % >> plo = plist(pl1, pl2) 0014 % 0015 % Then plo will contain a parameter 'A' with value 1. 0016 % 0017 % M-FILE INFO: Get information about this methods by calling 0018 % >> plist.getInfo('combine') 0019 % 0020 % Get information about a specified set-plist by calling: 0021 % >> plist.getInfo('combine', 'set') 0022 % 0023 % VERSION: $Id: combine.m,v 1.17 2008/09/04 15:29:31 ingo Exp $ 0024 % 0025 % HISTORY: 28-04-2007 M Hewitson 0026 % Creation 0027 % 0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0029 0030 function varargout = combine(varargin) 0031 0032 %%% Check if this is a call for parameters 0033 if utils.helper.isinfocall(varargin{:}) 0034 varargout{1} = getInfo(varargin{3}); 0035 return 0036 end 0037 0038 objs = utils.helper.collect_objects(varargin(:), 'plist'); 0039 0040 %%% decide whether we modify the first plist, or create a new one. 0041 pl = copy(objs(1), nargout); 0042 0043 %%% If we found more than one plist then append the parameters 0044 %%% of the second, third, ... plist to the first plist 0045 if numel (objs) > 1 0046 for ii = 2:numel(objs) 0047 % Loop over all params in the current plist 0048 for jj = 1:length(objs(ii).params) 0049 ps = copy(objs(ii).params(jj), 1); 0050 pl = add_param(pl, ps); 0051 end 0052 end 0053 end 0054 0055 varargout{1} = pl; 0056 end 0057 0058 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0059 % Local Functions % 0060 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0061 0062 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0063 % DESCRIPTION: The input parameter will only be added if the key doesn't exist 0064 % in the plist. 0065 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0066 function pl = add_param(pl, p) 0067 0068 for kk = 1:length(pl.params) 0069 if strcmpi(pl.params(kk).key, p.key) 0070 % If the key exist in pl then do nothing, otherwise add the key value pair. 0071 return 0072 end 0073 end 0074 0075 % Convert all key characters into upper case characters 0076 p.setKey(upper(p.key)); 0077 0078 pl.params = [pl.params p]; 0079 end 0080 0081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0082 % 0083 % FUNCTION: getInfo 0084 % 0085 % DESCRIPTION: Get Info Object 0086 % 0087 % HISTORY: 11-07-07 M Hewitson 0088 % Creation. 0089 % 0090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0091 0092 function ii = getInfo(varargin) 0093 if nargin == 1 && strcmpi(varargin{1}, 'None') 0094 sets = {}; 0095 pl = []; 0096 else 0097 sets = {'Default'}; 0098 pl = getDefaultPlist; 0099 end 0100 % Build info object 0101 ii = minfo(mfilename, 'plist', '', utils.const.categories.helper, '$Id: combine.m,v 1.17 2008/09/04 15:29:31 ingo Exp $', sets, pl); 0102 end 0103 0104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0105 % 0106 % FUNCTION: getDefaultPlist 0107 % 0108 % DESCRIPTION: Get Default Plist 0109 % 0110 % HISTORY: 11-07-07 M Hewitson 0111 % Creation. 0112 % 0113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0114 0115 function plo = getDefaultPlist() 0116 plo = plist(); 0117 end 0118