Modular Megafauna Model 1.1.5
A physiological, dynamic herbivore simulator in C++.
Loading...
Searching...
No Matches
habitat_forage.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2020 W. Traylor <wolfgang.traylor@senckenberg.de>
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
11#ifndef FAUNA_HABITAT_FORAGE_H
12#define FAUNA_HABITAT_FORAGE_H
13
14#include "Fauna/forage_types.h"
15#include "Fauna/forage_values.h"
16#include "Fauna/grass_forage.h"
17
18namespace Fauna {
19
22 public:
25
26 // TODO: Move this member variable to private and implement a getter.
29
30 // ADD NEW FORAGE TYPES (E.G. BROWSE) HERE.
31
33
38
40 ForageMass get_mass() const;
41
44
46
48 ForageBase get_total() const;
49
51 HabitatForage& merge(const HabitatForage& other, const double this_weight,
52 const double other_weight);
53
55
59 const ForageBase& operator[](const ForageType ft) const {
60 switch (ft) {
62 return grass;
63 // ADD NEW FORAGE TYPES HERE.
65 return inedible;
66 default:
67 throw std::logic_error((std::string)
68 "Fauna::HabitatForage::operator[]()const "
69 "Forage type \"" +
70 get_forage_type_name(ft) + "\" "
71 "is not implemented.");
72 }
73 }
74
77 switch (ft) {
79 return grass;
80 // ADD NEW FORAGE TYPES HERE.
82 return inedible;
83 default:
84 throw std::logic_error(
85 "Fauna::HabitatForage::operator[]() "
86 "Forage type \"" +
88 "\" "
89 "is not implemented.");
90 }
91 }
92
94
97 void set_nitrogen_content(const ForageFraction& nitrogen_content);
98
99 private:
101
104};
105} // namespace Fauna
106#endif // FAUNA_HABITAT_FORAGE_H
Base class for herbivore forage in a habitat.
Definition: forage_base.h:19
Grass forage in a habitat.
Definition: grass_forage.h:19
All values for large herbivore forage in a Habitat.
Definition: habitat_forage.h:21
HabitatForage()
Constructor with zero values.
Definition: habitat_forage.h:24
ForageFraction get_nitrogen_content()
Fraction of nitrogen in dry matter [kgN/kgDM].
Definition: habitat_forage.cpp:34
ForageBase get_total() const
Total forage in the habitat.
Definition: habitat_forage.cpp:45
HabitatForage & merge(const HabitatForage &other, const double this_weight, const double other_weight)
Merge this object with another one by building (weighted) means.
Definition: habitat_forage.cpp:68
ForageMass get_mass() const
Get dry matter mass [kgDM/km²] for all edible forage types.
Definition: habitat_forage.cpp:25
void set_nitrogen_content(const ForageFraction &nitrogen_content)
Set the nitrogen content [kgN/kgDM] for all forage types.
Definition: habitat_forage.cpp:78
Digestibility get_digestibility() const
Get digestibility [fractional] for all edible forage types.
Definition: habitat_forage.cpp:16
ForageBase & operator[](const ForageType ft)
Reference to forage object by forage type.
Definition: habitat_forage.h:76
ForageBase inedible
Inedible forage in the habitat.
Definition: habitat_forage.h:103
GrassForage grass
The grass forage in the habitat.
Definition: habitat_forage.h:28
const ForageBase & operator[](const ForageType ft) const
Reference to forage object by forage type.
Definition: habitat_forage.h:59
Definition of forage types (grass, browse, etc.)
Basic classes encapsulating forage amounts & fractions.
The forage class for grass.
Definition: average.h:16
const std::string & get_forage_type_name(const ForageType)
Get a short, lowercase string identifier for a forage type.
Definition: forage_types.cpp:30
ForageType
Different types of forage.
Definition: forage_types.h:21
@ Inedible
Plants that are not edible for herbivores.
@ Grass
Forage type grass.