time | Calls | line |
---|
< 0.001 | 8 | 1 | classdef (Abstract) saveLoadCompatibility
|
| | 2 |
|
| | 3 | properties(Abstract, Constant, Access='protected')
|
| | 4 | version;
|
| | 5 | end
|
| | 6 |
|
| | 7 | methods(Hidden)
|
| | 8 | function serialized = setCompatibleVersionLimit(obj, serialized, minCompatVer)
|
| | 9 | serialized.versionSavedFrom = obj.version; % scalar double. version number of saved object
|
| | 10 | serialized.minCompatibleVersion = minCompatVer; % scalar double. minimum running version required to reconstruct an instance from serialized data
|
| | 11 | serialized.incompatibilityMsg = ''; % character row vector. Addition to warning message in case of incompatible load
|
| | 12 | end
|
| | 13 |
|
| | 14 | function tf = isIncompatible(obj, serializedObj, warnMsgID)
|
| | 15 | % Warn if current version is below the minimum compatible version of the serialized object
|
| | 16 | tf = obj.version < serializedObj.minCompatibleVersion;
|
| | 17 | if tf
|
| | 18 | warnState = warning('backtrace','off'); % warn without backtrace for cleaner display
|
| | 19 | restoreWarnState = onCleanup(@()warning(warnState));
|
| | 20 | msg = strcat(getString(message(warnMsgID)), serializedObj.incompatibilityMsg);
|
| | 21 | warning(warnMsgID, msg);
|
| | 22 | end
|
| | 23 | end
|
| | 24 | end
|
| | 25 | end
|