diff m-toolbox/classes/+utils/@helper/getPublicMethods.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@helper/getPublicMethods.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,61 @@
+% 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
\ No newline at end of file