view m-toolbox/classes/@param/copy.m @ 1:2014ba5b353a database-connection-manager

Remove old code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Sat, 03 Dec 2011 18:13:55 +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