-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodelParameter.m
65 lines (57 loc) · 2.25 KB
/
modelParameter.m
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
classdef (Abstract) modelParameter
%modelParameter A value which controls a model option.
% Every parameter should be defined as an instance of this class so
% important information about that parameter is available. Example
% parameters include output directories, evolution on/off, super
% symbiont options, and number of worker threads.
properties
category char
name char
dataType char
needsMinMax logical
nullAllowed logical
end
methods
function obj = modelParameter(cat, name, type)
%modelParameter Construct an instance of this class
% Detailed explanation goes here
if nargin ~= 3
error('Parameters must be defined with a name and type.');
end
% False for everything except keyReefs, at least at first:
obj.nullAllowed = false;
% Accept either a character array or a string for each input.
if ischar(name)
obj.name = name;
else
error('Parameters must be given a text (string) name.');
end
if ischar(cat)
obj.category = cat;
else
error('Parameters must be given a text (string) category.');
end
if ischar(type)
obj.dataType = type;
obj.needsMinMax = false;
switch obj.dataType
case 'integer'
obj.needsMinMax = true;
case 'logical'
case 'double'
obj.needsMinMax = true;
case 'string'
otherwise
error('Parameter type must be integer, logical, double, or string.');
end
else
error('Parameter type must be a string, and one of integer, logical, double, or string.');
end
end
function vs = asString(obj)
% Returns the value as a string - non-char parameters should
% override this.
vs = obj.value; %#ok<MCNPN> % Becomes valid in subclasses.
end
end
end