Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/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('ao', 'generateConstructorPlist')">Parameters Description</a> | |
10 % | |
11 % VERSION: $Id: generateConstructorPlist.m,v 1.4 2011/04/08 08:56:18 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 data | |
39 if ~isempty(obj.data) | |
40 | |
41 if isa(obj.data, 'cdata') | |
42 | |
43 % Add y | |
44 pl.append('vals', obj.data.y); | |
45 % Add dy | |
46 appendProperty(pl, obj.data, 'dy'); | |
47 % Add yunits | |
48 appendProperty(pl, obj.data, 'yunits'); | |
49 | |
50 else | |
51 | |
52 % Add general properties of the xydata, tsdata and fsdata class | |
53 | |
54 % Add y | |
55 pl.append('yvals', obj.data.y); | |
56 % Add dy | |
57 appendProperty(pl, obj.data, 'dy'); | |
58 % Add yunits | |
59 appendProperty(pl, obj.data, 'yunits'); | |
60 % Add x | |
61 pl.append('xvals', obj.data.x); | |
62 % Add dx | |
63 appendProperty(pl, obj.data, 'dx'); | |
64 % Add xunits | |
65 appendProperty(pl, obj.data, 'xunits'); | |
66 | |
67 if isa(obj.data, 'xydata') | |
68 % Add data type | |
69 pl.append('type', 'xydata'); | |
70 | |
71 elseif isa(obj.data, 'tsdata') | |
72 | |
73 % Add fs | |
74 appendProperty(pl, obj.data, 'fs'); | |
75 % Add t0 | |
76 appendProperty(pl, obj.data, 't0'); | |
77 % Add data type | |
78 pl.append('type', 'tsdata'); | |
79 | |
80 elseif isa(obj.data, 'fsdata') | |
81 | |
82 % Add fs | |
83 appendProperty(pl, obj.data, 'fs'); | |
84 % Add t0 | |
85 appendProperty(pl, obj.data, 't0'); | |
86 % Add enbw | |
87 appendProperty(pl, obj.data, 'enbw'); | |
88 % Add navs | |
89 appendProperty(pl, obj.data, 'navs'); | |
90 % Add data type | |
91 pl.append('type', 'fsdata'); | |
92 | |
93 else | |
94 error('### This method doesn''t support a data object of the class %s', class(obj.data)); | |
95 end | |
96 end | |
97 | |
98 end | |
99 | |
100 end | |
101 | |
102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
103 % Local Functions % | |
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
105 | |
106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
107 % | |
108 % FUNCTION: appendProperty | |
109 % | |
110 % CALL: appendProperty(pl, obj, propName) | |
111 % appendProperty(pl, obj, propName, isemptyCheck) | |
112 % | |
113 % DESCRIPTION: Get Info Object | |
114 % | |
115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
116 | |
117 function appendProperty(pl, obj, propName, isemptyCheck) | |
118 | |
119 if nargin <= 3 | |
120 isemptyCheck = true; | |
121 end | |
122 | |
123 if isemptyCheck | |
124 if ~isempty(obj.(propName)) | |
125 pl.append(propName, obj.(propName)); | |
126 else | |
127 % Don't append the property to the PLIST | |
128 end | |
129 else | |
130 pl.append(propName, obj.(propName)); | |
131 end | |
132 | |
133 end | |
134 | |
135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
136 % | |
137 % FUNCTION: getInfo | |
138 % | |
139 % DESCRIPTION: Get Info Object | |
140 % | |
141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
142 | |
143 function ii = getInfo(varargin) | |
144 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
145 sets = {}; | |
146 pl = []; | |
147 else | |
148 sets = {'Default'}; | |
149 pl = getDefaultPlist; | |
150 end | |
151 % Build info object | |
152 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.internal, '$Id: generateConstructorPlist.m,v 1.4 2011/04/08 08:56:18 hewitson Exp $', sets, pl); | |
153 end | |
154 | |
155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
156 % | |
157 % FUNCTION: getDefaultPlist | |
158 % | |
159 % DESCRIPTION: Get Default Plist | |
160 % | |
161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
162 | |
163 function plout = getDefaultPlist() | |
164 persistent pl; | |
165 if exist('pl', 'var')==0 || isempty(pl) | |
166 pl = buildplist(); | |
167 end | |
168 plout = pl; | |
169 end | |
170 | |
171 function pl = buildplist() | |
172 pl = plist.EMPTY_PLIST; | |
173 end | |
174 |