Home > classes > @ao > copy.m

copy

PURPOSE ^

COPY makes a (deep) copy of the input AOs.

SYNOPSIS ^

function varargout = copy(old, deepcopy)

DESCRIPTION ^

 COPY makes a (deep) copy of the input AOs.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: COPY makes a deep copy of the input AOs.

 CALL:        b = copy(a, flag)

 INPUTS:      a    - input analysis object
              flag - 1: make a deep copy, 0: return copies of handles

 OUTPUTS:     b - copy of inputs

 This is a transparent function and adds no history.

 VERSION:     $Id: copy.m,v 1.14 2008/09/03 16:29:33 hewitson Exp $

 HISTORY:     14-07-2008 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % COPY makes a (deep) copy of the input AOs.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: COPY makes a deep copy of the input AOs.
0005 %
0006 % CALL:        b = copy(a, flag)
0007 %
0008 % INPUTS:      a    - input analysis object
0009 %              flag - 1: make a deep copy, 0: return copies of handles
0010 %
0011 % OUTPUTS:     b - copy of inputs
0012 %
0013 % This is a transparent function and adds no history.
0014 %
0015 % VERSION:     $Id: copy.m,v 1.14 2008/09/03 16:29:33 hewitson Exp $
0016 %
0017 % HISTORY:     14-07-2008 M Hewitson
0018 %                 Creation
0019 %
0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0021 
0022 function varargout = copy(old, deepcopy)
0023 
0024   if deepcopy
0025     t0   = time;
0026     prov = provenance;
0027     % Loop over input AOs
0028     s = size(old);
0029     obj(s(1),s(2)) = ao;
0030     for kk=1:numel(old)
0031       utils.helper.msg(utils.const.msg.OPROC2, 'copying %s', old(kk).name);
0032       % New defaults for all these objects
0033       % copy properties
0034       if ~isempty(old(kk).data)
0035         obj(kk).data        = copy(old(kk).data, 1);
0036       end
0037       obj(kk).mfile       = old(kk).mfile;
0038       obj(kk).mfilename   = old(kk).mfilename;
0039       obj(kk).mdlfile     = old(kk).mdlfile;
0040       obj(kk).plotinfo    = copy(old(kk).plotinfo, 1);
0041       obj(kk).description = old(kk).description;
0042       obj(kk).hist        = old(kk).hist;
0043       obj(kk).name        = old(kk).name;
0044       % These are reset on copy
0045       obj(kk).procinfo = plist;
0046       obj(kk).created  = t0;
0047       obj(kk).creator  = prov;
0048       obj(kk).version  = ao.VEROUT;
0049     end
0050   else
0051     obj = old;
0052   end
0053   varargout{1} = obj;
0054 end
0055 
0056

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003