3 function self=StructChangeTracker()
5 function [SInput,lastVersion]=applyAllLaterPatches(self,SInput,startRev)
6 lastVersion=self.getLastRevision();
11 if lastVersion>startRev
12 SInput=self.applyPatches(SInput,startRev,...
13 lastVersion,[false true]);
14 elseif lastVersion<startRev
17 'state of structure repository: latest patch version',...
18 ' is %d, version of current structure is %d'],...
19 lastVersion,startRev);
22 function lastRevNum=getLastRevision(self)
23 [~,revNumVec]=self.findPatchFuncList(-Inf,+Inf,[true true]);
27 lastRevNum=max(revNumVec);
31 function SInput=applyPatches(self,SInput,startRev,endRev,isInclusiveVec)
33 isInclusiveVec=[true true];
36 funcHandleList=self.findPatchFuncList(startRev,endRev,isInclusiveVec);
37 nFunc=length(funcHandleList);
39 SInput=feval(funcHandleList{iFunc},SInput);
43 methods(Access=
private)
44 function [funcHandleList,revNumVec]=findPatchFuncList(self,startRev,endRev,isInclusiveVec)
47 if ~islogical(isInclusiveVec)
49 'isInlcusiveVec is expected to have logical type');
51 if length(isInclusiveVec)~=2
53 'isInlcusiveVec is expected to be a vector with 2 elements');
55 metaClass=metaclass(self);
56 methodList=metaClass.Methods;
57 %isPatchVec=cellfun(@(x,y)(x.Static),methodList);
58 isPatchVec=true(size(methodList));
61 methodList=methodList(isPatchVec);
62 funcNameList=cellfun(@(x)x.Name,methodList,'UniformOutput',false);
64 [SResList]=regexp(funcNameList,...
65 '^patch_(?<patchver>\d*)','names');
66 nMatchesVec=cellfun('length',SResList);
69 ['Oops, we shouldn''t be here, regular ',...
70 'expression is incorrect']);
73 isNumOkVec=~cellfun('isempty',SResList);
74 okRevNumVec=cellfun(@(x)str2double(x.patchver),SResList(isNumOkVec));
77 isNumOkSubLeftVec=(okRevNumVec>=startRev);
79 isNumOkSubLeftVec=(okRevNumVec>startRev);
83 isNumOkSubRightVec=(okRevNumVec<=endRev);
85 isNumOkSubRightVec=(okRevNumVec<endRev);
88 isNumOkSubVec=isNumOkSubLeftVec&isNumOkSubRightVec;
89 isNumOkVec(isNumOkVec)=isNumOkSubVec;
91 okRevNumVec=okRevNumVec(isNumOkSubVec);
93 nFuncHandles=sum(isNumOkVec);
94 funcHandleList=cell(1,nFuncHandles);
95 indNumOkVec=find(isNumOkVec);
96 for iFuncHandle=1:nFuncHandles
97 funcHandleList{iFuncHandle}=eval([
'@(y)self.',...
98 funcNameList{indNumOkVec(iFuncHandle)},
'(y)']);
100 %sort the patch names by the patch number
101 [revNumVec,ind]=sort(okRevNumVec);
102 funcHandleList=funcHandleList(ind);
function throwerror(in msgTag, in varargin)
THROWERROR works similarly to built-in ERROR function in case when there is no output arguments but s...