view m-toolbox/classes/@plist/copy.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line source

% COPY makes a (deep) copy of the input plist objects.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: COPY makes a deep copy of the input plist objects.
%
% CALL:        b = copy(a, flag)
%
% INPUTS:      a    - input plist 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 plist objects
    new = plist.newarray(size(old));
    obj = copy@ltpda_uo(new, old, true);
    
    for kk = 1:numel(old)
      if ~isempty(old(kk).params)
        obj(kk).params  = copy(old(kk).params, true);
      end
    end
  else
    obj = old;
  end
  
  varargout{1} = obj;
end