comparison m-toolbox/classes/@miir/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.10 2011/03/28 12:45:46 hewitson 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 %%% a
34 if isfield(obj_struct, 'gain') && ~isempty(obj_struct.gain) && obj_struct.gain ~= 0
35 obj_struct.a = obj_struct.a * obj_struct.gain;
36 end
37
38 %%% creator
39 if isfield(obj_struct, 'provenance') && ~isfield(obj_struct, 'creator')
40 obj_struct.creator = obj_struct.provenance;
41 elseif ~isfield(obj_struct, 'creator')
42 obj_struct.creator = provenance('Updater 1.0 -> 1.9.1');
43 end
44
45 %%%%% hist
46 if ~isfield(obj_struct, 'hist')
47 if isfield(obj_struct, 'class')
48 cn = obj_struct.class;
49 else
50 cn = 'unknown class. updater';
51 end
52 ii = minfo('update_struct', cn, 'ltpda', '', ...
53 '$Id: update_struct.m,v 1.10 2011/03/28 12:45:46 hewitson Exp $', ...
54 {'Default'}, plist(), 0, 0);
55 obj_struct.hist = history(time().utc_epoch_milli, ii, obj_struct.plist);
56 end
57
58 catch ME
59 disp(varargin{1});
60 throw(addCause(ME, MException('MATLAB:LTPDA','### The struct (miir) above is not from version 1.0')));
61 end
62
63 struct_ver = '1.9.1';
64 end
65
66 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.1' ->'1.9.2' %%%%%%%%%%%%%%%%%%%%%%%
67
68 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
69 strcmp(struct_ver, '1.9.1')
70
71 struct_ver = '1.9.2';
72 end
73
74 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.2' ->'1.9.3' %%%%%%%%%%%%%%%%%%%%%%%
75
76 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
77 strcmp(struct_ver, '1.9.2')
78
79 struct_ver = '1.9.3';
80 end
81
82 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.3' ->'1.9.4' %%%%%%%%%%%%%%%%%%%%%%%
83
84 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
85 strcmp(struct_ver, '1.9.3')
86
87 %%% created
88 if isfield(obj_struct, 'created')
89 obj_struct = rmfield(obj_struct, 'created');
90 end
91
92 %%% creator
93 if isfield(obj_struct, 'creator')
94 obj_struct = rmfield(obj_struct, 'creator');
95 end
96
97 struct_ver = '1.9.4';
98 end
99
100 %%% ntaps
101 if isfield(obj_struct, 'ntaps')
102 obj_struct = rmfield(obj_struct, 'ntaps');
103 end
104
105 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.4' ->'2.0' %%%%%%%%%%%%%%%%%%%%%%%
106
107 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
108 strcmp(struct_ver, '1.9.4')
109
110 struct_ver = '2.0';
111 end
112
113 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0' ->'2.0.1' %%%%%%%%%%%%%%%%%%%%%%%
114
115 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
116 strcmp(struct_ver, '2.0')
117
118 struct_ver = '2.0.1';
119 end
120
121 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0.1' ->'2.1' %%%%%%%%%%%%%%%%%%%%%%%
122
123 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
124 strcmp(struct_ver, '2.0.1')
125
126 struct_ver = '2.1';
127 end
128
129 varargout{1} = obj_struct;
130 end
131