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

Method LoadStructuredSystematicsGroup

avida-core/source/main/cPopulation.cc:6557–6588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6555}
6556
6557bool cPopulation::LoadStructuredSystematicsGroup(cAvidaContext& ctx, const Systematics::RoleID& role, const cString& filename)
6558{
6559 cInitFile input_file(filename, m_world->GetWorkingDir(), ctx.Driver().Feedback());
6560 if (!input_file.WasOpened()) return false;
6561
6562
6563 Systematics::ManagerPtr classmgr = Systematics::Manager::Of(m_world->GetNewWorld());
6564 Systematics::ArbiterPtr arbiter = classmgr->ArbiterForRole(role);
6565
6566 for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
6567 cString cur_line = input_file.GetLine(line_id);
6568
6569 // Setup the group for this line...
6570 Apto::SmartPtr<Apto::Map<Apto::String, Apto::String> > props = input_file.GetLineAsDict(line_id);
6571 Systematics::GroupPtr grp = arbiter->LegacyLoad(&props);
6572
6573 // Process resident cell ids
6574 cString cellstr(props->Get("cells"));
6575 if (cellstr.GetSize()) {
6576 while (cellstr.GetSize()) {
6577 int cell_id = cellstr.Pop(',').AsInt();
6578 if (cell_array[cell_id].IsOccupied()) {
6579 Systematics::UnitPtr unit(cell_array[cell_id].GetOrganism());
6580 cell_array[cell_id].GetOrganism()->AddReference(); // creating new smart pointer to org, explicitly add reference
6581 unit->AddClassification(grp->ClassifyNewUnit(unit, Systematics::ConstGroupMembershipPtr(NULL)));
6582 }
6583 }
6584 }
6585 }
6586
6587 return true;
6588}
6589
6590bool cPopulation::SaveFlameData(const cString& filename)
6591{

Callers 1

ProcessMethod · 0.80

Calls 15

FeedbackMethod · 0.80
WasOpenedMethod · 0.80
GetNewWorldMethod · 0.80
ArbiterForRoleMethod · 0.80
GetNumLinesMethod · 0.80
GetLineAsDictMethod · 0.80
IsOccupiedMethod · 0.80
AddClassificationMethod · 0.80
DriverMethod · 0.45
GetLineMethod · 0.45
LegacyLoadMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected