comparison m-toolbox/classes/@timespan/update_struct.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 % UPDATE_STRUCT update the input structure to the current ltpda version
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % FUNCTION: update_struct
5 %
6 % DESCRIPTION: UPDATE_STRUCT update the input structure to the current
7 % ltpda version
8 %
9 % CALL: obj_struct = update_struct(obj_struct, version_str);
10 %
11 % VERSION: $Id: update_struct.m,v 1.13 2011/03/28 12:45:44 hewitson Exp $
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function obj_struct = update_struct(obj_struct, version_str)
16
17 % get only the version string without the MATLAB version and convert to double
18 ver = utils.helper.ver2num(strtok(version_str));
19
20 % update from version 1.0
21 if ver <= utils.helper.ver2num('1.0')
22 % hist
23 if ~isfield(obj_struct, 'hist')
24 if isfield(obj_struct, 'class')
25 cn = obj_struct.class;
26 else
27 cn = 'unknown class. updater';
28 end
29 ii = minfo('update_struct', cn, 'ltpda', '', ...
30 '$Id: update_struct.m,v 1.13 2011/03/28 12:45:44 hewitson Exp $', ...
31 {'Default'}, plist(), 0, 0);
32 obj_struct.hist = history(time().utc_epoch_milli, ii, obj_struct.plist);
33 end
34 % startT
35 if ~isfield(obj_struct, 'startT') && isfield(obj_struct, 'start')
36 obj_struct.startT = obj_struct.start;
37 elseif ~isfield(obj_struct, 'startT')
38 obj_struct.startT = time(0);
39 end
40 % endT
41 if ~isfield(obj_struct, 'endT') && isfield(obj_struct, 'end')
42 obj_struct.endT = obj_struct.end;
43 elseif ~isfield(obj_struct, 'endT')
44 obj_struct.endT = time(0);
45 end
46 end
47
48 % update from version 1.9.3
49 if ver <= utils.helper.ver2num('1.9.3')
50 % created
51 if isfield(obj_struct, 'created')
52 obj_struct = rmfield(obj_struct, 'created');
53 end
54 % creator
55 if isfield(obj_struct, 'creator')
56 obj_struct = rmfield(obj_struct, 'creator');
57 end
58 end
59
60 % update from version 2.3
61 if ver <= utils.helper.ver2num('2.3')
62 % interval
63 if isfield(obj_struct, 'interval')
64 obj_struct = rmfield(obj_struct, 'interval');
65 end
66 end
67
68 % update from version 2.4
69 if ver <= utils.helper.ver2num('2.4')
70 % timeformat
71 if isfield(obj_struct, 'timeformat')
72 obj_struct = rmfield(obj_struct, 'timeformat');
73 end
74 % timezone
75 if isfield(obj_struct, 'timezone')
76 obj_struct = rmfield(obj_struct, 'timezone');
77 end
78 end
79
80 end
81