Mercurial > hg > ltpda
comparison m-toolbox/classes/@history/history.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 % HISTORY History object class constructor. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: HISTORY History object class constructor. | |
5 % Create a history object. | |
6 % | |
7 % SUPERCLASSES: ltpda_nuo < ltpda_obj | |
8 % | |
9 % CONSTRUCTORS: | |
10 % | |
11 % h = history() | |
12 % h = history(proctime, minfo, plist) | |
13 % h = history(proctime, minfo, plist, in_names, oldUUID, in_hists) | |
14 % | |
15 % h = history(filename) | |
16 % h = history(structure) | |
17 % h = history(history-object) | |
18 % h = history('database', ...) | |
19 % | |
20 % INPUTS: minfo: Minfo-object which is created in the called method. | |
21 % plist: Plist-object which is used in the called method. | |
22 % in_names: Variable names which are used for the called method. | |
23 % in_hist: Older history-objects | |
24 % | |
25 % VERSION: $Id: history.m,v 1.72 2011/03/28 17:02:27 ingo Exp $ | |
26 % | |
27 % SEE ALSO: ltpda_obj, ltpda_nuo, minfo, plist | |
28 % | |
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
30 | |
31 classdef (Sealed = true, Hidden = true) history < ltpda_nuo | |
32 | |
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
34 % Property definition % | |
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
36 | |
37 %---------- Public (read/write) Properties ---------- | |
38 properties | |
39 end | |
40 | |
41 %---------- Protected read-only Properties ---------- | |
42 properties (SetAccess = protected) | |
43 methodInfo = []; % minfo-object which is created in the called method | |
44 plistUsed = []; % plist-object which is used in the called method | |
45 methodInvars = {}; % variable names which are used for the called method | |
46 inhists = []; % the older history-objects | |
47 proctime = []; % creation time of the history object | |
48 UUID = []; % UUID of the object that was changed | |
49 objectClass = ''; % The class of the object the history was attached to | |
50 creator = provenance(); | |
51 end | |
52 | |
53 %---------- Private Properties ---------- | |
54 properties (GetAccess = public, SetAccess = private) | |
55 end | |
56 | |
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
58 % Check property setting % | |
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
60 | |
61 methods | |
62 function set.methodInfo(obj, val) | |
63 if ~(isa(val, 'minfo') || isempty(val)) | |
64 error('### The value for the property ''methodInfo''\n### must be a minfo-object or empty but\n### it is from the class %s', class(val)); | |
65 end | |
66 obj.methodInfo = val; | |
67 end | |
68 function set.plistUsed(obj, val) | |
69 if ~(isa(val, 'plist') || isempty(val)) | |
70 error('### The value for the property ''plistUsed''\n### must be a plist-object or empty but\n### it is from the class %s', class(val)); | |
71 end | |
72 obj.plistUsed = val; | |
73 end | |
74 function set.methodInvars(obj, val) | |
75 if ~iscell(val) | |
76 error('### The value for the property ''methodInvars''\n### must be a cell-array but\n### it is from the class %s', class(val)); | |
77 end | |
78 obj.methodInvars = val; | |
79 end | |
80 function set.inhists(obj, val) | |
81 if ~(isa(val, 'history') || isempty(val) || ischar(val)) | |
82 error('### The value for the property ''inhists''\n### must be a history-object or empty but\n### it is from the class %s', class(val)); | |
83 end | |
84 obj.inhists = val; | |
85 end | |
86 | |
87 end | |
88 | |
89 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
90 % Constructor % | |
91 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
92 | |
93 methods | |
94 | |
95 function obj = history(varargin) | |
96 | |
97 switch nargin | |
98 case 0 | |
99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
100 %%%%%%%%%%%%%%%%%%%%%%%%%%% no input %%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
102 | |
103 % Do nothing | |
104 | |
105 case 1 | |
106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
107 %%%%%%%%%%%%%%%%%%%%%%%%%%% one input %%%%%%%%%%%%%%%%%%%%%%%%%%% | |
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
109 | |
110 %%%%%%%%%%% From File %%%%%%%%%%%%%%%% | |
111 if ischar(varargin{1}) | |
112 | |
113 filename = varargin{1}; | |
114 [path, name, ext] = fileparts(filename); | |
115 switch ext | |
116 case '.mat' | |
117 obj = load(filename); | |
118 obj = obj.a; | |
119 case '.xml' | |
120 root_node = xmlread(filename); | |
121 obj = utils.xml.xmlread(root_node, 'history'); | |
122 otherwise | |
123 error('### Unknown file type.'); | |
124 end | |
125 | |
126 %%%%%%%%%% h = history(struct) %%%%%%%%%% | |
127 elseif isstruct(varargin{1}) | |
128 obj = fromStruct(obj, varargin{1}); | |
129 | |
130 %%%%%%%%%% h = history(history) %%%%%%%%%% | |
131 elseif isa(varargin{1}, 'history') | |
132 obj = copy(varargin{1}, 1); | |
133 | |
134 %%%%%%%%%% h = history(plist) %%%%%%%%%% | |
135 elseif isa(varargin{1}, 'plist') | |
136 %%% is the plist is empty then return an empty history object | |
137 if nparams(varargin{1}) == 0 | |
138 obj.plistUsed = varargin{1}; | |
139 else | |
140 error('### Unknown history constructor method.'); | |
141 end | |
142 | |
143 else | |
144 error('### Unknown history constructor method.'); | |
145 end | |
146 | |
147 case 2 | |
148 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
149 %%%%%%%%%%%%%%%%%%%%%%%%%%% two input %%%%%%%%%%%%%%%%%%%%%%%%%%% | |
150 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
151 | |
152 if isa(varargin{1}, 'org.apache.xerces.dom.DeferredElementImpl') && ... | |
153 isa(varargin{2}, 'history') | |
154 %%%%%%%%%% obj = history(DOM node, history-objects) %%%%%%%%%% | |
155 obj = fromDom(obj, varargin{1}, varargin{2}); | |
156 | |
157 else | |
158 error('### Unknown constructor method for two inputs.'); | |
159 end | |
160 | |
161 case 3 | |
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
163 %%%%%%%%%%%%%%%%%%%%%%%%%% three inputs %%%%%%%%%%%%%%%%%%%%%%%%% | |
164 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
165 | |
166 %%%%%%%%%% h = history(proctime, minfo, plist) %%%% | |
167 %%% Use default values | |
168 if ~isempty(varargin{1}) | |
169 obj.proctime = varargin{1}; | |
170 end | |
171 if ~isempty(varargin{2}) | |
172 obj.methodInfo = varargin{2}; | |
173 end | |
174 if ~isempty(varargin{3}) | |
175 obj.plistUsed = varargin{3}; | |
176 end | |
177 | |
178 case 6 | |
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
180 %%%%%%%%%%%%%%%%%%%%%%%%%% five inputs %%%%%%%%%%%%%%%%%%%%%%%%% | |
181 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
182 | |
183 %%%%%%%%%% h = history(proctime, minfo, plist, in_names, oldUUID, in_hists) %%%% | |
184 | |
185 %%% Use default values | |
186 if ~isempty(varargin{1}) | |
187 obj.proctime = varargin{1}; | |
188 end | |
189 if ~isempty(varargin{2}) | |
190 obj.methodInfo = varargin{2}; | |
191 end | |
192 if isempty(varargin{3}) | |
193 obj.plistUsed = plist(); | |
194 else | |
195 obj.plistUsed = varargin{3}; | |
196 end | |
197 | |
198 if ~isempty(varargin{4}) | |
199 obj.methodInvars = varargin{4}; | |
200 end | |
201 if ~isempty(varargin{5}) | |
202 % Don't store the 'old' UUID inside the history object because we | |
203 % use the UUID of the history object for creating the history | |
204 % tree. For this it is necessary that the history have its own | |
205 % independent UUID. | |
206 % | |
207 obj.UUID = varargin{5}; | |
208 end | |
209 if ~isempty(varargin{6}) | |
210 obj.inhists = varargin{6}; | |
211 end | |
212 | |
213 otherwise | |
214 error('### Unknown number of constructor arguments.'); | |
215 end | |
216 | |
217 end | |
218 | |
219 end | |
220 | |
221 | |
222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
223 % Methods (public) % | |
224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
225 | |
226 methods | |
227 %%% Define Abstract methods | |
228 varargout = char(varargin) | |
229 varargout = copy(varargin) | |
230 varargout = display(varargin) | |
231 | |
232 varargout = getNodes(varargin) | |
233 varargout = hist2dot(varargin) | |
234 varargout = hist2m(varargin) | |
235 varargout = plot(varargin) | |
236 varargout = string(varargin) | |
237 end | |
238 | |
239 methods (Hidden = true) | |
240 varargout = attachToDom(varargin) | |
241 varargout = getObjectClass(varargin); | |
242 varargout = setObjectClass(varargin); | |
243 end | |
244 | |
245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
246 % Methods (protected) % | |
247 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
248 | |
249 methods (Access = protected) | |
250 varargout = fromStruct(varargin) | |
251 varargout = fromDom(varargin) | |
252 end | |
253 | |
254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
255 % Methods (private) % | |
256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
257 | |
258 methods (Access = private) | |
259 end | |
260 | |
261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
262 % Methods (Static, Public) % | |
263 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
264 | |
265 methods (Static = true) | |
266 | |
267 function out = VEROUT() | |
268 out = '$Id: history.m,v 1.72 2011/03/28 17:02:27 ingo Exp $'; | |
269 end | |
270 | |
271 function ii = getInfo(varargin) | |
272 ii = utils.helper.generic_getInfo(varargin{:}, 'history'); | |
273 end | |
274 | |
275 function out = SETS() | |
276 out = {'Default'}; | |
277 end | |
278 | |
279 function out = getDefaultPlist(set) | |
280 switch lower(set) | |
281 case 'default' | |
282 out = plist(); | |
283 | |
284 otherwise | |
285 error('### Unknown set [%s]', set); | |
286 end | |
287 end | |
288 | |
289 function obj = initObjectWithSize(n,m) | |
290 obj = history.newarray([n m]); | |
291 end | |
292 | |
293 end | |
294 | |
295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
296 % Methods (Static, Private) % | |
297 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
298 | |
299 methods (Static = true, Access = private) | |
300 end | |
301 | |
302 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
303 % Methods (static, hidden) % | |
304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
305 | |
306 methods (Static = true, Hidden = true) | |
307 varargout = loadobj(varargin) | |
308 varargout = update_struct(varargin); | |
309 end | |
310 | |
311 end |