comparison m-toolbox/classes/@plist/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.9 2011/02/28 17:11:21 ingo Exp $
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function varargout = update_struct(varargin)
16
17 obj_struct = varargin{1};
18 struct_ver = varargin{2};
19
20 % get the version of the current toolbox
21 tbx_ver = strtok(getappdata(0, 'ltpda_version'));
22
23 % get only the version string without the MATLAB version
24 struct_ver = strtok(struct_ver);
25
26 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.0 -> 1.9.1' %%%%%%%%%%%%%%%%%%%%%%%
27
28 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
29 strcmp(struct_ver, '1.0')
30
31 try
32
33 if isfield(obj_struct, 'provenance') && ~isfield(obj_struct, 'creator')
34 obj_struct.creator = obj_struct.provenance;
35 elseif ~isfield(obj_struct, 'creator')
36 obj_struct.creator = provenance('Updater 1.0 -> 1.9.1');
37 end
38
39 catch ME
40 disp(varargin{1});
41 throw(addCause(ME, MException('MATLAB:LTPDA','### The struct (plist) above is not from version 1.0')));
42 end
43
44 struct_ver = '1.9.1';
45 end
46
47 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.1' ->'1.9.2' %%%%%%%%%%%%%%%%%%%%%%%
48
49 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
50 strcmp(struct_ver, '1.9.1')
51
52 struct_ver = '1.9.2';
53 end
54
55 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.2' ->'1.9.3' %%%%%%%%%%%%%%%%%%%%%%%
56
57 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
58 strcmp(struct_ver, '1.9.2')
59
60 struct_ver = '1.9.3';
61 end
62
63 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.3' ->'1.9.4' %%%%%%%%%%%%%%%%%%%%%%%
64
65 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
66 strcmp(struct_ver, '1.9.3')
67
68 struct_ver = '1.9.4';
69 end
70
71 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.4' ->'2.0' %%%%%%%%%%%%%%%%%%%%%%%
72
73 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
74 strcmp(struct_ver, '1.9.4')
75
76 struct_ver = '2.0';
77 end
78
79 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0' ->'2.0.1' %%%%%%%%%%%%%%%%%%%%%%%
80
81 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
82 strcmp(struct_ver, '2.0')
83
84 struct_ver = '2.0.1';
85 end
86
87 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0.1' ->'2.1' %%%%%%%%%%%%%%%%%%%%%%%
88
89 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
90 strcmp(struct_ver, '2.0.1')
91
92 if isfield(obj_struct, 'created')
93 for ii = 1:numel(obj_struct)
94 if isa(obj_struct(ii).created, 'time')
95 obj_struct(ii).created = obj_struct(ii).created.utc_epoch_milli;
96 elseif isfield(obj_struct(ii).created, 'utc_epoch_milli')
97 obj_struct(ii).created = obj_struct(ii).created.utc_epoch_milli;
98 end
99 end
100 end
101
102 struct_ver = '2.1';
103 end
104
105 varargout{1} = obj_struct;
106 end
107