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

Method LoadFile

avida-core/source/analyze/cAnalyze.cc:770–858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

768}
769
770void cAnalyze::LoadFile(cString cur_string)
771{
772 // LOAD
773
774 cString filename = cur_string.PopWord();
775
776 cout << "Loading: " << filename << endl;
777
778 cInitFile input_file(filename, m_world->GetWorkingDir());
779 if (!input_file.WasOpened()) {
780 const cUserFeedback& feedback = input_file.GetFeedback();
781 for (int i = 0; i < feedback.GetNumMessages(); i++) {
782 switch (feedback.GetMessageType(i)) {
783 case cUserFeedback::UF_ERROR: cerr << "error: "; break;
784 case cUserFeedback::UF_WARNING: cerr << "warning: "; break;
785 default: break;
786 };
787 cerr << feedback.GetMessage(i) << endl;
788 }
789 if (exit_on_error) exit(1);
790 }
791
792 const cString filetype = input_file.GetFiletype();
793 if (filetype != "population_data" && // Deprecated
794 filetype != "genotype_data") {
795 cerr << "error: cannot load files of type \"" << filetype << "\"." << endl;
796 if (exit_on_error) exit(1);
797 }
798
799 if (m_world->GetVerbosity() >= VERBOSE_ON) {
800 cout << "Loading file of type: " << filetype << endl;
801 }
802
803
804 // Construct a linked list of data types that can be loaded...
805 tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
806 tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
807 cUserFeedback feedback;
808 cAnalyzeGenotype::GetDataCommandManager().LoadCommandList(input_file.GetFormat(), output_list, &feedback);
809
810 for (int i = 0; i < feedback.GetNumMessages(); i++) {
811 switch (feedback.GetMessageType(i)) {
812 case cUserFeedback::UF_ERROR: cerr << "error: "; break;
813 case cUserFeedback::UF_WARNING: cerr << "warning: "; break;
814 default: break;
815 };
816 cerr << feedback.GetMessage(i) << endl;
817 }
818
819 if (feedback.GetNumErrors()) return;
820
821 bool id_inc = input_file.GetFormat().HasString("id");
822
823 // Setup the genome...
824 const cInstSet& is = m_world->GetHardwareManager().GetDefaultInstSet();
825 HashPropertyMap props;
826 cHardwareManager::SetupPropertyMap(props, (const char*)is.GetInstSetName());
827 Genome default_genome(is.GetHardwareType(), props, GeneticRepresentationPtr(new InstructionSequence(1)));

Callers 1

LoadResourcesMethod · 0.45

Calls 15

PopWordMethod · 0.80
WasOpenedMethod · 0.80
GetNumMessagesMethod · 0.80
GetVerbosityMethod · 0.80
GetNumErrorsMethod · 0.80
HasStringMethod · 0.80
GetHardwareTypeMethod · 0.80
GetNumLinesMethod · 0.80
SetAlignedMethod · 0.80
GetMessageTypeMethod · 0.45
LoadCommandListMethod · 0.45
GetLineMethod · 0.45

Tested by

no test coverage detected