view m-toolbox/classes/@param/copy.m @ 34:03d92954b939 database-connection-manager

Improve look of LTPDAPreferences diaolog
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% COPY makes a (deep) copy of the input param objects.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: COPY makes a deep copy of the input param objects.
%
% CALL:        b = copy(a, flag)
%
% INPUTS:      a    - input param object
%              flag - true: make a deep copy, false: return copies of handles
%
% OUTPUTS:     b - copy of inputs
%
% VERSION:     $Id: copy.m,v 1.18 2011/05/23 20:41:12 mauro Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = copy(old, deepcopy)
  
  if deepcopy
    % Loop over input param objects
    new = param.newarray(size(old));
    
    for kk = 1:numel(old)
      if isa(old(kk).val, 'ltpda_obj')
        new(kk).val  = copy(old(kk).val, true);
      else
        new(kk).val = old(kk).val;
      end
      new(kk).key  = old(kk).key;
      new(kk).desc = old(kk).desc;
    end
  else
    new = old;
  end
  
  varargout{1} = new;
end