Loading [MathJax]/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FarmerList Class Reference

A class to manage simple farmer list functionality. More...

#include <Farm.h>

Public Member Functions

 FarmerList ()
 FarmerList constructor. More...
 
void AddFarmer (Farmer *a_farmer)
 Adds a farmer to the end of the list. More...
 
Farmer * GetFarmer (int i)
 Gets a farmer point if an index is available. More...
 
void ReplaceFarmer (int i, Farmer *a_farmer)
 Replace a farmer. More...
 
int GetSize ()
 Gets the list length. More...
 
APoint GetLocation (int i)
 Gets location of a farmer in ALMaSS coordinates. More...
 
void UpdateSocialNetworks (bool a_geographic, bool a_associative, bool a_virtual)
 Forces update of one or more social networks for each farmer. More...
 
void ResetAllDone ()
 Sets all farmers AllDone to false ready for the next day. More...
 

Protected Attributes

vector< Farmer * > m_TheFarmers
 The list of farmers. More...
 

Detailed Description

A class to manage simple farmer list functionality.

Constructor & Destructor Documentation

◆ FarmerList()

FarmerList::FarmerList ( )
inline

FarmerList constructor.

Only resizes the list of farmers to zero length ready for input

467  {
471  m_TheFarmers.resize(0);
472  }

References m_TheFarmers.

Member Function Documentation

◆ AddFarmer()

void FarmerList::AddFarmer ( Farmer *  a_farmer)
inline

Adds a farmer to the end of the list.

474 { m_TheFarmers.push_back(a_farmer); }

References m_TheFarmers.

Referenced by FarmManager::CreateFarms().

◆ GetFarmer()

Farmer* FarmerList::GetFarmer ( int  i)
inline

Gets a farmer point if an index is available.

476 { return m_TheFarmers[i]; }

References m_TheFarmers.

Referenced by FarmManager::FarmManagement(), FarmManager::GetFarmer(), and FarmManager::PrintLocationAndArea().

◆ GetLocation()

APoint FarmerList::GetLocation ( int  i)

Gets location of a farmer in ALMaSS coordinates.

6089 {
6090  // Gets the x/y location as a point
6091  return m_TheFarmers[i]->SupplyPoint();
6092 }

References m_TheFarmers.

◆ GetSize()

int FarmerList::GetSize ( )
inline

Gets the list length.

480 { return int(m_TheFarmers.size()); }

References m_TheFarmers.

Referenced by FarmManager::FarmManagement(), and FarmManager::PrintLocationAndArea().

◆ ReplaceFarmer()

void FarmerList::ReplaceFarmer ( int  i,
Farmer *  a_farmer 
)
inline

Replace a farmer.

478 { m_TheFarmers[i] = a_farmer; }

References m_TheFarmers.

◆ ResetAllDone()

void FarmerList::ResetAllDone ( )

Sets all farmers AllDone to false ready for the next day.

Ensures that all farmers can start their activity the next day

6109 {
6111  for (auto it = m_TheFarmers.begin(); it != m_TheFarmers.end(); it++) (*it)->SetStepDone(false);
6112 }

References m_TheFarmers.

Referenced by FarmManager::FarmManagement().

◆ UpdateSocialNetworks()

void FarmerList::UpdateSocialNetworks ( bool  a_geographic,
bool  a_associative,
bool  a_virtual 
)

Forces update of one or more social networks for each farmer.

Simply loops through all the farmers and tells them to update their networks if the corresponding flag is set If social networks are disabled, then this is not called.

6095 {
6100  for (auto it = m_TheFarmers.begin(); it != m_TheFarmers.end(); it++)
6101  {
6102  if (a_spatial) (*it)->UpdateSpatialNetwork();
6103  if (a_associative) (*it)->UpdateAssociativeNetwork();
6104  if (a_virtual) (*it)->UpdateVirtualNetwork();
6105  }
6106 }

References m_TheFarmers.

Referenced by FarmManager::InitiateManagement().

Member Data Documentation

◆ m_TheFarmers

vector<Farmer*> FarmerList::m_TheFarmers
protected

The documentation for this class was generated from the following files:
FarmerList::m_TheFarmers
vector< Farmer * > m_TheFarmers
The list of farmers.
Definition: Farm.h:463