view m-toolbox/classes/@param/display.m @ 35:4be5f7a5316f database-connection-manager

Suppress output messages on preferences loading and saving
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% DISPLAY display a parameter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: DISPLAY display a parameter
%              Is called for the parameter object when the semicolon is not used.
%
% CALL:        param('a', 1)
%              txt = display(param('a', 1));
%
% VERSION:     $Id: display.m,v 1.54 2011/02/18 16:48:53 ingo Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = display(varargin)
  
  objs = [varargin{:}];
  
  txt = {};
  
  for ii = 1:numel(objs)
    banner = sprintf('---- param %d ----', ii);
    txt{end+1} = banner;
    
    % get key and value
    name = objs(ii).key;
    v    = objs(ii).getVal;
    desc = objs(ii).desc;
    
    %%%%%%%%%%%%%%%%%%%%   Add Property 'key'   %%%%%%%%%%%%%%%%%%%%
    txt{end+1} = ['key:  ' name];
    
    %%%%%%%%%%%%%%%%%%%%   Add Property 'val'   %%%%%%%%%%%%%%%%%%%%
    
    if isstruct(v)
      %%%%%%%%%%   Special case: structures
      txt{end+1} = 'val:  structure';
      nv = numel(v);
      for ss = 1:nv
        if nv > 1, txt{end+1} = sprintf('       --- struct %02d ---', ss); end
        vs = v(ss);
        fields = fieldnames(vs);
        for kk=1:length(fields)
          field = fields{kk};
          val   = vs.(field);
          txt{end+1} = ['       ' field ': ' utils.helper.val2str(val, 60)];
        end
      end
    else
      %%%%%%%%%%   All other cases
      txt{end+1} = sprintf('val:  %s', utils.helper.val2str(v, 60));
    end
    
    %%%%%%%%%%%%%%%%%%%%   Add property 'description'   %%%%%%%%%%%%%%%%%%%%
    %%% Display the description only if it is not empty
    if ~isempty(desc)
      
      if iscell(desc)
        txt{end+1} = ['desc: ' desc(1,:)];
        for kk = 2:size(desc,1)
          txt{end+1} = ['      ' desc(kk,:)];
        end
      else
        txt{end+1} = ['desc: ' desc];
      end
    end
    
    banner_end(1:length(banner)) = '-';
    txt{end+1} = banner_end;
    
  end
  
  %%% Prepare output
  if nargout == 0
    for ii=1:length(txt)
      disp(sprintf(txt{ii}));
    end
  elseif nargout == 1
    varargout{1} = txt;
  end
  
end