Modular Megafauna Model 1.1.5
A physiological, dynamic herbivore simulator in C++.
Loading...
Searching...
No Matches
Fauna::CohortPopulation Class Reference

A population of HerbivoreCohort objects. More...

#include <cohort_population.h>

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

Public Member Functions

virtual void create_offspring (const double ind_per_km2)
 Give birth to new herbivores. More...
 
virtual void establish ()
 Create a set of new herbivores to establish a population. More...
 
virtual const Hftget_hft () const
 
virtual ConstHerbivoreVector get_list () const
 Get pointers to the herbivores (including dead ones). More...
 
virtual HerbivoreVector get_list ()
 Get pointers to the herbivores (including dead ones). More...
 
virtual void kill_nonviable ()
 Mark those herbivores as dead that are not viable. More...
 
virtual void purge_of_dead ()
 Delete all dead herbivores. More...
 
 CohortPopulation (const CreateHerbivoreCohort create_cohort)
 Constructor. More...
 
- Public Member Functions inherited from Fauna::PopulationInterface
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...
 

Private Types

typedef std::list< HerbivoreCohortList
 

Private Member Functions

void create_offspring_by_sex (const Sex sex, double ind_per_km2)
 Add newborn animals to the population either males or females. More...
 
List::iterator find_cohort (const int age_years, const Sex sex)
 Find a cohort in the list. More...
 

Private Attributes

const CreateHerbivoreCohort create_cohort
 
List list
 Offspring accumulated until above minimum threshold [ind/km²]. More...
 

Detailed Description

A population of HerbivoreCohort objects.

Member Typedef Documentation

◆ List

typedef std::list<HerbivoreCohort> Fauna::CohortPopulation::List
private

Constructor & Destructor Documentation

◆ CohortPopulation()

CohortPopulation::CohortPopulation ( const CreateHerbivoreCohort  create_cohort)

Constructor.

Parameters
create_cohortFunctor for creating new HerbivoreCohort instances.
Exceptions
std::invalid_argumentif any parameter is wrong.

Member Function Documentation

◆ create_offspring()

void CohortPopulation::create_offspring ( const double  ind_per_km2)
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.

Implements Fauna::PopulationInterface.

◆ create_offspring_by_sex()

void CohortPopulation::create_offspring_by_sex ( const Sex  sex,
double  ind_per_km2 
)
private

Add newborn animals to the population either males or females.

If no newborn cohort (age in years = zero) exists yet, it will be created. Otherwise, the additional newborns will be merged into the existing newborn cohort. The age in days of the existing cohort will not be changed.

See also
HerbivoreCohort::merge()
create_offspring()

◆ establish()

void CohortPopulation::establish ( )
virtual

Create a set of new herbivores to establish a population.

Exceptions
std::logic_errorIf this population is not empty.

Implements Fauna::PopulationInterface.

◆ find_cohort()

CohortPopulation::List::iterator CohortPopulation::find_cohort ( const int  age_years,
const Sex  sex 
)
private

Find a cohort in the list.

Parameters
age_yearsAge-class number (0=first year of life).
sexMale or female cohort?
Returns
If found: iterator pointing to the HerbivoreCohort object. If not found: end() iterator of the cohort list.

◆ get_hft()

virtual const Hft & Fauna::CohortPopulation::get_hft ( ) const
inlinevirtual

◆ get_list() [1/2]

HerbivoreVector CohortPopulation::get_list ( )
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.

Implements Fauna::PopulationInterface.

◆ get_list() [2/2]

ConstHerbivoreVector CohortPopulation::get_list ( ) const
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.

Implements Fauna::PopulationInterface.

◆ kill_nonviable()

void CohortPopulation::kill_nonviable ( )
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.

Implements Fauna::PopulationInterface.

◆ purge_of_dead()

void CohortPopulation::purge_of_dead ( )
virtual

Delete all dead herbivores.

See also
HerbivoreInterface::is_dead()

Implements Fauna::PopulationInterface.

Member Data Documentation

◆ create_cohort

const CreateHerbivoreCohort Fauna::CohortPopulation::create_cohort
private

◆ list

List Fauna::CohortPopulation::list
private

Offspring accumulated until above minimum threshold [ind/km²].


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