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

A habitat with the herbivores that live in it. More...

#include <simulation_unit.h>

Public Member Functions

 SimulationUnit (std::shared_ptr< Habitat > habitat, PopulationList *populations)
 Constructor. More...
 
 ~SimulationUnit ()
 Default Destructor. More...
 
Habitatget_habitat ()
 The habitat where the populations live. More...
 
const Habitatget_habitat () const
 Get a readonly reference to the habitat. More...
 
Output::CombinedData get_output () const
 Get combined output from habitat and herbivores together. More...
 
PopulationListget_populations ()
 The herbivores that live in the habitat. More...
 
const PopulationListget_populations () const
 The read-only handle to all herbivores that live in the habitat. More...
 
bool is_initial_establishment_done () const
 Whether the flag for initial establishment has been set. More...
 
void set_initial_establishment_done ()
 Set the flag that initial establishment has been performed. More...
 

Private Attributes

std::shared_ptr< Habitathabitat
 
bool initial_establishment_done
 
std::unique_ptr< PopulationListpopulations
 

Detailed Description

A habitat with the herbivores that live in it.

See also
Overview

Constructor & Destructor Documentation

◆ SimulationUnit()

SimulationUnit::SimulationUnit ( std::shared_ptr< Habitat habitat,
PopulationList populations 
)

Constructor.

Parameters
habitatA shared pointer to the habitat object. Since the object is created not by the megafauna library, but externally, it is implemented as a shared pointer. The Habitat resource will not be released from memory when the SimulationUnit object dies.
populationsPointer to the habitat object. SimulationUnit will take over exclusive ownership of the pointer.
Exceptions
std::invalid_argumentIf one of the parameters is NULL.

◆ ~SimulationUnit()

SimulationUnit::~SimulationUnit ( )
default

Default Destructor.

Member Function Documentation

◆ get_habitat() [1/2]

Habitat & SimulationUnit::get_habitat ( )

The habitat where the populations live.

Exceptions
std::logic_errorIf the private pointer is NULL.

◆ get_habitat() [2/2]

const Habitat & SimulationUnit::get_habitat ( ) const

Get a readonly reference to the habitat.

Exceptions
std::logic_errorIf the private pointer is NULL.

◆ get_output()

Output::CombinedData SimulationUnit::get_output ( ) const

Get combined output from habitat and herbivores together.

See also
HerbivoreInterface::get_todays_output()
Habitat::get_todays_output()

◆ get_populations() [1/2]

PopulationList & SimulationUnit::get_populations ( )

The herbivores that live in the habitat.

Exceptions
std::logic_errorIf the private pointer is NULL.

◆ get_populations() [2/2]

const PopulationList & SimulationUnit::get_populations ( ) const

The read-only handle to all herbivores that live in the habitat.

Exceptions
std::logic_errorIf the private pointer is NULL.

◆ is_initial_establishment_done()

bool Fauna::SimulationUnit::is_initial_establishment_done ( ) const
inline

Whether the flag for initial establishment has been set.

◆ set_initial_establishment_done()

void Fauna::SimulationUnit::set_initial_establishment_done ( )
inline

Set the flag that initial establishment has been performed.

Member Data Documentation

◆ habitat

std::shared_ptr<Habitat> Fauna::SimulationUnit::habitat
private

◆ initial_establishment_done

bool Fauna::SimulationUnit::initial_establishment_done
private

◆ populations

std::unique_ptr<PopulationList> Fauna::SimulationUnit::populations
private

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