Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
pif_data.h
Go to the documentation of this file.
1#pragma once
2
5#include <string>
6#include <unordered_map>
7#include <vector>
8
9namespace hgps::input {
10
27
29class PIFTable {
30 public:
32 PIFTable() = default;
33
39 double get_pif_value(int age, core::Gender gender, int year_post_intervention) const;
40
43 void add_item(const PIFDataItem &item);
44
47 void build_hash_table();
48
51 bool has_data() const noexcept { return !data_.empty(); }
52
55 std::size_t size() const noexcept { return data_.size(); }
56
58 void clear() noexcept {
59 data_.clear();
60 direct_array_.clear();
61 }
62
63 private:
64 std::vector<PIFDataItem> data_;
65
66 // Direct array for TRUE O(1) access - no lookups!
67 std::vector<PIFDataItem> direct_array_;
68
69 int min_age_{0}, max_age_{0}, min_year_{0}, max_year_{0};
70 int age_range_{1}, year_range_{1};
71};
72
74class PIFData {
75 public:
77 PIFData() = default;
78
82 void add_scenario_data(const std::string &scenario, PIFTable &&table);
83
87 const PIFTable *get_scenario_data(const std::string &scenario) const;
88
91 bool has_data() const noexcept { return !scenario_data_.empty(); }
92
95 std::size_t scenario_count() const noexcept { return scenario_data_.size(); }
96
99 std::vector<std::string> get_scenario_names() const;
100
102 void clear() noexcept { scenario_data_.clear(); }
103
104 private:
105 std::unordered_map<std::string, PIFTable> scenario_data_;
106};
107
108} // namespace hgps::input
PIF data container for multiple scenarios.
Definition pif_data.h:74
PIFData()=default
Default constructor.
const PIFTable * get_scenario_data(const std::string &scenario) const
Get PIF table for specific scenario.
Definition pif_data.cpp:80
void clear() noexcept
Clear all data.
Definition pif_data.h:102
bool has_data() const noexcept
Check if PIF data is available for any scenario.
Definition pif_data.h:91
void add_scenario_data(const std::string &scenario, PIFTable &&table)
Add PIF table for a specific scenario.
Definition pif_data.cpp:76
std::vector< std::string > get_scenario_names() const
Get all available scenario names.
Definition pif_data.cpp:88
std::size_t scenario_count() const noexcept
Get the number of scenarios.
Definition pif_data.h:95
PIF data table for a specific disease-risk factor-scenario combination.
Definition pif_data.h:29
void clear() noexcept
Clear all data.
Definition pif_data.h:58
double get_pif_value(int age, core::Gender gender, int year_post_intervention) const
Get PIF value for specific age, gender, and time.
Definition pif_data.cpp:7
PIFTable()=default
Default constructor.
void add_item(const PIFDataItem &item)
Add PIF data item.
Definition pif_data.cpp:27
std::size_t size() const noexcept
Get the number of data items.
Definition pif_data.h:55
void build_hash_table()
Build hash table from vector data for direct access Call this after adding all items to optimize look...
Definition pif_data.cpp:29
bool has_data() const noexcept
Check if PIF data is available.
Definition pif_data.h:51
Gender
Enumerates gender types.
Definition forward_type.h:18
Data structures containing model parameters and configuration options.
Definition configuration.cpp:75
PIF data item for a specific age, gender, and time.
Definition pif_data.h:12
double pif_value
Definition pif_data.h:16
core::Gender gender
Definition pif_data.h:14
int age
Definition pif_data.h:13
PIFDataItem(int age, core::Gender gender, int year_post_intervention, double pif_value)
Constructor with parameters.
Definition pif_data.h:23
int year_post_intervention
Definition pif_data.h:15
PIFDataItem()
Default constructor.
Definition pif_data.h:19