Mercurial > hg > ltpda
comparison m-toolbox/classes/@ltpda_obj/isprop.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 % ISPROP tests if the given field is one of the object properties. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: ISPROP tests if the given field is one of the object properties. | |
5 % | |
6 % CALL: obj.isprop('field'); | |
7 % isprop(obj, 'field'); | |
8 % | |
9 % INPUTS: obj - Input objects | |
10 % field - Property name of the object | |
11 % | |
12 % <a href="matlab:utils.helper.displayMethodInfo('ltpda_obj', 'isprop')">Parameters Description</a> | |
13 % | |
14 % VERSION: $Id: isprop.m,v 1.13 2011/04/08 08:56:37 hewitson Exp $ | |
15 % | |
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
17 | |
18 function varargout = isprop(varargin) | |
19 | |
20 callerIsMethod = utils.helper.callerIsMethod; | |
21 | |
22 %%% Check if this is a call for parameters | |
23 if utils.helper.isinfocall(varargin{:}) | |
24 varargout{1} = getInfo(varargin{3}); | |
25 return | |
26 end | |
27 | |
28 if callerIsMethod | |
29 objs = [varargin{1:end-1}]; | |
30 field = varargin{end}; | |
31 else | |
32 %%% Collect input variable names | |
33 in_names = cell(size(varargin)); | |
34 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
35 | |
36 %%% Collect all objects | |
37 [objs, invars, rest] = utils.helper.collect_objects(varargin(:), '', in_names); | |
38 | |
39 %%% If we eliminated the objects and plists then is the rest the property name | |
40 if length(rest) == 1 | |
41 field = rest{1}; | |
42 else | |
43 error('### Please specify [only one] field-name.') | |
44 end | |
45 end | |
46 | |
47 res = zeros(size(objs)); | |
48 | |
49 if any(strcmp(field, properties(objs))) | |
50 res = ones(size(objs)); | |
51 else | |
52 zeros(size(objs)); | |
53 end | |
54 | |
55 %%% prepare output | |
56 varargout{1} = res; | |
57 end | |
58 | |
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
60 % Local Functions % | |
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
62 | |
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
64 % | |
65 % FUNCTION: getInfo | |
66 % | |
67 % DESCRIPTION: Get Info Object | |
68 % | |
69 % HISTORY: 11-07-07 M Hewitson | |
70 % Creation. | |
71 % | |
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
73 | |
74 function ii = getInfo(varargin) | |
75 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
76 sets = {}; | |
77 pl = []; | |
78 else | |
79 sets = {'Default'}; | |
80 pl = getDefaultPlist; | |
81 end | |
82 % Build info object | |
83 ii = minfo(mfilename, 'ltpda_obj', 'ltpda', utils.const.categories.internal, '$Id: isprop.m,v 1.13 2011/04/08 08:56:37 hewitson Exp $', sets, pl); | |
84 ii.setModifier(false); | |
85 end | |
86 | |
87 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
88 % | |
89 % FUNCTION: getDefaultPlist | |
90 % | |
91 % DESCRIPTION: Get Default Plist | |
92 % | |
93 % HISTORY: 11-07-07 M Hewitson | |
94 % Creation. | |
95 % | |
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
97 | |
98 function plout = getDefaultPlist() | |
99 persistent pl; | |
100 if exist('pl', 'var')==0 || isempty(pl) | |
101 pl = buildplist(); | |
102 end | |
103 plout = pl; | |
104 end | |
105 | |
106 function pl = buildplist() | |
107 pl = plist.EMPTY_PLIST; | |
108 end | |
109 |