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
Osmia_Nest Class Reference

The Osmia nest is assumed to be a linear element with egg cells added one by one. More...

#include <Osmia.h>

Inheritance diagram for Osmia_Nest:
TAnimal TALMaSSObject

Public Member Functions

 Osmia_Nest (int a_x, int a_y, int a_polyref, Osmia_Nest_Manager *a_manager)
 
virtual ~Osmia_Nest ()
 
void SetCellLock (void)
 Set the cell lock. More...
 
void ReleaseCellLock (void)
 Release the cell lock. More...
 
void AddCocoon (TAnimal *a_cocoon)
 Adds a cocoon to the nest, this is only used to initialise the simulation. More...
 
void AddEgg (TAnimal *a_egg)
 Adds an egg to the nest. More...
 
void ReplaceNestPointer (TAnimal *a_oldpointer, TAnimal *a_newpointer)
 
void RemoveCell (TAnimal *a_oldpointer)
 
bool Find (TAnimal *a_osmia)
 Debug function - Is this osmia present? More...
 
void KillAllSubsequentCells (TAnimal *a_osmia)
 Removes all Osmia from the nest from a target to the end of the tube. More...
 
int GetPolyRef ()
 Get the polyref. More...
 
int GetNoNests ()
 For debug - get the number of nests currently for this polygon. More...
 
int GetNoCells ()
 Get the number of cells for this nest. More...
 
bool ZeroCells ()
 Debug - to check if any nests have zero cells. More...
 
int GetAspectDelay ()
 
bool GetIsOpen ()
 Tells us whether the nest is finished for additions = false or can be added too = true. More...
 
void CloseNest ()
 Signals that the nest is closed. More...
 
- Public Member Functions inherited from TAnimal
 TAnimal (int x, int y, Landscape *L)
 The TAnimal constructor saving the x,y, location and the landscape pointer. More...
 
 TAnimal (int x, int y)
 The TAnimal constructor saving the x,y used if landscape is already set. More...
 
void SetGuardMapIndex (int a_index_x, int a_index_y)
 Set the guard map index, this is used to avoid two animals operating in the same location when using multithread. More...
 
unsigned SupplyFarmOwnerRef () const
 Get the current location farm ref if any. More...
 
AnimalPosition SupplyPosition () const
 Returns the objects location and habitat type and veg type. More...
 
APoint SupplyPoint () const
 Returns the objects location in ALMaSS coordinates. More...
 
int SupplyPolygonRef () const
 Returns the polygon reference where the object is located. More...
 
TTypesOfLandscapeElement SupplyPolygonType () const
 Returns the polygon type where the object is located. More...
 
int Supply_m_Location_x () const
 Returns the ALMaSS x-coordinate. More...
 
int Supply_m_Location_y () const
 Returns the ALMaSS y-coordinate. More...
 
int SupplyGuardCellX () const
 Returns the x-index to the guard cell. More...
 
int SupplyGuardCellY () const
 Returns the y-index to the guard cell. More...
 
int SupplyAge () const
 Returns the animals age in days. More...
 
void SetAge (int a_age)
 Sets the animals age in days. More...
 
virtual void KillThis ()
 Sets all parameters ready for object destruction. More...
 
virtual void CopyMyself ()
 Used to copy the object details to another in descendent classes. More...
 
void SetX (const int a_x)
 Sets the x-coordinate. More...
 
void SetY (const int a_y)
 Sets the y-coordinate. More...
 
virtual void ReinitialiseObject (int a_x, int a_y, Landscape *a_l_ptr)
 
virtual void ReinitialiseObject (int a_x, int a_y)
 Used to re-use an object - must be implemented in descendent classes. More...
 
virtual int WhatState ()
 Returns the objects current state number. More...
 
virtual void Dying ()
 A wrapped for KillThis - ideally should not be used. More...
 
void CheckManagement ()
 Used to start a check for any management related effects at the objects current location. More...
 
