ALMaSS Rabbit ODdox  1.1
The rabbit model description following ODdox protocol
MapErrorMsg Class Reference

#include <maperrormsg.h>

Public Member Functions

void Warn (MapErrorState a_level, std::string a_msg1, std::string a_msg2)
 
void Warn (MapErrorState a_level, std::string a_msg1, int)
 
void Warn (std::string a_msg1, std::string a_msg2)
 
void Warn (std::string a_msg1, double a_num)
 
void WarnAddInfo (MapErrorState a_level, std::string a_add1, std::string a_add2)
 
void WarnAddInfo (MapErrorState a_level, std::string a_add1, double a_num)
 
void SetWarnLevel (MapErrorState a_level)
 
 MapErrorMsg (std::string a_warnfile)
 

Private Attributes

MapErrorState m_level
 
std::string m_warnfile
 

Detailed Description

Definition at line 43 of file maperrormsg.h.

Constructor & Destructor Documentation

◆ MapErrorMsg()

MapErrorMsg::MapErrorMsg ( std::string  a_warnfile)

Definition at line 43 of file maperrormsg.cpp.

44 {
45  m_warnfile = a_warnfile;
46 }

References m_warnfile.

Member Function Documentation

◆ SetWarnLevel()

void MapErrorMsg::SetWarnLevel ( MapErrorState  a_level)

Definition at line 48 of file maperrormsg.cpp.

49 {
50  if ( a_level > WARN_BUG && a_level <= WARN_ALL )
51  m_level = a_level;
52  else {
53  m_level = WARN_ALL;
54  Warn( WARN_BUG, "MapErrorMsg::SetWarnLevel(): Illegal error level!", "");
55  exit(1);
56  }
57 }

References m_level, Warn(), WARN_ALL, and WARN_BUG.

◆ Warn() [1/4]

void MapErrorMsg::Warn ( MapErrorState  a_level,
std::string  a_msg1,
int  a_msg2 
)

Definition at line 83 of file maperrormsg.cpp.

84 {
85  FILE * EFile;
86  time_t aclock;
87  tm* newtime;
88  time(&aclock); // Get time in seconds.
89  newtime = localtime(&aclock); // Convert time to struct tm form.
90 
91  // Print local time as a string
92  EFile = fopen(m_warnfile.c_str(), "a+");
93  if (!EFile) {
94  fprintf(stderr, "MapErrorMsg::Warn(): Unable to open file"
95  " for error messages: %s\n", m_warnfile.c_str());
96  exit(1);
97  }
98 
99  fprintf(EFile, "%s Level %d *****\n%s %d\n",
100  asctime(newtime), a_level, a_msg1.c_str(), a_msg2);
101  fflush(EFile);
102  fclose(EFile);
103 }

References m_warnfile.

◆ Warn() [2/4]

void MapErrorMsg::Warn ( MapErrorState  a_level,
std::string  a_msg1,
std::string  a_msg2 
)

Definition at line 59 of file maperrormsg.cpp.

62 {
63  FILE * EFile;
64  time_t aclock;
65  tm* newtime;
66  time(&aclock); // Get time in seconds.
67  newtime = localtime(&aclock); // Convert time to struct tm form.
68 
69  // Print local time as a string
70  EFile = fopen(m_warnfile.c_str(), "a+");
71  if (!EFile) {
72  fprintf(stderr, "MapErrorMsg::Warn(): Unable to open file"
73  " for error messages: %s\n", m_warnfile.c_str());
74  exit(1);
75  }
76 
77  fprintf(EFile, "%s Level %d *****\n%s %s\n",
78  asctime(newtime), a_level, a_msg1.c_str(), a_msg2.c_str());
79  fflush(EFile);
80  fclose(EFile);
81 }

References m_warnfile.

