comparison m-toolbox/classes/@ao/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 2009/08/31 17:09:46 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 %%% procinfo
34 if ~isfield(obj_struct, 'procinfo')
35 obj_struct.procinfo = plist();
36 end
37
38 %%% plotinfo
39 if ~isfield(obj_struct, 'plotinfo')
40 obj_struct.plotinfo = plist();
41 end
42
43 %%% creator
44 if isfield(obj_struct, 'provenance') && ~isfield(obj_struct, 'creator')
45 obj_struct.creator = obj_struct.provenance;
46 elseif ~isfield(obj_struct, 'creator')
47 obj_struct.creator = provenance('Updater 1.0 -> 1.9.1');
48 end
49
50 catch ME
51 disp(varargin{1});
52 throw(addCause(ME, MException('MATLAB:LTPDA','### The struct (ao) above is not from version 1.0')));
53 end
54
55 struct_ver = '1.9.1';
56 end
57
58 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.1' ->'1.9.2' %%%%%%%%%%%%%%%%%%%%%%%
59
60 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
61 strcmp(struct_ver, '1.9.1')
62
63 struct_ver = '1.9.2';
64 end
65
66 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.2' ->'1.9.3' %%%%%%%%%%%%%%%%%%%%%%%
67
68 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
69 strcmp(struct_ver, '1.9.2')
70
71 struct_ver = '1.9.3';
72 end
73
74 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.3' ->'1.9.4' %%%%%%%%%%%%%%%%%%%%%%%
75
76 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
77 strcmp(struct_ver, '1.9.3')
78
79 %%% created
80 if isfield(obj_struct, 'created')
81 obj_struct = rmfield(obj_struct, 'created');
82 end
83
84 %%% creator
85 if isfield(obj_struct, 'creator')
86 obj_struct = rmfield(obj_struct, 'creator');
87 end
88
89 struct_ver = '1.9.4';
90 end
91
92 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.4' ->'2.0' %%%%%%%%%%%%%%%%%%%%%%%
93
94 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
95 strcmp(struct_ver, '1.9.4')
96
97 struct_ver = '2.0';
98 end
99
100 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0' ->'2.0.1' %%%%%%%%%%%%%%%%%%%%%%%
101
102 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
103 strcmp(struct_ver, '2.0')
104
105 struct_ver = '2.0.1';
106 end
107
108 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0.1' ->'2.1' %%%%%%%%%%%%%%%%%%%%%%%
109
110 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
111 strcmp(struct_ver, '2.0.1')
112
113 for ii = 1:numel(obj_struct)
114 if isfield(obj_struct(ii), 'mfilename') && ~isempty(obj_struct(ii).mfilename)
115 warning('!!! The field ''mfilename'' of the AO is not longer supported');
116 end
117
118 if isfield(obj_struct(ii), 'mfile') && ~isempty(obj_struct(ii).mfile)
119 warning('!!! The field ''mfile'' of the AO is not longer supported');
120 end
121
122 if isfield(obj_struct(ii), 'mdlfilename') && ~isempty(obj_struct(ii).mdlfilename)
123 warning('!!! The field ''mdlfilename'' of the AO is not longer supported');
124 end
125
126 if isfield(obj_struct(ii), 'mdlfile') && ~isempty(obj_struct(ii).mdlfile)
127 obj_struct(ii).mdlfile = '';
128 warning('!!! The field ''mdlfile'' have a new definition. Empty field.');
129 end
130 end
131
132 struct_ver = '2.1';
133 end
134
135 varargout{1} = obj_struct;
136 end
137