comparison m-toolbox/classes/@ao/applymethod.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 % APPLYMETHOD to the analysis object
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: APPLYMETHOD to the analysis object
5 % Private static AO function that applies the given method to
6 % the given AOs. This is called by all the simple methods like
7 % abs, mean, acos, etc.
8 %
9 % CALL: as = applymethod(copyObjects, callerIsMethod, in_names, operatorName, dxFcn, getInfo, getDefaultPlist, varargin)
10 %
11 % VERSION: $Id: applymethod.m,v 1.23 2011/04/17 09:12:33 hewitson Exp $
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function varargout = applymethod(copyObjects, callerIsMethod, in_names, operatorName, dxFcn, getInfo, getDefaultPlist, varargin)
16
17 if callerIsMethod
18
19 ao_invars = {};
20 % assumed call: b = fcn(a1,a2,a3)
21 % assumed call: b = fcn(a1,a2,a3, pl)
22
23 if isa(varargin{end}, 'plist')
24 as = varargin{1:end-1};
25 pl = varargin{end};
26 else
27 pl = [];
28 as = [varargin{:}];
29 end
30
31 info = [];
32
33 else
34 % Check if this is a call for parameters
35 if utils.helper.isinfocall(varargin{:})
36 varargout{1} = getInfo(varargin{3});
37 if nargout == 2
38 varargout{2} = [];
39 end
40 return
41 end
42
43 % Collect all AOs
44 [as, ao_invars, rest] = utils.helper.collect_objects(varargin, 'ao', in_names);
45
46 info = getInfo('None');
47
48 % Collect the rest of the inputs (should be plists)
49 pl = utils.helper.collect_objects(rest, 'plist');
50 end
51
52 % Decide on a deep copy or a modify
53 bs = copy(as, copyObjects);
54
55
56 for jj = 1:numel(bs)
57 % Message
58 utils.helper.msg(utils.const.msg.PROC3, 'applying %s to %s ', operatorName, bs(jj).name);
59 % Apply method to data
60 pl = applymethod(bs(jj).data, pl, operatorName, getDefaultPlist, dxFcn);
61 if ~callerIsMethod
62 % Set new AO name
63 bs(jj).name = [operatorName '(' ao_invars{jj} ')'];
64 % append history
65 bs(jj).addHistory(info, pl, ao_invars(jj), bs(jj).hist);
66 end
67 end
68
69 if nargout == 1
70 varargout{1} = bs;
71 elseif nargout == 2
72 varargout{1} = bs;
73 varargout{2} = pl;
74 else
75 error('### Incorrect outputs');
76 end
77
78 end