SETNAME Set the property 'name'. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: Set the property 'name'. CALL: obj = obj.setName('new name'); obj = obj.setName(plist('name', 'new name')); obj = setName(obj, 'new name'); EXAMPLE: obj.setName -> Sets the name to the variable name. In this case to 'obj' INPUTS: obj - can be a vector, matrix, list, or a mix of them. pl - to set the name with a plist specify only one plist with only one key-word 'name'. M-FILE INFO: Get information about this methods by calling >> ao.getInfo('setName') Get information about a specified set-plist by calling: >> ao.getInfo('setName', 'set') VERSION: $Id: setName.m,v 1.4 2008/09/04 15:29:30 ingo Exp $ HISTORY: 27-05-2008 Diepholz Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % SETNAME Set the property 'name'. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: Set the property 'name'. 0005 % 0006 % CALL: obj = obj.setName('new name'); 0007 % obj = obj.setName(plist('name', 'new name')); 0008 % obj = setName(obj, 'new name'); 0009 % 0010 % EXAMPLE: obj.setName -> Sets the name to the variable name. 0011 % In this case to 'obj' 0012 % 0013 % INPUTS: obj - can be a vector, matrix, list, or a mix of them. 0014 % pl - to set the name with a plist specify only one plist with 0015 % only one key-word 'name'. 0016 % 0017 % M-FILE INFO: Get information about this methods by calling 0018 % >> ao.getInfo('setName') 0019 % 0020 % Get information about a specified set-plist by calling: 0021 % >> ao.getInfo('setName', 'set') 0022 % 0023 % VERSION: $Id: setName.m,v 1.4 2008/09/04 15:29:30 ingo Exp $ 0024 % 0025 % HISTORY: 27-05-2008 Diepholz 0026 % Creation 0027 % 0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0029 0030 function varargout = setName(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 %%% Internal call: Only one object + don't look for a plist 0039 if strcmp(varargin{end}, 'internal') 0040 0041 %%% decide whether we modify the first object, or create a new one. 0042 varargin{1} = copy(varargin{1}, nargout); 0043 0044 varargin{1}.name = varargin{2}; 0045 varargout{1} = varargin{1}; 0046 return 0047 end 0048 0049 %%% Collect input variable names 0050 in_names = cell(size(varargin)); 0051 for ii = 1:nargin,in_names{ii} = inputname(ii);end 0052 0053 [objs, obj_invars, rest] = utils.helper.collect_objects(varargin(:), '', in_names); 0054 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist'); 0055 0056 %%% If pls contains only one plist with the only key 'name' then set the 0057 %%% property with a plist. 0058 if length(pls) == 1 && isa(pls, 'plist') && nparams(pls) == 1 && isparam(pls, 'name') 0059 rest{1} = find(pls, 'name'); 0060 end 0061 0062 if numel(rest) > 1 0063 error('### Please specify a single name, either in a plist or directly.'); 0064 end 0065 0066 %%% If rest is not filled then use the variable name for the property. 0067 if isempty(rest) 0068 vals = in_names{1}; 0069 else 0070 vals = rest{1}; 0071 end 0072 0073 %%% Combine plists 0074 pls = combine(pls, plist('name', vals)); 0075 0076 %%% Restrict name length 0077 if length(vals) > 35 0078 vals = [vals(1:20) '...' vals(end-12:end)]; 0079 end 0080 0081 %%% Set the Name 0082 for ii = 1:numel(objs) 0083 0084 %%% decide whether we modify the first plist, or create a new one. 0085 objs(ii) = copy(objs(ii), nargout); 0086 0087 %%% set the value 0088 objs(ii).name = vals; 0089 objs(ii).addHistory(getInfo, pls, obj_invars(ii), objs(ii).hist); 0090 end 0091 0092 %%% Prepare output 0093 varargout{1} = objs; 0094 end 0095 0096 0097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0098 % Local Functions % 0099 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0100 0101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0102 % 0103 % FUNCTION: getInfo 0104 % 0105 % DESCRIPTION: Get Info Object 0106 % 0107 % HISTORY: 11-07-07 M Hewitson 0108 % Creation. 0109 % 0110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0111 0112 function ii = getInfo(varargin) 0113 if nargin == 1 && strcmpi(varargin{1}, 'None') 0114 sets = {}; 0115 pl = []; 0116 else 0117 sets = {'Default'}; 0118 pl = getDefaultPlist; 0119 end 0120 % Build info object 0121 ii = minfo(mfilename, 'ltpda_uoh', '', utils.const.categories.helper, '$Id: setName.m,v 1.4 2008/09/04 15:29:30 ingo Exp $', sets, pl); 0122 end 0123 0124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0125 % 0126 % FUNCTION: getDefaultPlist 0127 % 0128 % DESCRIPTION: Get Default Plist 0129 % 0130 % HISTORY: 11-07-07 M Hewitson 0131 % Creation. 0132 % 0133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0134 0135 function plo = getDefaultPlist() 0136 plo = plist('name', ''); 0137 end 0138