blob: 3e6b55ea392d3940d9919c0e588d59db06f34d85 (
plain)
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
|
package jcgp.backend.resources;
import jcgp.backend.resources.parameters.BooleanParameter;
import jcgp.backend.resources.parameters.DoubleParameter;
import jcgp.backend.resources.parameters.IntegerParameter;
/**
*
* This subclass of Resources allows modifications to be made.
* A read-only cast of this class is passed to modules for safety,
* and only classes with access to a JCGP instance may modify
* the resources.
*
* @author eddy
*
*/
public class ModifiableResources extends Resources {
public ModifiableResources() {
super();
}
public void set(String key, Object value) {
if (parameters.get(key) instanceof IntegerParameter) {
((IntegerParameter) parameters.get(key)).set(((Integer) value).intValue());
} else if (parameters.get(key) instanceof DoubleParameter) {
((DoubleParameter) parameters.get(key)).set(((Double) value).doubleValue());
} else if (parameters.get(key) instanceof BooleanParameter) {
((BooleanParameter) parameters.get(key)).set(((Boolean) value).booleanValue());
}
}
public void setFunctionSet(int index) {
functionSet = functionSets[index];
set("arity", functionSet.getMaxArity());
}
public void setConsole(Console console) {
this.console = console;
}
}
|