ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
Probe_Data Class Reference

Data structure to hold & output probe data probe data is designed to be used to return the number of objects in a given area or areas in specific element or vegetation types or farms. More...

#include <PopulationManager.h>

Public Member Functions

void FileOutput (int No, int time, int ProbeNo) const
 
void FileAppendOutput (int No, int time) const
 
 Probe_Data ()
 
void SetFile (ofstream *F)
 
ofstream * OpenFile (const string &Nme)
 
bool OpenForAppendToFile ()
 
void CloseFile () const
 
 ~Probe_Data ()=default
 

Public Attributes

bool m_FileRecord
 
bool m_FullLandscapeProbe
 
unsigned m_ReportInterval
 
unsigned m_NoAreas
 
rectangle m_Rect [16]
 
unsigned m_NoEleTypes
 
unsigned m_NoVegTypes
 
unsigned m_NoFarms
 
TTypesOfVegetation m_RefVeg [25]
 
TTypesOfLandscapeElement m_RefEle [25]
 
unsigned m_RefFarms [25]
 
bool m_TargetTypes [16]
 

Protected Attributes

ofstream * m_MyFile
 
int m_Time
 
char m_MyFileName [255]
 

Detailed Description

Data structure to hold & output probe data probe data is designed to be used to return the number of objects in a given area or areas in specific element or vegetation types or farms.

Constructor & Destructor Documentation

◆ Probe_Data()

Probe_Data::Probe_Data ( )

Constructor for probe_data

1656  : m_MyFile(nullptr), m_Time(0), m_MyFileName{}, m_FileRecord(false),
1659 }

◆ ~Probe_Data()

Probe_Data::~Probe_Data ( )
default

Member Function Documentation

◆ CloseFile()

void Probe_Data::CloseFile ( ) const
115  {
116  if (m_MyFile != nullptr)
117  {
118  if (m_MyFile->is_open()) m_MyFile->close();
119  delete m_MyFile;
120  }
121 };

◆ FileAppendOutput()

void Probe_Data::FileAppendOutput ( int  No,
int  time 
) const
1641  {
1642  m_MyFile->open(m_MyFileName, ios::app);
1643  if (!m_MyFile->is_open())
1644  {
1645  g_msg->Warn(static_cast<MapErrorState>(0), "Cannot open file for append: ", m_MyFileName);
1646  exit(0);
1647  }
1648  if (m_FileRecord) { *m_MyFile << time << '\t' << No << endl; }
1649  m_MyFile->close();
1650 }

References g_msg, m_FileRecord, m_MyFile, m_MyFileName, and MapErrorMsg::Warn().

◆ FileOutput()

void Probe_Data::FileOutput ( int  No,
int  time,
int  ProbeNo 
) const

Basic output function of the default probe data file.
This just counts numbers in specified areas

1626  {
1627  if (m_FileRecord)
1628  {
1629  if (ProbeNo == 0)
1630  {
1631  // First probe so write the time and a new line
1632  *m_MyFile << endl;
1633  *m_MyFile << time << '\t' << No;
1634  }
1635  else *m_MyFile << '\t' << No;
1636  }
1637  (*m_MyFile).flush();
1638 }

References m_FileRecord, and m_MyFile.

Referenced by Population_Manager::ProbeReport(), Skylark_Population_Manager::ProbeReportPOM(), and Population_Manager::ProbeReportTimed().

◆ OpenFile()

ofstream * Probe_Data::OpenFile ( const string &  a_Nme)

Opens the default probe data output file

1666  {
1667  m_MyFile = new ofstream(a_Nme);
1668  if (!m_MyFile->is_open())
1669  {
1670  g_msg->Warn(static_cast<MapErrorState>(0), "probe_data::OpenFile - Cannot open file: ", a_Nme);
1671  exit(0);
1672  }
1673  return m_MyFile;
1674 }

References g_msg, m_MyFile, and MapErrorMsg::Warn().

Referenced by GetProbeInput_ini().

◆ OpenForAppendToFile()

bool Probe_Data::OpenForAppendToFile ( )
inline
448  {
449  m_MyFile = new ofstream(m_MyFileName, ios::app);
450  if (!(*m_MyFile).is_open())
451  {
452  g_msg->Warn(WARN_FILE, "PopulationManager::AppendToFile() Unable to open file for append: ", m_MyFileName);
453  exit(1);
454  }
455  return true;
456  }

References g_msg, m_MyFile, m_MyFileName, MapErrorMsg::Warn(), and WARN_FILE.

◆ SetFile()

void Probe_Data::SetFile ( ofstream *  F)

Sets the filename for the default probe data output

1680 { m_MyFile = F; }

References m_MyFile.

Member Data Documentation

◆ m_FileRecord

bool Probe_Data::m_FileRecord

◆ m_FullLandscapeProbe

◆ m_MyFile

ofstream* Probe_Data::m_MyFile
protected

◆ m_MyFileName

char Probe_Data::m_MyFileName[255]
protected

◆ m_NoAreas

◆ m_NoEleTypes

◆ m_NoFarms

◆ m_NoVegTypes

◆ m_Rect

◆ m_RefEle

◆ m_RefFarms

◆ m_RefVeg

◆ m_ReportInterval

unsigned Probe_Data::m_ReportInterval

◆ m_TargetTypes

bool Probe_Data::m_TargetTypes[16]

◆ m_Time

int Probe_Data::m_Time
protected

The documentation for this class was generated from the following files:
Probe_Data::m_Time
int m_Time
Definition: PopulationManager.h:424
WARN_FILE
Definition: MapErrorMsg.h:37
Probe_Data::m_TargetTypes
bool m_TargetTypes[16]
Definition: PopulationManager.h:441
Probe_Data::m_FullLandscapeProbe
bool m_FullLandscapeProbe
Definition: PopulationManager.h:429
Probe_Data::m_RefVeg
TTypesOfVegetation m_RefVeg[25]
Definition: PopulationManager.h:437
Probe_Data::m_NoEleTypes
unsigned m_NoEleTypes
Definition: PopulationManager.h:434
Probe_Data::m_MyFileName
char m_MyFileName[255]
Definition: PopulationManager.h:425
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
Probe_Data::m_Rect
rectangle m_Rect[16]
Definition: PopulationManager.h:433
Probe_Data::m_ReportInterval
unsigned m_ReportInterval
Definition: PopulationManager.h:431
Probe_Data::m_NoVegTypes
unsigned m_NoVegTypes
Definition: PopulationManager.h:435
Probe_Data::m_NoAreas
unsigned m_NoAreas
Definition: PopulationManager.h:432
Probe_Data::m_FileRecord
bool m_FileRecord
Definition: PopulationManager.h:428
Probe_Data::m_RefFarms
unsigned m_RefFarms[25]
Definition: PopulationManager.h:439
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
Probe_Data::m_NoFarms
unsigned m_NoFarms
Definition: PopulationManager.h:436
Probe_Data::m_RefEle
TTypesOfLandscapeElement m_RefEle[25]
Definition: PopulationManager.h:438
Probe_Data::m_MyFile
ofstream * m_MyFile
Definition: PopulationManager.h:423