MCPcopy Create free account
hub / github.com/devosoft/avida / Load

Method Load

avida-core/source/main/cEnvironment.cc:1213–1249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1211}
1212
1213bool 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
1252void cEnvironment::SetupInputs(cAvidaContext& ctx, Apto::Array<int>& input_array, bool random) const

Callers 9

ProcessMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
setupMethod · 0.45
InitWithDirectoryMethod · 0.45
InitWithDirectoryMethod · 0.45
processArgsFunction · 0.45

Calls 12

WasOpenedMethod · 0.80
GetNumMessagesMethod · 0.80
GetNumLinesMethod · 0.80
GetTaskMethod · 0.80
GetMessageTypeMethod · 0.45
ErrorMethod · 0.45
WarningMethod · 0.45
NotifyMethod · 0.45
GetLineMethod · 0.45
GetSizeMethod · 0.45
GetReactionMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected