1 package nl.tudelft.goal.unreal.messages;
2
3 import java.net.URI;
4 import java.net.URISyntaxException;
5 import java.util.ArrayList;
6 import java.util.List;
7 import java.util.logging.Level;
8
9 import cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController;
10
11
12
13
14
15
16
17
18
19 public class Configuration {
20
21 public static final Level DEFAULT_LOG_LEVEL = Level.WARNING;
22 public static final String DEFAULT_BOT_NAME = "UnrealGOALBot";
23 public static final String CONTROL_SERVER = "ut://127.0.0.1:3001";
24 public static final String BOT_SERVER = "ut://127.0.0.1:3000";
25
26 private static final URI VISUALIZER_SERVER = null;
27
28 private List<BotParameters> bots;
29 private URI visualizer;
30 private URI botServer;
31 private URI controlServer;
32
33 private Level logLevel;
34
35 private Class<? extends IUT2004BotController> botControllerClass;
36
37 public List<BotParameters> getBots() {
38 return bots == null? new ArrayList<BotParameters>() : bots;
39 }
40
41 public void setBots(List<BotParameters> bots) {
42 this.bots = bots;
43 }
44
45 public URI getVisualizer() {
46 return visualizer;
47 }
48
49 public void setVisualizer(URI visualizer) {
50 this.visualizer = visualizer;
51 }
52
53 public URI getBotServer() {
54 return botServer;
55 }
56
57 public void setBotServer(URI botServer) {
58 this.botServer = botServer;
59 }
60
61 public URI getControlServer() {
62 return controlServer;
63 }
64
65 public void setControlServer(URI controlServer) {
66 this.controlServer = controlServer;
67 }
68
69 public Configuration setLogLevel(Level level) {
70 assert level != null;
71 this.logLevel = level;
72 return this;
73 }
74
75 public Level getLogLevel() {
76 return logLevel;
77 }
78
79 public String getDefaultBotName() {
80 return DEFAULT_BOT_NAME;
81 }
82
83
84
85
86
87 public int getBotServerPort() {
88 return botServer == null ? -1 : botServer.getPort();
89 }
90
91
92
93
94
95 public String getBotServerHost() {
96 return botServer == null ? null : botServer.getHost();
97 }
98
99 public static Configuration getDefaults() {
100
101 Configuration configuration = new Configuration();
102
103 configuration.setBots(new ArrayList<BotParameters>());
104 configuration.setVisualizer(VISUALIZER_SERVER);
105
106 try {
107 configuration.setBotServer(new URI(BOT_SERVER));
108 configuration.setControlServer(new URI(CONTROL_SERVER));
109 } catch (URISyntaxException e) {
110
111 }
112
113 configuration.setLogLevel(DEFAULT_LOG_LEVEL);
114
115 return configuration;
116 }
117
118 public void assignDefaults(Configuration configuration){
119
120 if(bots == null) bots = configuration.bots;
121 if(visualizer == null) visualizer = configuration.visualizer;
122 if(botServer == null) botServer = configuration.botServer;
123 if(controlServer == null) controlServer = configuration.controlServer;
124 if(logLevel == null) logLevel = configuration.logLevel;
125
126 }
127
128 public Class<? extends IUT2004BotController> getBotControllerClass() {
129 return botControllerClass;
130 }
131
132 public void setBotControllerClass(Class<? extends IUT2004BotController> botControllerClass) {
133 this.botControllerClass = botControllerClass;
134
135 }
136
137 public int getControlServerPort() {
138 return controlServer == null? -1 : controlServer.getPort();
139 }
140
141 public String getControlServerHost() {
142 return controlServer == null? null : controlServer.getHost();
143 }
144 }