comparison m-toolbox/classes/@ltpda_obj/get.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 % GET get a property of a object.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: GET get a property of a object.
5 %
6 % CALL: val = get(obj, 'prop_name');
7 %
8 % <a href="matlab:utils.helper.displayMethodInfo('ltpda_obj', 'get')">Parameters Description</a>
9 %
10 % VERSION: $Id: get.m,v 1.14 2011/04/08 08:56:37 hewitson Exp $
11 %
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13
14 function varargout = get(varargin)
15
16 %%% Check if this is a call for parameters
17 if utils.helper.isinfocall(varargin{:})
18 varargout{1} = getInfo(varargin{3});
19 return
20 end
21
22 obj = varargin{1};
23 prop_name = varargin{2};
24
25 %%% Some input checks
26 if nargin ~= 2
27 error('### This method accepts only two inputs');
28 end
29 if numel(obj) ~= 1
30 error('### This method works only for one input object.')
31 end
32 if ~(ischar(prop_name) || isa(prop_name, 'plist'))
33 error('### Please define the property name as a string of in a plist.')
34 end
35
36 %%% If prop_name is a plist then extrat the poperty name from the plist.
37 if isa(prop_name, 'plist')
38 prop_name = find(prop_name, 'property');
39 if isempty(prop_name)
40 error ('### The plist does not contain the ''key'' = ''property''');
41 end
42 end
43
44 %%% Return the property of the analysis object
45 if any(strcmp(prop_name, properties(obj)))
46 varargout{1} = obj.(prop_name);
47 else
48 error('### ''%s'' is not a valid %s-object property.', prop_name, class(obj));
49 end
50
51 end
52
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 % Local Functions %
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 %
59 % FUNCTION: getInfo
60 %
61 % DESCRIPTION: Get Info Object
62 %
63 % HISTORY: 05-01-2009 Ingo Diepholz
64 % Creation.
65 %
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67
68 function ii = getInfo(varargin)
69 if nargin == 1 && strcmpi(varargin{1}, 'None')
70 sets = {};
71 pl = [];
72 else
73 sets = {'Default'};
74 pl = getDefaultPlist;
75 end
76 % Build info object
77 ii = minfo(mfilename, 'ltpda_obj', 'ltpda', utils.const.categories.helper, '$Id: get.m,v 1.14 2011/04/08 08:56:37 hewitson Exp $', sets, pl);
78 ii.setModifier(false);
79 end
80
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 %
83 % FUNCTION: getDefaultPlist
84 %
85 % DESCRIPTION: Get Default Plist
86 %
87 % HISTORY: 11-07-07 M Hewitson
88 % Creation.
89 %
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91
92 function plout = getDefaultPlist()
93 persistent pl;
94 if exist('pl', 'var')==0 || isempty(pl)
95 pl = buildplist();
96 end
97 plout = pl;
98 end
99
100 function pl = buildplist()
101 pl = plist({'property', 'Property name you want to get.'}, '');
102 end
103