www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcmodel/@data/CommitEdit.m
function D = CommitEdit(D) %COMMITEDIT Update temporary changes in the data. % % D = COMMITEDIT(D) % % See also mbcmodel.data.BeginEdit, mbcmodel.data.RollbackEdit. % Copyright 2004-2007 The MathWorks, Inc. % Check that the object is being edited if ~D.IsBeingEdited error(message('mbc:mbcmodel:data:InvalidState1')); end % Get the modified data obj = D.Object; % This object is no longer being edited - This switches the behaviour % of D.Object from local to pointer and clears the local copy D.IsBeingEdited = false; % Check that the object is still editable and has an owner if ~D.IsEditable % And free-up the internal pointers of the modified data freeInternalPtrs(obj); error(message('mbc:mbcmodel:data:InvalidState2')); end % Different modification depending on ownership if isempty(D.Owner) % Make sure all the caches are empty obj = clearCachedInfo(obj); % Assign the new data to the old heap space D.Object = assign(D.Object, obj); else % Make sure all the caches are empty - in the ssf only obj = setCacheState(obj, false); % Tell the owner it's been modified which updates the heap with the new % data object. if isa(D.Owner,'mbcmodel.testplan') StoreResponses(D.Owner.Object); end modifyData(D.Owner.Object, D.pGetPointerInstance, obj); end % And free-up the internal pointers of the modified data freeInternalPtrs(obj);