void CheckManagementXY (int a_x, int a_y)
 Used to start a check for any management related effects at x,y. More...
 
virtual bool OnFarmEvent (FarmToDo)
 Must be reimplemented if used in descendent classes. Sets the action on a management event. More...
 
- Public Member Functions inherited from TALMaSSObject
int GetCurrentStateNo () const
 Returns the current state number. More...
 
void SetCurrentStateNo (int a_num)
 Sets the current state number. More...
 
bool GetStepDone () const
 Returns the step done indicator flag. More...
 
void SetStepDone (bool a_bool)
 Sets the step done indicator flag. More...
 
virtual void BeginStep ()
 BeingStep behaviour - must be implemented in descendent classes. More...
 
virtual void Step ()
 Step behaviour - must be implemented in descendent classes. More...
 
virtual void EndStep ()
 EndStep behaviour - must be implemented in descendent classes. More...
 
void ReinitialiseObjectBase ()
 Used to initialise an object. More...
 
 TALMaSSObject ()
 The constructor for TALMaSSObject. More...
 
virtual ~TALMaSSObject ()=default
 The destructor for TALMaSSObject. More...
 

Public Attributes

Osmia_Femalem_owner
 

Protected Attributes

int m_x
 x-location More...
 
int m_y
 y-location More...
 
int m_PolyRef
 polygon reference to where the nest is located More...
 
std::forward_list< TAnimal * > m_cells
 list of egg objects More...
 
omp_nest_lock_t * m_cell_lock
 The lock to for egg cells operation. More...
 
bool m_isOpen
 Signals that the nest is closed or open for adding new cells. More...
 
int m_aspectdelay
 Simulates the natural variation assumed per nest location based on aspect, exposure etc.. More...
 
- Protected Attributes inherited from TAnimal
int m_Location_x
 The objects ALMaSS x coordinate. More...
 
int m_Location_y
 The objects ALMaSS y coordinate. More...
 
int m_guard_cell_x
 The index x to the guard cell. More...
 
int m_guard_cell_y
 The index y to the guard cell. More...
 
int m_AgeDays {0}
 To hold the age in days. More...
 
PesticideToxicity m_my_pesticide
 
- Protected Attributes inherited from TALMaSSObject
int m_CurrentStateNo
 The basic state number for all objects - '-1' indicates death. More...
 
bool m_StepDone
 Indicates whether the iterative step code is done for this timestep. More...
 

Static Protected Attributes

static Osmia_Nest_Managerm_OurManager = NULL
 A pointer to the one and only nest population manager. More...
 
- Static Protected Attributes inherited from TAnimal
static Landscapem_OurLandscape = nullptr
 A pointer to the landscape object shared with all TAnimal objects. More...
 
static int m_SimulationWidth = 0
 A static member for the simulation width because it is often used by descendent classes. More...
 
static int m_SimulationHeight = 0
 A static member for the simulation height because it is often used by descendent classes. More...
 
static double m_TemperatureToday = 0.0
 A holder for the temperature today shared with all TAnimal objects. More...
 
static int m_DayInYear = 0
 A holder for the day in year shared with all TAnimal objects. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from TAnimal
static void SetSimulationWidth (int a_value)
 Sets the simulation width. More...
 
static void SetSimulationHeight (int a_value)
 Sets the simulation height. More...
 
static void SetDayInYear (int a_value)
 Sets the day in year attribute. More...
 
static void SetOurLandscape (Landscape *a_value)
 Sets the landscape pointer. More...
 
static void SetTempToday (double a_value)
 Sets the temperature today attribute. More...
 
- Static Public Member Functions inherited from TALMaSSObject
static void OnArrayBoundsError ()
 Used for debugging only, tests basic object properties. More...
 
- Protected Member Functions inherited from TAnimal
void CorrectWrapRound ()
 Corrects wrap around co-ordinate problems. More...
 

