Modular Megafauna Model 1.1.5
A physiological, dynamic herbivore simulator in C++.
Loading...
Searching...
No Matches
Fauna::PopulationInterface Struct Referenceabstract

A container of herbivore objects. More...

#include <population_interface.h>

Inheritance diagram for Fauna::PopulationInterface:
Fauna::CohortPopulation

Public Member Functions

virtual ~PopulationInterface ()
 Virtual destructor. More...
 
virtual void create_offspring (const double ind_per_km2)=0
 Give birth to new herbivores. More...
 
virtual void establish ()=0
 Create a set of new herbivores to establish a population. More...
 
virtual const double get_ind_per_km2 () const
 Get individual density of all herbivores together [ind/km²]. More...
 
virtual const double get_kg_per_km2 () const
 Get mass density of all herbivores together [kg/km²]. More...
 
virtual ConstHerbivoreVector get_list () const =0
 Get pointers to the herbivores (including dead ones). More...
 
virtual HerbivoreVector get_list ()=0
 Get pointers to the herbivores (including dead ones). More...
 
virtual void kill_all ()
 Mark all herbivores as dead (see HerbivoreInterface::kill()). More...
 
virtual void kill_nonviable ()=0
 Mark those herbivores as dead that are not viable. More...
 
virtual void purge_of_dead ()=0
 Delete all dead herbivores. More...
 

Detailed Description

A container of herbivore objects.

Manages a set of HerbivoreInterface instances. What makes a "population" may be defined by the derived class. For instance, herbivore cohorts have one population per HFT in each simulation unit.

A population also instantiates all new objects of herbivore classes (derived from HerbivoreInterface) in a simulation.

Note
This is strictly speaking no “interface” anymore since not all of its functions are pure abstract. It is just unnecessary effort to change the name.

Constructor & Destructor Documentation

◆ ~PopulationInterface()

virtual Fauna::PopulationInterface::~PopulationInterface ( )
inlinevirtual

Virtual destructor.

Destructor must be virtual in an interface.

Member Function Documentation

◆ create_offspring()

virtual void Fauna::PopulationInterface::create_offspring ( const double  ind_per_km2)
pure virtual

Give birth to new herbivores.

The new herbivores are owned by this population object.

Parameters
ind_per_km2Offspring amount [ind/km²].
Exceptions
std::invalid_argumentIf offspring<0.0.

Implemented in Fauna::CohortPopulation.

◆ establish()

virtual void Fauna::PopulationInterface::establish ( )
pure virtual

Create a set of new herbivores to establish a population.

Exceptions
std::logic_errorIf this population is not empty.

Implemented in Fauna::CohortPopulation.

◆ get_ind_per_km2()

const double PopulationInterface::get_ind_per_km2 ( ) const
virtual

Get individual density of all herbivores together [ind/km²].

◆ get_kg_per_km2()

const double PopulationInterface::get_kg_per_km2 ( ) const
virtual

Get mass density of all herbivores together [kg/km²].

◆ get_list() [1/2]

virtual ConstHerbivoreVector Fauna::PopulationInterface::get_list ( ) const
pure virtual

Get pointers to the herbivores (including dead ones).

Warning
The pointers are not guaranteed to stay valid on changing the population in create_offspring() or establish().
Returns
Pointers to all living herbivores in the population. Guaranteed no NULL pointers.

Implemented in Fauna::CohortPopulation.

◆ get_list() [2/2]

virtual HerbivoreVector Fauna::PopulationInterface::get_list ( )
pure virtual

Get pointers to the herbivores (including dead ones).

Warning
The pointers are not guaranteed to stay valid on changing the population in create_offspring() or establish().
Returns
Pointers to all living herbivores in the population. Guaranteed no NULL pointers.

Implemented in Fauna::CohortPopulation.

◆ kill_all()

void PopulationInterface::kill_all ( )
virtual

Mark all herbivores as dead (see HerbivoreInterface::kill()).

◆ kill_nonviable()

virtual void Fauna::PopulationInterface::kill_nonviable ( )
pure virtual

Mark those herbivores as dead that are not viable.

The first step is to mark non-viable herbivores as dead (see HerbivoreInterface::kill()). In the second step, dead herbivores are removed. It is necessary to split this up so that the simulation framework can do something with dead herbivores before they are deleted in purge_of_dead(). For example this may be returning nitrogen.

Implemented in Fauna::CohortPopulation.

◆ purge_of_dead()

virtual void Fauna::PopulationInterface::purge_of_dead ( )
pure virtual

Delete all dead herbivores.

See also
HerbivoreInterface::is_dead()

Implemented in Fauna::CohortPopulation.


The documentation for this struct was generated from the following files: