| 1211 | } |
| 1212 | |
| 1213 | bool cEnvironment::Load(const cString& filename, const cString& working_dir, Feedback& feedback, const Apto::Map<Apto::String, Apto::String>* defs) |
| 1214 | { |
| 1215 | cInitFile infile(filename, working_dir, NULL, defs); |
| 1216 | if (!infile.WasOpened()) { |
| 1217 | for (int i = 0; i < infile.GetFeedback().GetNumMessages(); i++) { |
| 1218 | switch (infile.GetFeedback().GetMessageType(i)) { |
| 1219 | case cUserFeedback::UF_ERROR: |
| 1220 | feedback.Error(infile.GetFeedback().GetMessage(i)); |
| 1221 | break; |
| 1222 | case cUserFeedback::UF_WARNING: |
| 1223 | feedback.Warning(infile.GetFeedback().GetMessage(i)); |
| 1224 | break; |
| 1225 | default: |
| 1226 | feedback.Notify(infile.GetFeedback().GetMessage(i)); |
| 1227 | } |
| 1228 | } |
| 1229 | feedback.Error("failed to load environment '%s'", (const char*)filename); |
| 1230 | return false; |
| 1231 | } |
| 1232 | |
| 1233 | for (int line_id = 0; line_id < infile.GetNumLines(); line_id++) { |
| 1234 | // Load the next line from the file. |
| 1235 | bool load_ok = LoadLine(infile.GetLine(line_id), feedback); |
| 1236 | if (load_ok == false) return false; |
| 1237 | } |
| 1238 | |
| 1239 | // Make sure that all pre-declared reactions have been loaded correctly. |
| 1240 | for (int i = 0; i < reaction_lib.GetSize(); i++) { |
| 1241 | if (reaction_lib.GetReaction(i)->GetTask() == NULL) { |
| 1242 | feedback.Error("pre-declared reaction '%s' never defined", |
| 1243 | (const char*)reaction_lib.GetReaction(i)->GetName()); |
| 1244 | return false; |
| 1245 | } |
| 1246 | } |
| 1247 | |
| 1248 | return true; |
| 1249 | } |
| 1250 | |
| 1251 | |
| 1252 | void cEnvironment::SetupInputs(cAvidaContext& ctx, Apto::Array<int>& input_array, bool random) const |
no test coverage detected