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

Abstract class of a homogenous spatial unit populated by herbivores. More...

#include <habitat.h>

Inheritance diagram for Fauna::Habitat:
Fauna::Demo::SimpleHabitat

Public Member Functions

virtual ~Habitat ()
 Virtual Destructor. More...
 
virtual const char * get_aggregation_unit () const =0
 A string identifier for the group of habitats whose output is aggregated. More...
 
virtual HabitatForage get_available_forage () const =0
 Get dry-matter biomass [kgDM/km²] that is available to herbivores to eat. More...
 
virtual HabitatEnvironment get_environment () const =0
 Get today’s abiotic environmental variables in the habitat. More...
 
virtual void init_day (const int today)
 Update at the start of the day. More...
 
bool is_dead () const
 Whether kill() has been called on this object. More...
 
void kill ()
 Mark the object as dead and to be deleted. More...
 
virtual void remove_eaten_forage (const ForageMass &eaten_forage)
 Remove forage eaten by herbivores. More...
 
int get_day () const
 The current day as set by init_day(). More...
 
const Output::HabitatDataget_todays_output () const
 The current output data (read-only). More...
 

Protected Member Functions

Output::HabitatDataget_todays_output ()
 Class-internal read/write access to current output data. More...
 

Private Attributes

Output::HabitatData current_output
 
int day_of_year
 
bool killed = false
 

Detailed Description

Abstract class of a homogenous spatial unit populated by herbivores.

Note
While this base class implements the basic output functions, any derived class is responsible to add its own output.

Constructor & Destructor Documentation

◆ ~Habitat()

virtual Fauna::Habitat::~Habitat ( )
inlinevirtual

Virtual Destructor.

Destructor must be virtual in an interface.

Member Function Documentation

◆ get_aggregation_unit()

virtual const char * Fauna::Habitat::get_aggregation_unit ( ) const
pure virtual

A string identifier for the group of habitats whose output is aggregated.

Suppose the vegetation model works in longitude/latitude grid cells and has three habitats in each grid cell. Output shall be aggregated per grid cell. Then all habitats in each set of three have the same (unique!) aggregation unit sting identifier. This could be for instance "10.0/54.0" for a grid cell at 10° E and 54° N. It’s completely up to the vegetation model to define a convention for the aggregation unit identifiers.

You should avoid leading or trailing whitespaces and take care that you don’t include a character that is used as a field separator in the output table. Also, the string should not be empty.

The output of this function should not change within the lifetime of one class instance: One Habitat object shall not change into another aggregation unit.

Implemented in Fauna::Demo::SimpleHabitat.

◆ get_available_forage()

virtual HabitatForage Fauna::Habitat::get_available_forage ( ) const
pure virtual

Get dry-matter biomass [kgDM/km²] that is available to herbivores to eat.

Exceptions
std::logic_errorIf this object is dead.

Implemented in Fauna::Demo::SimpleHabitat.

◆ get_day()

int Fauna::Habitat::get_day ( ) const
inline

The current day as set by init_day().

See also
Date::day

◆ get_environment()

virtual HabitatEnvironment Fauna::Habitat::get_environment ( ) const
pure virtual

Get today’s abiotic environmental variables in the habitat.

Exceptions
std::logic_errorIf this object is dead.

Implemented in Fauna::Demo::SimpleHabitat.

◆ get_todays_output() [1/2]

Output::HabitatData & Fauna::Habitat::get_todays_output ( )
inlineprotected

Class-internal read/write access to current output data.

◆ get_todays_output() [2/2]

const Output::HabitatData & Fauna::Habitat::get_todays_output ( ) const
inline

The current output data (read-only).

◆ init_day()

void Habitat::init_day ( const int  today)
virtual

Update at the start of the day.

Call this once every day from the framework. When overwriting this in derived classes, make sure to call this parent function first.

Parameters
todayDay of the year (0 ≙ Jan 1st).
Exceptions
std::invalid_argumentIf not 0<=today<=364.
std::logic_errorIf this object is dead.

Reimplemented in Fauna::Demo::SimpleHabitat.

◆ is_dead()

bool Fauna::Habitat::is_dead ( ) const
inline

Whether kill() has been called on this object.

◆ kill()

void Fauna::Habitat::kill ( )
inline

Mark the object as dead and to be deleted.

Call this when the corresponding vegetation unit is invalid.

◆ remove_eaten_forage()

virtual void Fauna::Habitat::remove_eaten_forage ( const ForageMass eaten_forage)
inlinevirtual

Remove forage eaten by herbivores.

The base class implements only adding the eaten forage to the output. Any derived class should call this (the parent‘s) function and do forage removal afterwards.

Note
It is the vegetation model’s responsibility to recycle nutrients (e.g. nitrogen). Even though the herbivore model counts the amount of ingested nitrogen, it does not close the nutrient cycle by returning nitrogen to the vegetation. The implementation of this function could directly put eaten nitrogen into the soil, thereby ignoring the (short) time herbivores retain nitrogen in their digestive tract and their body tissue.
Parameters
eaten_forageDry matter leaf forage [kgDM/km²], must not exceed available forage.
Exceptions
std::logic_errorIf eaten_forage exceeds available forage (to be implemented in derived classes).
std::logic_errorIf this object is dead.

Reimplemented in Fauna::Demo::SimpleHabitat.

Member Data Documentation

◆ current_output

Output::HabitatData Fauna::Habitat::current_output
private

◆ day_of_year

int Fauna::Habitat::day_of_year
private

◆ killed

bool Fauna::Habitat::killed = false
private

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