view m-toolbox/classes/@history/string.m @ 24:056f8e1e995e database-connection-manager

Properly record history in fromRepository constructors
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% STRING writes a command string that can be used to recreate the input history object.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: STRING writes a command string that can be used to recreate the
%              input history object.
%
% CALL:        cmd = string(history_obj)
%
% INPUT:       history_obj - history object
%
% OUTPUT:      cmd         - command string to create the input object
%
% VERSION:     $Id: string.m,v 1.11 2011/02/18 16:48:52 ingo Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = string(varargin)

  objs = [varargin{:}];

  cmd = '';

  for ii = 1:numel(objs)
    hh = objs(ii);
    m_info  = hh.methodInfo;
    pl_used = hh.plistUsed;
    in_hist = hh.inhists;

    %%% Create minfo string
    if isempty(m_info)
      minfo_str = '[]';
    else
      minfo_str = string(m_info);
    end

    %%% Create plist string
    if isempty(pl_used)
      pl_str = '[]';
    else
      pl_str = string(pl_used);
    end

    %%% Create history string
    if isempty(in_hist)
      hi_str = '[]';
    else
      hi_str = string(in_hist);
    end
    if isempty(hi_str)
      hi_str = '[]';
    end

    cmd = [cmd 'history(' minfo_str, ', ' pl_str, ', '  hi_str,  ') '];
  end

  if numel(objs) > 1
    cmd = ['[ ' cmd ']'];
  end

  varargout{1} = cmd;
end