Home > classes > @ao > copy.m

copy

PURPOSE ^

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

SYNOPSIS ^

function varargout = copy(varargin)

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.13 2008/08/21 19:39:33 hewitson Exp $

 HISTORY:     14-07-2008 M Hewitson
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

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.13 2008/08/21 19:39:33 hewitson Exp $
0016 %
0017 % HISTORY:     14-07-2008 M Hewitson
0018 %                 Creation
0019 %
0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0021 
0022 function varargout = copy(varargin)
0023 
0024   %%% Check if this is a call for parameters
0025   if nargin == 3 && ischar(varargin{2}) && strcmp(varargin{2}, 'INFO')
0026     varargout{1} = getInfo(varargin{3});
0027     return
0028   end
0029   
0030   % Collect all AOs and plists
0031   old = utils.helper.collect_objects(varargin(:), 'ao');
0032 
0033   % copy of handles?
0034   deepcopy = varargin{end};
0035 
0036   if deepcopy
0037     t0   = time;
0038     prov = provenance;
0039     % Loop over input AOs
0040     s = size(old);
0041     obj(s(1),s(2)) = ao;
0042     for kk=1:numel(old)
0043       utils.helper.msg(utils.const.msg.OPROC2, 'copying %s', old(kk).name);
0044       % New defaults for all these objects
0045       % copy properties
0046       if ~isempty(old(kk).data)
0047         obj(kk).data        = copy(old(kk).data, 1);
0048       end
0049       obj(kk).mfile       = old(kk).mfile;
0050       obj(kk).mfilename   = old(kk).mfilename;
0051       obj(kk).mdlfile     = old(kk).mdlfile;
0052       obj(kk).plotinfo    = copy(old(kk).plotinfo, 1);
0053       obj(kk).description = old(kk).description;
0054       obj(kk).hist        = old(kk).hist;
0055       obj(kk).name        = old(kk).name;
0056       % These are reset on copy
0057       obj(kk).procinfo = plist;
0058       obj(kk).created  = t0;
0059       obj(kk).creator  = prov;
0060       obj(kk).version  = ao.VEROUT;
0061     end
0062   else
0063     obj = old;
0064   end
0065   varargout{1} = obj;
0066 end
0067 
0068 %--------------------------------------------------------------------------
0069 % Get Info Object
0070 %--------------------------------------------------------------------------
0071 function ii = getInfo(varargin)
0072 
0073   if nargin == 1 && strcmpi(varargin{1}, 'None')
0074     sets = {};
0075     pl   = [];
0076   else
0077     sets = {'Default'};
0078     pl   = getDefaultPlist;
0079   end
0080   % Build info object
0081   ii = minfo(mfilename, 'ao', '', 'Helper', '$Id: copy.m,v 1.13 2008/08/21 19:39:33 hewitson Exp $', sets, pl);
0082 end
0083 
0084 %--------------------------------------------------------------------------
0085 % Get Default Plist
0086 %--------------------------------------------------------------------------
0087 function pl = getDefaultPlist()
0088   pl = plist();
0089 end
0090

Generated on Mon 25-Aug-2008 22:39:29 by m2html © 2003