Mercurial > hg > ltpda
comparison m-toolbox/classes/@smodel/plus.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 % PLUS implements addition operator for smodel objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: PLUS implements addition operator for two smodel objects. | |
5 % | |
6 % CALL: obj = obj1+obj2 | |
7 % obj = plus(obj1,obj2); | |
8 % | |
9 % <a href="matlab:utils.helper.displayMethodInfo('smodel', 'plus')">Parameters Description</a> | |
10 % | |
11 % VERSION: $Id: plus.m,v 1.10 2011/05/10 20:35:29 mauro Exp $ | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 | |
15 function varargout = plus(varargin) | |
16 | |
17 callerIsMethod = utils.helper.callerIsMethod; | |
18 | |
19 % Check if this is a call for parameters | |
20 if utils.helper.isinfocall(varargin{:}) | |
21 varargout{1} = getInfo(varargin{3}); | |
22 return | |
23 end | |
24 | |
25 % Settings | |
26 op = 'plus'; | |
27 opname = 'addition'; | |
28 opsym = '+'; | |
29 | |
30 if callerIsMethod | |
31 pl = []; | |
32 infoObj = []; | |
33 else | |
34 pl = getDefaultPlist(); | |
35 infoObj = getInfo('None'); | |
36 end | |
37 varNames = cell(size(varargin)); | |
38 for ii = 1:nargin,varNames{ii} = inputname(ii);end | |
39 | |
40 if nargout == 0 | |
41 error('### A %s operator can not be used as a modifier.', opname); | |
42 end | |
43 | |
44 mdl = smodel.elementOp(callerIsMethod, op, opname, opsym, infoObj, pl, varargin(:), varNames); | |
45 | |
46 % Set output | |
47 varargout = utils.helper.setoutputs(nargout, mdl); | |
48 | |
49 end | |
50 | |
51 %-------------------------------------------------------------------------- | |
52 % Get Info Object | |
53 %-------------------------------------------------------------------------- | |
54 function ii = getInfo(varargin) | |
55 | |
56 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
57 sets = {}; | |
58 pl = []; | |
59 else | |
60 sets = {'Default'}; | |
61 pl = getDefaultPlist(); | |
62 end | |
63 % Build info object | |
64 ii = minfo(mfilename, 'smodel', 'ltpda', utils.const.categories.aop, '$Id: plus.m,v 1.10 2011/05/10 20:35:29 mauro Exp $', sets, pl); | |
65 ii.setArgsmin(2); | |
66 ii.setModifier(false); | |
67 end | |
68 | |
69 %-------------------------------------------------------------------------- | |
70 % Get Default Plist | |
71 %-------------------------------------------------------------------------- | |
72 function plout = getDefaultPlist() | |
73 persistent pl; | |
74 if ~exist('pl', 'var') || isempty(pl) | |
75 pl = buildplist(); | |
76 end | |
77 plout = pl; | |
78 end | |
79 | |
80 function pl = buildplist() | |
81 pl = plist.EMPTY_PLIST; | |
82 end |