Mercurial > hg > ltpda
comparison m-toolbox/classes/@smodel/generateConstructorPlist.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 % GENERATECONSTRUCTORPLIST generates a PLIST from the properties which can rebuild the object. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: GENERATECONSTRUCTORPLIST generates a PLIST from the | |
5 % properties which can rebuild the object. | |
6 % | |
7 % CALL: pl = obj.generateConstructorPlist(); | |
8 % | |
9 % <a href="matlab:utils.helper.displayMethodInfo('smodel', 'generateConstructorPlist')">Parameters Description</a> | |
10 % | |
11 % VERSION: $Id: generateConstructorPlist.m,v 1.5 2011/04/08 08:56:27 hewitson Exp $ | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 | |
15 function pl = generateConstructorPlist(varargin) | |
16 | |
17 % Check if this is a call for parameters | |
18 if utils.helper.isinfocall(varargin{:}) | |
19 pl = getInfo(varargin{3}); | |
20 return | |
21 end | |
22 | |
23 obj = varargin{1}; | |
24 pl = plist(); | |
25 | |
26 % Add procinfo | |
27 appendProperty(pl, obj, 'procinfo'); | |
28 | |
29 % Add plotinfo | |
30 appendProperty(pl, obj, 'plotinfo'); | |
31 | |
32 % Add name | |
33 appendProperty(pl, obj, 'name', false); | |
34 | |
35 % Add description | |
36 appendProperty(pl, obj, 'description'); | |
37 | |
38 % Add expression | |
39 pl.append('expression', obj.expr); | |
40 | |
41 % Add params | |
42 appendProperty(pl, obj, 'params'); | |
43 | |
44 % Add values | |
45 appendProperty(pl, obj, 'values'); | |
46 | |
47 % Add trans | |
48 appendProperty(pl, obj, 'trans'); | |
49 | |
50 % Add xvar | |
51 appendProperty(pl, obj, 'xvar'); | |
52 | |
53 % Add xvals | |
54 appendProperty(pl, obj, 'xvals'); | |
55 | |
56 % Add xunits | |
57 appendProperty(pl, obj, 'xunits'); | |
58 | |
59 % Add yunits | |
60 appendProperty(pl, obj, 'yunits'); | |
61 | |
62 | |
63 end | |
64 | |
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
66 % Local Functions % | |
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
68 | |
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
70 % | |
71 % FUNCTION: appendProperty | |
72 % | |
73 % CALL: appendProperty(pl, obj, propName) | |
74 % appendProperty(pl, obj, propName, isemptyCheck) | |
75 % | |
76 % DESCRIPTION: Get Info Object | |
77 % | |
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
79 | |
80 function appendProperty(pl, obj, propName, isemptyCheck) | |
81 | |
82 if nargin <= 3 | |
83 isemptyCheck = true; | |
84 end | |
85 | |
86 if isemptyCheck | |
87 if ~isempty(obj.(propName)) | |
88 pl.append(propName, obj.(propName)); | |
89 else | |
90 % Don't append the property to the PLIST | |
91 end | |
92 else | |
93 pl.append(propName, obj.(propName)); | |
94 end | |
95 | |
96 end | |
97 | |
98 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
99 % | |
100 % FUNCTION: getInfo | |
101 % | |
102 % DESCRIPTION: Get Info Object | |
103 % | |
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
105 | |
106 function ii = getInfo(varargin) | |
107 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
108 sets = {}; | |
109 pl = []; | |
110 else | |
111 sets = {'Default'}; | |
112 pl = getDefaultPlist; | |
113 end | |
114 % Build info object | |
115 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.internal, '$Id: generateConstructorPlist.m,v 1.5 2011/04/08 08:56:27 hewitson Exp $', sets, pl); | |
116 end | |
117 | |
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
119 % | |
120 % FUNCTION: getDefaultPlist | |
121 % | |
122 % DESCRIPTION: Get Default Plist | |
123 % | |
124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
125 | |
126 function plout = getDefaultPlist() | |
127 persistent pl; | |
128 if exist('pl', 'var')==0 || isempty(pl) | |
129 pl = buildplist(); | |
130 end | |
131 plout = pl; | |
132 end | |
133 | |
134 function pl = buildplist() | |
135 pl = plist.EMPTY_PLIST; | |
136 end | |
137 |