Mercurial > hg > ltpda
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % GETPUBLICMETHODS returns a cell array of the public methods for the given | |
2 % class. | |
3 % | |
4 % CALL: [methods, minfos] = getPublicMethods(classname); | |
5 % | |
6 % M Hewitson 17-12-10 | |
7 % | |
8 % $Id: getPublicMethods.m,v 1.1 2010/12/17 14:22:56 hewitson Exp $ | |
9 % | |
10 function [mths, infos] = getPublicMethods(cl) | |
11 | |
12 fprintf(' collecting methods for %s class...\n', cl); | |
13 | |
14 cms = eval(['?' cl]); | |
15 m = [cms.Methods{:}]; | |
16 if isempty(m) | |
17 mths = {}; | |
18 infos = []; | |
19 return; | |
20 end | |
21 idx_static = [m(:).Static]; | |
22 idx_hidden = [m(:).Hidden]; | |
23 idx_public = strcmpi({m(:).Access}, 'public'); | |
24 | |
25 dc = [m(:).DefiningClass]; | |
26 idx_handle = strcmpi({dc(:).Name}, 'handle'); | |
27 | |
28 idx = ~idx_static & ~idx_hidden & idx_public & ~idx_handle; | |
29 | |
30 m = m(idx); | |
31 if isempty(m) | |
32 mths = {}; | |
33 infos = []; | |
34 return; | |
35 end | |
36 mths = {m(:).Name}; | |
37 | |
38 infos = []; | |
39 cmd = sprintf('%s.getInfo', cl); | |
40 for kk=1:numel(m) | |
41 try | |
42 ii = feval(cmd, m(kk).Name); | |
43 % disp([' found method: ' mt.Name]); | |
44 infos = [infos ii]; | |
45 catch | |
46 mths{kk} = ''; | |
47 infos = [infos minfo]; | |
48 warning('### could not get info about: %s', m(kk).Name); | |
49 end | |
50 | |
51 end | |
52 | |
53 idx = ~cellfun('isempty', mths); | |
54 mths = mths(idx); | |
55 infos = infos(idx); | |
56 | |
57 [mths,i,j] = unique(mths); | |
58 infos = infos(i); | |
59 | |
60 | |
61 end |