comparison m-toolbox/classes/+utils/@helper/getClassFromStruct.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
2
3 function objCl = getClassFromStruct(obj_struct)
4
5 objCl = '';
6 if isfield(obj_struct, 'class')
7 objCl = obj_struct.class;
8 elseif isstruct(obj_struct)
9 cls = utils.helper.ltpda_non_abstract_classes();
10 snames = fieldnames(obj_struct);
11 for jj=1:numel(cls)
12 cl = cls{jj};
13 m = meta.class.fromName(cl);
14 p = [m.Properties{:}];
15 idxPub = [strcmpi({p.GetAccess}, 'public')] & ~[p.Hidden];
16 pubCnames = {p(idxPub).Name}; % public and not hidden properties. (same as properties(cl))
17 allCnames = {p.Name}; %
18 if numel(allCnames) == numel(snames) && all(utils.helper.ismember(snames, allCnames))
19 objCl = cl;
20 return;
21 elseif numel(pubCnames) == numel(snames) && all(utils.helper.ismember(snames, pubCnames))
22 objCl = cl;
23 return;
24 end
25 end
26 end
27
28 end