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

Method LoadCell

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

Source from the content-addressed store, hash-verified

661}
662
663bool cEnvironment::LoadCell(cString desc, Feedback& feedback)
664
665/*****************************************************************************
666 Routine to read in spatial resources loaded in one cell at a time. Syntax:
667
668 CELL resource_name:cell_list[:options]
669
670 where options are initial, inflow and outflow
671 *****************************************************************************/
672
673{
674 if (desc.GetSize() == 0) {
675 feedback.Warning("CELL line with no resources listed");
676 return false;
677 }
678
679 cResource* this_resource;
680 while (desc.GetSize() > 0) {
681 cString cur_resource = desc.PopWord();
682 const cString name = cur_resource.Pop(':');
683
684 /* if this resource has not been already created go ahead and create it and
685 set some default global values */
686
687 if (! resource_lib.DoesResourceExist(name)) {
688 this_resource = resource_lib.AddResource(name);
689 this_resource->SetInitial(0.0);
690 this_resource->SetInflow(0.0);
691 this_resource->SetOutflow(0.0);
692 this_resource->SetGeometry("GRID");
693 this_resource->SetInflowX1(cResource::NONE);
694 this_resource->SetInflowX2(cResource::NONE);
695 this_resource->SetInflowY1(cResource::NONE);
696 this_resource->SetInflowY2(cResource::NONE);
697 this_resource->SetOutflowX1(cResource::NONE);
698 this_resource->SetOutflowX2(cResource::NONE);
699 this_resource->SetOutflowY1(cResource::NONE);
700 this_resource->SetOutflowY2(cResource::NONE);
701 this_resource->SetXDiffuse(0.0);
702 this_resource->SetXGravity(0.0);
703 this_resource->SetYDiffuse(0.0);
704 this_resource->SetYGravity(0.0);
705 this_resource->SetDemeResource("false");
706 } else {
707 this_resource = resource_lib.GetResource(name);
708 }
709 cString cell_list_str = cur_resource.Pop(':');
710 Apto::Array<int> cell_list = cStringUtil::ReturnArray(cell_list_str);
711 double tmp_initial = 0.0;
712 double tmp_inflow = 0.0;
713 double tmp_outflow = 0.0;
714 while (cur_resource.GetSize() != 0) {
715 cString var_entry = cur_resource.Pop(':');
716 cString var_name;
717 cString var_value;
718 const cString var_type =
719 cStringUtil::Stringf("resource '%s'", static_cast<const char*>(name));
720

Callers

nothing calls this directly

Calls 15

PopWordMethod · 0.80
DoesResourceExistMethod · 0.80
AddResourceMethod · 0.80
SetXDiffuseMethod · 0.80
SetXGravityMethod · 0.80
SetYDiffuseMethod · 0.80
SetYGravityMethod · 0.80
GetCellResourcePtrMethod · 0.80
UpdateCellResourceMethod · 0.80
AddCellResourceMethod · 0.80
GetSizeMethod · 0.45
WarningMethod · 0.45

Tested by

no test coverage detected