view m-toolbox/classes/+utils/@helper/getPublicMethods.m @ 16:91f21a0aab35 database-connection-manager

Update utils.jquery * * * Update utils.jmysql.getsinfo
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% GETPUBLICMETHODS returns a cell array of the public methods for the given
% class.
% 
% CALL: [methods, minfos] = getPublicMethods(classname);
% 
% M Hewitson 17-12-10
% 
% $Id: getPublicMethods.m,v 1.1 2010/12/17 14:22:56 hewitson Exp $
% 
function [mths, infos] = getPublicMethods(cl)
  
  fprintf('   collecting methods for %s class...\n', cl);
  
  cms = eval(['?' cl]);
  m = [cms.Methods{:}];
  if isempty(m)
    mths = {};
    infos = [];
    return;
  end
  idx_static = [m(:).Static];
  idx_hidden = [m(:).Hidden];
  idx_public = strcmpi({m(:).Access}, 'public');
  
  dc = [m(:).DefiningClass];
  idx_handle = strcmpi({dc(:).Name}, 'handle');
  
  idx = ~idx_static & ~idx_hidden & idx_public & ~idx_handle;
  
  m = m(idx);
  if isempty(m)
    mths = {};
    infos = [];
    return;
  end
  mths = {m(:).Name};
  
  infos = [];
  cmd = sprintf('%s.getInfo', cl);
  for kk=1:numel(m)
    try
      ii = feval(cmd, m(kk).Name);
      %         disp(['    found method: ' mt.Name]);
      infos = [infos ii];
    catch
      mths{kk} = '';
      infos = [infos minfo];
      warning('### could not get info about: %s', m(kk).Name);
    end
    
  end
  
  idx = ~cellfun('isempty', mths);
  mths = mths(idx);
  infos = infos(idx);
  
  [mths,i,j] = unique(mths);
  infos = infos(i);  
  
  
end