Referenced by OptimisingFarm::ActualProfit(), Landscape::AddBeetleBanks(), LE_TypeClass::BackTranslateEleTypes(), LE_TypeClass::BackTranslateVegTypes(), Landscape::BorderAdd(), Landscape::BorderNeed(), Landscape::BorderScan(), RasterMap::CellReplacementNeighbour(), Landscape::CentroidSpiralOut(), Farm::CheckRotationManagementLoop(), Crop::ChooseNextCrop(), FarmManager::ConnectFarm(), Landscape::ConsolidatePolys(), FarmManager::CreateFarms(), CropRotation::CropRotation(), Calendar::DayLength(), AnimalFarm::determineMinFodder(), FarmManager::DumpFarmrefs(), Landscape::DumpMapGraphics(), Landscape::DumpMapInfoByArea(), PesticideMap::DumpPMap(), Configurator::DumpSymbols(), Landscape::DumpTreatCounters(), Landscape::EventDump(), Landscape::EventDumpPesticides(), Landscape::EventtypeToString(), Configurator::ExtractString(), probe_data::FileAppendOutput(), OptimisingFarm::Find_neighbour_to_imitate(), FarmManager::FindClosestFarm(), FarmManager::FindClosestFarmOpenness(), FarmManager::FindClosestFarmOpennessProb(), FarmManager::FindClosestFarmOpennessProbNearRoostIsBest(), FarmManager::FindClosestFarmOpennessProbSmallIsBest(), OptimisingFarm::findCropByName(), OptimisingFarm::findCropByName_almass(), FarmManager::FindFarmWithOpenness(), FarmManager::FindFarmWithRandom(), Landscape::ForceArea(), RasterMap::Get(), DataForOptimisation::Get_farmType(), FarmManager::GetFarmCentroid(), FarmManager::GetFarmPtr(), CropRotation::GetFirstCrop(), CropRotation::GetNextCrop(), FarmManager::GetRenumberedFarmRef(), Landscape::GISASCII_Output(), OptimisingFarm::HandleEvents(), Landscape::IncTreatCounter(), RasterMap::Init1(), RasterMap::Init2(), OptimisingFarm::Initialize(), Farm::InitiateManagement(), Landscape::InitOsmiaBeeNesting(), Rabbit_Juvenile::InternalPesticideHandlingAndResponse(), Rabbit_Male::InternalPesticideHandlingAndResponse(), Rabbit_Female::InternalPesticideHandlingAndResponse(), Farm::InvIntPartition(), Landscape::Landscape(), Farm::LeSwitch(), Rabbit_Population_Manager::LoadWarrenLocations(), OptimisingFarm::Make_rotations(), Farm::Management(), OptimisingFarm::Match_crop_to_field(), Landscape::NewElement(), probe_data::OpenFile(), probe_data::OpenForAppendToFile(), Population_Manager::OpenTheMonthlyRipleysOutputProbe(), Population_Manager::OpenTheReallyBigProbe(), Population_Manager::OpenTheRipleysOutputProbe(), Configurator::ParseCfgLine(), PollenNectarDevelopmentData::PollenNectarDevelopmentData(), Landscape::PolysDump(), Landscape::PolysRenumber(), Landscape::PolysValidate(), Landscape::PolytypeToString(), FarmManager::PrintOutput(), OptimisingFarm::randomizeCropList(), RasterMap::RasterMap(), VegElement::ReadBugPercentageFile(), FarmManager::ReadCropsData_perFarm_and_Soil_and_Size_almass(), FarmManager::ReadCropsData_perFarmType_almass(), FarmManager::ReadCropsData_perSoilType_almass(), Landscape::ReadPolys2(), Farm::ReadRotation(), Configurator::ReadSymbols(), Farm::RemoveField(), Landscape::RemoveSmallPolygons(), Pesticide::SavePPM(), Rabbit_Population_Manager::SaveWarrenLocations(), CfgInt::set(), CfgFloat::set(), Configurator::SetCfgBool(), Configurator::SetCfgFloat(), Configurator::SetCfgGatekeeper(), Configurator::SetCfgInt(), Configurator::SetCfgStr(), PlantGrowthData::SetVegNum(), SetWarnLevel(), OptimisingFarm::total(), OptimisingFarm::Translate_crops_to_almass(), FarmManager::TranslateAnimalsCodes(), FarmManager::TranslateCropCodes(), FarmManager::TranslateCropsCodes(), FarmManager::TranslateCropVariablesCodes(), LE_TypeClass::TranslateEleTypes(), FarmManager::TranslateFarmCodes(), FarmManager::TranslateFarmSizeCodes(), FarmManager::TranslateLivestockParametersCodes(), FarmManager::TranslateParametersCodes(), FarmManager::TranslateSoilCodes(), LE_TypeClass::TranslateVegTypes(), Landscape::UnsprayedMarginAdd(), UserDefinedFarm::UserDefinedFarm(), Landscape::VegDump(), PlantGrowthData::VegTypeToCurveNum(), Landscape::VegtypeToString(), Landscape::Warn(), and Weather::Weather().

