Health-GPS  1.2.2.0
Global Health Policy Simulation model (Health-GPS)
life_table.h
Go to the documentation of this file.
1 #pragma once
3 #include "gender_value.h"
4 
5 #include <map>
6 
7 namespace hgps {
8 
11 
13 struct Birth {
14 
18  Birth(float number_of_births, float birth_sex_ratio)
19  : number{number_of_births}, sex_ratio{birth_sex_ratio} {}
20 
22  float number{};
23 
25  float sex_ratio{};
26 };
27 
29 class LifeTable {
30  public:
31  LifeTable() = delete;
35  LifeTable(std::map<int, Birth> &&births, std::map<int, std::map<int, Mortality>> &&deaths);
36 
40  const Birth &get_births_at(int time_year) const;
41 
45  const std::map<int, Mortality> &get_mortalities_at(int time_year) const;
46 
50  double get_total_deaths_at(int time_year) const;
51 
55  bool contains_age(int age) const noexcept;
56 
60  bool contains_time(int time_year) const noexcept;
61 
64  const core::IntegerInterval &time_limits() const noexcept;
65 
68  const core::IntegerInterval &age_limits() const noexcept;
69 
72  bool empty() const noexcept;
73 
74  private:
75  std::map<int, Birth> birth_table_;
76  std::map<int, std::map<int, Mortality>> death_table_;
77 
78  // Data limits cache
79  core::IntegerInterval time_range_{};
80  core::IntegerInterval age_range_{};
81 };
82 } // namespace hgps
Defines the population life table data type.
Definition: life_table.h:29
const Birth & get_births_at(int time_year) const
Gets the Birth indicators at a given time.
Definition: life_table.cpp:33
const core::IntegerInterval & age_limits() const noexcept
Gets the LifeTable data age limits.
Definition: life_table.cpp:65
bool empty() const noexcept
Determine whether the LifeTable data is empty.
Definition: life_table.cpp:67
bool contains_age(int age) const noexcept
Determine whether the LifeTable data contains a given age.
Definition: life_table.cpp:55
bool contains_time(int time_year) const noexcept
Determine whether the LifeTable data contains a given time.
Definition: life_table.cpp:59
LifeTable()=delete
const core::IntegerInterval & time_limits() const noexcept
Gets the LifeTable data time limits.
Definition: life_table.cpp:63
const std::map< int, Mortality > & get_mortalities_at(int time_year) const
Gets the Mortality indicators at a given time.
Definition: life_table.cpp:37
double get_total_deaths_at(int time_year) const
Gets the total number of deaths at a given time.
Definition: life_table.cpp:41
Numeric interval representation data type.
Definition: interval.h:10
Interval< int > IntegerInterval
Interval representation integer data type.
Definition: interval.h:66
Top-level namespace for Health-GPS C++ API.
Definition: analysis_definition.h:8
Global namespace.
Definition: jsonparser.h:88
Define the birth data type.
Definition: life_table.h:13
float number
The total number of births.
Definition: life_table.h:22
float sex_ratio
Sex ratio at birth (males per 100 female births)
Definition: life_table.h:25
Birth(float number_of_births, float birth_sex_ratio)
Initialises a new instance of the Birth structure.
Definition: life_table.h:18
Defines a gender associated value data type.
Definition: gender_value.h:10