Detailed Description

The Osmia nest is assumed to be a linear element with egg cells added one by one.

Constructor & Destructor Documentation

◆ Osmia_Nest()

Osmia_Nest::Osmia_Nest ( int  a_x,
int  a_y,
int  a_polyref,
Osmia_Nest_Manager a_manager 
)
1636  :TAnimal(a_x, a_y)
1637 {
1638  m_x = a_x;
1639  m_y = a_y;
1640  m_PolyRef = a_polyref;
1641  m_cells.clear(); // Ensures there are no cells occupied before we start
1642  m_OurManager = a_manager;
1643  m_isOpen = true;
1644  m_owner = nullptr;
1646  m_cell_lock = new omp_nest_lock_t;
1647  omp_init_nest_lock(m_cell_lock);
1648 }

References g_generator, g_uni_0to15(), m_aspectdelay, m_cell_lock, m_cells, m_isOpen, m_OurManager, m_owner, m_PolyRef, m_x, and m_y.

◆ ~Osmia_Nest()

virtual Osmia_Nest::~Osmia_Nest ( )
inlinevirtual
155  {
156  omp_destroy_nest_lock(m_cell_lock);
157  delete m_cell_lock;
158  }

References m_cell_lock.

Member Function Documentation

◆ AddCocoon()

void Osmia_Nest::AddCocoon ( TAnimal a_cocoon)
inline

Adds a cocoon to the nest, this is only used to initialise the simulation.

164  {
165  m_cells.push_front(a_cocoon);
166  }

References m_cells.

Referenced by Osmia_Population_Manager::CreateObjects().

◆ AddEgg()

void Osmia_Nest::AddEgg ( TAnimal a_egg)
inline

Adds an egg to the nest.

168 { m_cells.push_front(a_egg); }

References m_cells.

Referenced by Osmia_Population_Manager::CreateObjects().

◆ CloseNest()

void Osmia_Nest::CloseNest ( )
inline

Signals that the nest is closed.

197 { m_isOpen = false; }

References m_isOpen.

Referenced by Osmia_Female::st_Dying(), and Osmia_Female::st_ReproductiveBehaviour().

◆ Find()

bool Osmia_Nest::Find ( TAnimal a_osmia)
inline

Debug function - Is this osmia present?

175  {
176  if (std::find(m_cells.begin(), m_cells.end(), a_osmia) != m_cells.end()) return true;
177  else {
178  return false;
179  }
180  }

References m_cells.

◆ GetAspectDelay()

int Osmia_Nest::GetAspectDelay ( )
inline
193 { return m_aspectdelay; }

References m_aspectdelay.

Referenced by Osmia_InCocoon::st_Develop().

◆ GetIsOpen()

bool Osmia_Nest::GetIsOpen ( )
inline

Tells us whether the nest is finished for additions = false or can be added too = true.

195 { return m_isOpen; }

References m_isOpen.

Referenced by Osmia_Egg::st_Develop(), and Osmia_Larva::st_Develop().

◆ GetNoCells()

int Osmia_Nest::GetNoCells ( )
inline

Get the number of cells for this nest.

188 { return std::distance(std::begin(m_cells), std::end(m_cells)); };

References m_cells.

Referenced by Osmia_Female::st_Dying(), and Osmia_Female::st_ReproductiveBehaviour().

◆ GetNoNests()

int Osmia_Nest::GetNoNests ( )

For debug - get the number of nests currently for this polygon.

1709 {
1711 }

References Osmia_Nest_Manager::GetNoNests(), m_OurManager, and m_PolyRef.

◆ GetPolyRef()

int Osmia_Nest::GetPolyRef ( )
inline

Get the polyref.

184 { return m_PolyRef; }

References m_PolyRef.

Referenced by Osmia_Female::st_Dying(), and Osmia_Female::st_ReproductiveBehaviour().

◆ KillAllSubsequentCells()