◆ Warn() [3/4]

void MapErrorMsg::Warn ( std::string  a_msg1,
double  a_num 
)

Definition at line 127 of file maperrormsg.cpp.

128 {
129  FILE * EFile;
130  time_t aclock;
131  tm* newtime;
132  time( &aclock ); // Get time in seconds.
133  newtime=localtime( &aclock ); // Convert time to struct tm form.
134  // Print local time as a string.
135 
136  EFile=fopen(m_warnfile.c_str(), "a+" );
137  if ( !EFile ) {
138  fprintf(stderr, "MapErrorMsg::Warn(): Unable to open file"
139  " for error messages: %s\n", m_warnfile.c_str() );
140  exit(1);
141  }
142 
143  fprintf( EFile, "%s *****\n%s %g\n",
144  asctime(newtime), a_msg1.c_str(), a_num );
145  fflush( EFile );
146  fclose( EFile );
147 }

References m_warnfile.

◆ Warn() [4/4]

void MapErrorMsg::Warn ( std::string  a_msg1,
std::string  a_msg2 
)

Definition at line 105 of file maperrormsg.cpp.

106 {
107  FILE * EFile;
108  time_t aclock;
109  tm* newtime;
110  time( &aclock ); // Get time in seconds.
111  newtime=localtime( &aclock ); // Convert time to struct tm form.
112  // Print local time as a string.
113 
114  EFile=fopen(m_warnfile.c_str(), "a+" );
115  if ( !EFile ) {
116  fprintf(stderr, "MapErrorMsg::Warn(): Unable to open file"
117  " for error messages: %s\n", m_warnfile.c_str() );
118  exit(1);
119  }
120 
121  fprintf( EFile, "%s *****\n%s %s\n",
122  asctime(newtime), a_msg1.c_str(), a_msg2.c_str() );
123  fflush( EFile );
124  fclose( EFile );
125 }

References m_warnfile.

◆ WarnAddInfo() [1/2]

void MapErrorMsg::WarnAddInfo ( MapErrorState  a_level,
std::string  a_add1,
double  a_num 
)

Definition at line 164 of file maperrormsg.cpp.

165 {
166  if (a_level > m_level) return;
167  ofstream *EFile;
168  EFile = new ofstream(m_warnfile.c_str(), ios::app);
169  if (!EFile->is_open()) {
170  fprintf(stderr, "MapErrorMsg::Warn(): Unable to open file"
171  " for error messages: %s\n", m_warnfile.c_str());
172  exit(1);
173  }
174  (*EFile) << a_add1.c_str() << a_num << endl;
175  EFile->close();
176 }

References m_level, and m_warnfile.

◆ WarnAddInfo() [2/2]

void MapErrorMsg::WarnAddInfo ( MapErrorState  a_level,
std::string  a_add1,
std::string  a_add2 
)

Definition at line 149 of file maperrormsg.cpp.

150 {
151  FILE * EFile;
152  if (a_level > m_level) return;
153  EFile = fopen(m_warnfile.c_str(), "a+");
154  if (!EFile) {
155  fprintf(stderr, "MapErrorMsg::Warn(): Unable to open file"
156  " for error messages: %s\n", m_warnfile.c_str());
157  exit(1);
158  }
159  fprintf(EFile, "%s%s", a_add1.c_str(), a_add2.c_str());
160  fflush(EFile);
161  fclose(EFile);
162 }

References m_level, and m_warnfile.

Referenced by RasterMap::Get(), RasterMap::Init2(), and Configurator::ShowIdType().

Member Data Documentation

◆ m_level

MapErrorState MapErrorMsg::m_level
private

Definition at line 45 of file maperrormsg.h.

Referenced by SetWarnLevel(), and WarnAddInfo().

◆ m_warnfile

std::string MapErrorMsg::m_warnfile
private

Definition at line 46 of file maperrormsg.h.

Referenced by MapErrorMsg(), Warn(), and WarnAddInfo().


The documentation for this class was generated from the following files:
WARN_BUG
Definition: maperrormsg.h:34
MapErrorMsg::m_level
MapErrorState m_level
Definition: maperrormsg.h:45
WARN_ALL
Definition: maperrormsg.h:40
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
MapErrorMsg::m_warnfile
std::string m_warnfile
Definition: maperrormsg.h:46