-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgetModelVersion.m
More file actions
41 lines (32 loc) · 1.36 KB
/
getModelVersion.m
File metadata and controls
41 lines (32 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function versionNum = getModelVersion(outputType)
% Todo: save version number in prefs/singleton?
arguments
% outputType - char or VersionNumber. char is default to keep
% backwards compatibility. Todo: Deprecate char option
outputType (1,1) string ...
{mustBeMember(outputType, ["char", "VersionNumber"])} = "char"
end
persistent lastTic cachedVersionNumber
if isempty(lastTic); lastTic = uint64(0); end
if toc(lastTic) > 1
typeFolder = fullfile(openminds.internal.rootpath, 'types/');
pathSplit = strsplit(path, pathsep);
matchedIdx = find(contains(pathSplit, typeFolder));
if numel(matchedIdx) > 1
warning('Multiple openMINDS model versions are present on the search path.');
end
versionName = strrep(pathSplit{matchedIdx(1)}, typeFolder, '');
cachedVersionNumber = openminds.internal.utility.VersionNumber(versionName);
cachedVersionNumber.Format = "vX.Y";
lastTic = tic();
end
versionNum = cachedVersionNumber;
% Todo: remove. Pin latest version to v4.0 as v5.0 is not supported yet.
if versionNum == "latest"
versionNum = openminds.internal.utility.VersionNumber("4.0");
versionNum.Format = "vX.Y";
end
if outputType == "char"
versionNum = char(versionNum);
end
end