view m-toolbox/classes/@ltpda_uoh/setObjectProperties.m @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +0100
parents f0afece42f48
children
line wrap: on
line source

% SETOBJECTPROPERTIES sets the object properties of an ltpda_uoh object.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: SETOBJECTPROPERTIES sets the object properties of an
%              ltpda_uoh object from the input plist. 
% 
% Only the keys in plist which are actually object properties are used;
% other keys are ignored.
%
% CALL:        objs.setObjectProperties(pl);
%              objs.setObjectProperties(pl, exceptions);
%
% 'exceptions' should be a cell-array of property names which will be
% ignored (not set).
%
% <a href="matlab:utils.helper.displayMethodInfo('ltpda_uoh', 'setObjectProperties')">Parameters Description</a>
%
% VERSION:     $Id: setObjectProperties.m,v 1.6 2011/09/16 05:01:46 hewitson Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = setObjectProperties(varargin)

  % Get inputs
  as = varargin{1};
  pl = varargin{2};
  
  if nargin > 2
    exceptions = varargin{3};
  else
    exceptions = {};
  end
  
  % Decide on a deep copy or a modify
  bs = copy(as, nargout);
  
  % Loop over ltpda_uoh objects
  props = properties(as);
  keys  = pl.getKeys;
  
  for kk=1:numel(keys)
    key = lower(keys{kk});
    if utils.helper.ismember(key, exceptions)
%       fprintf('- skipping setting %s\n', key);
    elseif utils.helper.ismember(key, props)
%       fprintf('+ setting property %s\n', key);
      fcn = ['set' upper(key(1)) key(2:end)];
      if ismethod(bs, fcn)
        feval(fcn, bs, pl.find(key));
      end
    end
    
  end
  
  % Set output
  varargout = utils.helper.setoutputs(nargout, bs);
end