void Osmia_Nest::KillAllSubsequentCells ( TAnimal a_osmia)

Removes all Osmia from the nest from a target to the end of the tube.

Searches the nest until if finds a specific Osmia, once found it removes that Osmia and deletes all cells created higher up the tube.

1687 {
1691  auto prev_point = m_cells.before_begin();
1692  for (auto it = m_cells.begin(); it!=m_cells.end(); ++it)
1693  {
1694  if(*it == a_osmia)
1695  {
1696  m_cells.erase_after(prev_point, m_cells.end());
1697  if (std::distance(std::begin(m_cells), std::end(m_cells)) < 1)
1698  {
1699  // Need to remove the nest from the world
1701  }
1702  return;
1703  }
1704  prev_point=it;
1705  }
1706 }

References m_cells, m_OurManager, m_PolyRef, and Osmia_Nest_Manager::ReleaseOsmiaNest().

◆ ReleaseCellLock()

void Osmia_Nest::ReleaseCellLock ( void  )
inline

Release the cell lock.

162 { omp_unset_nest_lock(m_cell_lock); }

References m_cell_lock.

Referenced by Osmia_Population_Manager::CreateObjects(), RemoveCell(), Osmia_Female::st_Dying(), and Osmia_Female::st_ReproductiveBehaviour().

◆ RemoveCell()

void Osmia_Nest::RemoveCell ( TAnimal a_oldpointer)
1652 {
1653  SetCellLock();
1654 
1655  auto prev_point = m_cells.before_begin();
1656  for (auto it = m_cells.begin(); it!=m_cells.end(); ++it)
1657  {
1658  //cout<< a_oldpointer<<' '<<*it<<endl;
1659  //cout<<std::distance(std::begin(m_cells), std::end(m_cells))<<endl;
1660  if((*it) == a_oldpointer)
1661  {
1662  m_cells.erase_after(prev_point);
1663  //cout<<"cell removed "<<endl;
1664  if (std::distance(std::begin(m_cells), std::end(m_cells)) < 1)
1665  {
1666  // Need to remove the nest from the world
1667  //cout<<"nest needs removed "<<endl;
1668  //release the lock before we remove the nest
1669  ReleaseCellLock();
1671  }
1672  else
1673  {
1674  //cout<<"nest not removed "<<endl;
1675  ReleaseCellLock();
1676  }
1677  return;
1678  }
1679 
1680  prev_point=it;
1681  }
1682 
1683  ReleaseCellLock();
1684 }

References m_cells, m_OurManager, m_PolyRef, ReleaseCellLock(), Osmia_Nest_Manager::ReleaseOsmiaNest(), and SetCellLock().

Referenced by Osmia_Base::st_Dying(), and Osmia_InCocoon::st_Emerge().

◆ ReplaceNestPointer()

void Osmia_Nest::ReplaceNestPointer ( TAnimal a_oldpointer,
TAnimal a_newpointer 
)
inline
169  {
170  std::replace(m_cells.begin(), m_cells.end(), a_oldpointer, a_newpointer); // replaces the old life stage pointer with the new one in-place
171  }

References m_cells.

Referenced by Osmia_Population_Manager::CreateObjects().

◆ SetCellLock()

void Osmia_Nest::SetCellLock ( void  )
inline

◆ ZeroCells()

bool Osmia_Nest::ZeroCells ( )
inline

Debug - to check if any nests have zero cells.

190  {
191  if (std::distance(std::begin(m_cells), std::end(m_cells)) < 1) return false; else return true;
192  }

References m_cells.

Member Data Documentation

◆ m_aspectdelay

int Osmia_Nest::m_aspectdelay
protected

Simulates the natural variation assumed per nest location based on aspect, exposure etc..

Referenced by GetAspectDelay(), and Osmia_Nest().

◆ m_cell_lock

omp_nest_lock_t* Osmia_Nest::m_cell_lock
protected

