Mercurial > hg > ltpda
comparison m-toolbox/classes/@history/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.12 2011/03/28 17:02:27 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 %%% Get version | |
33 if isfield(obj_struct, 'version') | |
34 version = obj_struct.version; | |
35 else | |
36 version = 'dummy version from update_struct'; | |
37 end | |
38 | |
39 %%% methodInfo | |
40 if isfield(obj_struct, 'name') | |
41 ii = minfo(obj_struct.name, 'history', 'ltpda', '', version, {''}, plist, 0, 0); | |
42 obj_struct.methodInfo = ii; | |
43 end | |
44 | |
45 %%% proctime | |
46 if ~isfield(obj_struct, 'proctime') | |
47 if isfield(obj_struct, 'created') && (isfield(obj_struct.created, 'utc_epoch_milli') || isprop(obj_struct.created, 'utc_epoch_milli')) | |
48 obj_struct.proctime = obj_struct.created.utc_epoch_milli; | |
49 else | |
50 obj_struct.proctime = time().utc_epoch_milli; | |
51 end | |
52 end | |
53 | |
54 %%% methodInvars | |
55 if isfield(obj_struct, 'invars') | |
56 obj_struct.methodInvars = obj_struct.invars; | |
57 end | |
58 | |
59 %%% plistUsed | |
60 if isfield(obj_struct, 'plist') | |
61 obj_struct.plistUsed = obj_struct.plist; | |
62 end | |
63 | |
64 catch ME | |
65 disp(varargin{1}); | |
66 throw(addCause(ME, MException('MATLAB:LTPDA','### The struct (history) above is not from version 1.0'))); | |
67 end | |
68 | |
69 struct_ver = '1.9.1'; | |
70 end | |
71 | |
72 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.1' ->'1.9.2' %%%%%%%%%%%%%%%%%%%%%%% | |
73 | |
74 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
75 strcmp(struct_ver, '1.9.1') | |
76 | |
77 struct_ver = '1.9.2'; | |
78 end | |
79 | |
80 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.2' ->'1.9.3' %%%%%%%%%%%%%%%%%%%%%%% | |
81 | |
82 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
83 strcmp(struct_ver, '1.9.2') | |
84 | |
85 struct_ver = '1.9.3'; | |
86 end | |
87 | |
88 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.3' ->'1.9.4' %%%%%%%%%%%%%%%%%%%%%%% | |
89 | |
90 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
91 strcmp(struct_ver, '1.9.3') | |
92 | |
93 struct_ver = '1.9.4'; | |
94 end | |
95 | |
96 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.4' ->'2.0' %%%%%%%%%%%%%%%%%%%%%%% | |
97 | |
98 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
99 strcmp(struct_ver, '1.9.4') | |
100 | |
101 struct_ver = '2.0'; | |
102 end | |
103 | |
104 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0' ->'2.0.1' %%%%%%%%%%%%%%%%%%%%%%% | |
105 | |
106 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
107 strcmp(struct_ver, '2.0') | |
108 | |
109 struct_ver = '2.0.1'; | |
110 end | |
111 | |
112 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0.1' ->'2.1' %%%%%%%%%%%%%%%%%%%%%%% | |
113 | |
114 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
115 strcmp(struct_ver, '2.0.1') | |
116 | |
117 struct_ver = '2.1'; | |
118 end | |
119 | |
120 varargout{1} = obj_struct; | |
121 end | |
122 |