Mercurial > hg > ltpda
comparison m-toolbox/m/etc/class_method_template.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 % FOO description for function 'foo' in one line. Necessary for lookfor functionality. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: FOO detailed description for the function 'foo' | |
5 % | |
6 % CALL: foo(a) | |
7 % [a, b] = foo(a,pl) | |
8 % | |
9 % INPUTS: a - analysis object(s) | |
10 % pl - parameter list(s) | |
11 % | |
12 % OUTPUTS: a - ??? | |
13 % b - ??? | |
14 % | |
15 % <a href="matlab:web(CLASS.getInfo('foo').tohtml, '-helpbrowser')">Parameter Sets</a> | |
16 % | |
17 % VERSION: $Id: class_method_template.m,v 1.3 2011/05/22 22:30:32 mauro Exp $ | |
18 % | |
19 % SEE ALSO: ao/cos, ao/tan, ao/asin, acos, atan | |
20 % | |
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
22 | |
23 %%% REMARK: This is a method template for classes which are derived from the | |
24 %%% ltpda_uoh class. | |
25 | |
26 function varargout = foo(varargin) | |
27 | |
28 %%% Check if this is a call for parameters | |
29 if utils.helper.isinfocall(varargin{:}) | |
30 varargout{1} = getInfo(varargin{3}); | |
31 return | |
32 end | |
33 | |
34 import utils.const.* | |
35 utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename); | |
36 | |
37 %%% Collect input variable names | |
38 in_names = cell(size(varargin)); | |
39 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
40 | |
41 %%% Collect all AOs | |
42 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); | |
43 pli = utils.helper.collect_objects(varargin(:), 'plist', in_names); | |
44 | |
45 %%% Decide on a deep copy or a modify | |
46 %%% REMARK: If you create a new AO (call the constructor) then | |
47 %%% it is not necessay to copy the input-AOs !!! | |
48 bs = copy(as, nargout); | |
49 | |
50 %%% Combine plists | |
51 pl = combine(pli, getDefaultPlist); | |
52 | |
53 %%% go through analysis objects | |
54 for kk = 1:numel(bs) | |
55 | |
56 %%% store the input history | |
57 inhist = bs(kk).hist; | |
58 | |
59 %%%%%%%%%% get x- and y-data %%%%%%%%%% | |
60 %%%% REMARK: If you get the data in this way then are x and y always | |
61 %%%% column vectors. | |
62 x = bs(kk).x; | |
63 y = bs(kk).y; | |
64 dx = bs(kk).dx; | |
65 dy = bs(kk).dy; | |
66 | |
67 %%%%%%%%%% some calculations %%%%%%%%%% | |
68 bs(kk).setX(some_new_X_data); | |
69 bs(kk).setY(some_new_Y_data); | |
70 bs(kk).setFs(new_fs); | |
71 bs(kk).setXunits(new_xunits); | |
72 bs(kk).setYunits(new_yunits); | |
73 | |
74 %%% Set Name | |
75 bs(kk).setName('new name'); | |
76 %%% A better way to set the name | |
77 bs(kk).name = 'new name'; | |
78 | |
79 %%% Add History | |
80 bs(kk).addHistory(getInfo('Special set or all sets? You decide.'), pl, ao_invars(kk), inhist); | |
81 end | |
82 | |
83 % Set output | |
84 varargout = utils.helper.setoutputs(nargout, bs); | |
85 | |
86 end | |
87 | |
88 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
89 % Local Functions % | |
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
91 | |
92 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
93 % | |
94 % FUNCTION: getInfo | |
95 % | |
96 % DESCRIPTION: Get Info Object | |
97 % | |
98 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
99 | |
100 function ii = getInfo(varargin) | |
101 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
102 sets = {}; | |
103 pls = []; | |
104 elseif nargin == 1 && ~isempty(varargin{1}) && ischar(varargin{1}) | |
105 sets{1} = varargin{1}; | |
106 pls = getDefaultPlist(sets{1}); | |
107 else | |
108 sets = {'set1', 'set2', 'set3'}; | |
109 pls = []; | |
110 for kk=1:numel(sets) | |
111 pls = [pls getDefaultPlist(sets{kk})]; | |
112 end | |
113 end | |
114 % Build info object | |
115 ii = minfo(mfilename, 'CLASS', '', utils.const.categories.DEFINE_ME, '$Id: class_method_template.m,v 1.3 2011/05/22 22:30:32 mauro Exp $', sets, pls); | |
116 end | |
117 | |
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
119 % | |
120 % FUNCTION: getDefaultPlist | |
121 % | |
122 % DESCRIPTION: Get Default Plist | |
123 % | |
124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
125 | |
126 function plo = getDefaultPlist(set) | |
127 switch set | |
128 case 'set1' | |
129 plo = plist(); | |
130 | |
131 % A | |
132 p = param({'a','This is the documentation for the key ''A''.'}, paramValue.EMPTY_DOUBLE); | |
133 plo.append(p); | |
134 case 'set2' | |
135 plo = plist(); | |
136 | |
137 % A | |
138 p = param({'a','This is the documentation for the key ''A''.'}, paramValue.DOUBLE_VALUE(1)); | |
139 plo.append(p); | |
140 % B | |
141 p = param({'b','This is the documentation for the key ''B''.'}, paramValue.DOUBLE_VALUE(2)); | |
142 plo.append(p); | |
143 case 'set3' | |
144 plo = plist(); | |
145 | |
146 % KEY | |
147 p = param({'key','This is the documentation for the key ''key''.'}, paramValue.STRING_VALUE('val') ); | |
148 plo.append(p); | |
149 | |
150 otherwise | |
151 error('### Unknown default plist for the set [%s]', set) | |
152 end | |
153 | |
154 end | |
155 |