The lock to for egg cells operation.

Referenced by Osmia_Nest(), ReleaseCellLock(), SetCellLock(), and ~Osmia_Nest().

◆ m_cells

std::forward_list<TAnimal*> Osmia_Nest::m_cells
protected

◆ m_isOpen

bool Osmia_Nest::m_isOpen
protected

Signals that the nest is closed or open for adding new cells.

Referenced by CloseNest(), GetIsOpen(), and Osmia_Nest().

◆ m_OurManager

Osmia_Nest_Manager * Osmia_Nest::m_OurManager = NULL
staticprotected

A pointer to the one and only nest population manager.

Referenced by GetNoNests(), KillAllSubsequentCells(), Osmia_Nest(), and RemoveCell().

◆ m_owner

Osmia_Female* Osmia_Nest::m_owner

◆ m_PolyRef

int Osmia_Nest::m_PolyRef
protected

polygon reference to where the nest is located

Referenced by GetNoNests(), GetPolyRef(), KillAllSubsequentCells(), Osmia_Nest(), and RemoveCell().

◆ m_x

int Osmia_Nest::m_x
protected

x-location

The Osmia_Nest class contains a list of Osmia_Egg pointers to objects it contains. It is descended from TAnimal which means it has a location and has access to the TALMaSSObject Step code if needed..however, right now this is not implemented in the population manager. All information about the egg state is held by the egg itself e.g. sex, parasitoids, so this is simply a list of eggs in order of them being added to the nest The nest can however supply the number of current eggs it holds

Referenced by Osmia_Nest().

◆ m_y

int Osmia_Nest::m_y
protected

y-location

Referenced by Osmia_Nest().


The documentation for this class was generated from the following files:
Osmia_Nest::SetCellLock
void SetCellLock(void)
Set the cell lock.
Definition: Osmia.h:160
Osmia_Nest::m_isOpen
bool m_isOpen
Signals that the nest is closed or open for adding new cells.
Definition: Osmia.h:150
g_generator
std::mt19937 g_generator
Osmia_Nest::m_x
int m_x
x-location
Definition: Osmia.h:138
TAnimal::TAnimal
TAnimal(int x, int y, Landscape *L)
The TAnimal constructor saving the x,y, location and the landscape pointer.
Definition: PopulationManager.cpp:1553
Osmia_Nest::m_OurManager
static Osmia_Nest_Manager * m_OurManager
A pointer to the one and only nest population manager.
Definition: Osmia.h:148
g_uni_0to15
static std::uniform_int_distribution< int > g_uni_0to15(0, 35)
Osmia_Nest::m_PolyRef
int m_PolyRef
polygon reference to where the nest is located
Definition: Osmia.h:142
Osmia_Nest::m_cells
std::forward_list< TAnimal * > m_cells
list of egg objects
Definition: Osmia.h:144
Osmia_Nest::m_owner
Osmia_Female * m_owner
Definition: Osmia.h:199
Osmia_Nest_Manager::GetNoNests
int GetNoNests(int a_polyindex)
Definition: Osmia_Population_Manager.h:351
Osmia_Nest_Manager::ReleaseOsmiaNest
void ReleaseOsmiaNest(int a_polyindex, Osmia_Nest *a_nest)
release nest here
Definition: Osmia_Population_Manager.h:342
Osmia_Nest::ReleaseCellLock
void ReleaseCellLock(void)
Release the cell lock.
Definition: Osmia.h:162
Osmia_Nest::m_y
int m_y
y-location
Definition: Osmia.h:140
Osmia_Nest::m_aspectdelay
int m_aspectdelay
Simulates the natural variation assumed per nest location based on aspect, exposure etc....
Definition: Osmia.h:152
Osmia_Nest::m_cell_lock
omp_nest_lock_t * m_cell_lock
The lock to for egg cells operation.
Definition: Osmia.h:146