Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
mapping.h
Go to the documentation of this file.
1#pragma once
4
5#include <stdexcept>
6#include <string>
7#include <unordered_map>
8#include <vector>
9
10namespace hgps {
11
14
16using OptionalInterval = std::optional<core::DoubleInterval>;
17
23 public:
24 MappingEntry() = delete;
25
30 MappingEntry(std::string name, int level, OptionalInterval range = {});
31
34 const std::string &name() const noexcept;
35
38 int level() const noexcept;
39
42 const core::Identifier &key() const noexcept;
43
46 const OptionalInterval &range() const noexcept;
47
51 double get_bounded_value(double value) const noexcept;
52
53 private:
54 std::string name_;
55 core::Identifier name_key_;
56 int level_{};
57 OptionalInterval range_;
58};
59
62 public:
64 using IteratorType = std::vector<MappingEntry>::iterator;
66 using ConstIteratorType = std::vector<MappingEntry>::const_iterator;
67
69
72 HierarchicalMapping(std::vector<MappingEntry> mapping);
73
76 const std::vector<MappingEntry> &entries() const noexcept;
77
80 std::size_t size() const noexcept;
81
84 int max_level() const noexcept;
85
90 MappingEntry at(const core::Identifier &key) const;
91
95 std::vector<MappingEntry> at_level(int level) const noexcept;
96
99 IteratorType begin() noexcept { return mapping_.begin(); }
100
103 IteratorType end() noexcept { return mapping_.end(); }
104
107 ConstIteratorType begin() const noexcept { return mapping_.cbegin(); }
108
111 ConstIteratorType end() const noexcept { return mapping_.cend(); }
112
115 ConstIteratorType cbegin() const noexcept { return mapping_.cbegin(); }
116
119 ConstIteratorType cend() const noexcept { return mapping_.cend(); }
120
121 private:
122 std::vector<MappingEntry> mapping_;
123};
124
125} // namespace hgps
Defines the hierarchical model mapping data type.
Definition mapping.h:61
IteratorType end() noexcept
Gets an iterator to the element following the last mapping.
Definition mapping.h:103
ConstIteratorType cend() const noexcept
Gets a read-only iterator to the element following the last mapping.
Definition mapping.h:119
std::vector< MappingEntry >::iterator IteratorType
Hierarchical mappings iterator.
Definition mapping.h:64
ConstIteratorType end() const noexcept
Gets a read-only iterator to the element following the last mapping.
Definition mapping.h:111
std::vector< MappingEntry >::const_iterator ConstIteratorType
read-only hierarchical mappings iterator
Definition mapping.h:66
IteratorType begin() noexcept
Gets an iterator to the beginning of the mappings.
Definition mapping.h:99
const std::vector< MappingEntry > & entries() const noexcept
Gets the collection of mapping entries.
Definition mapping.cpp:45
int max_level() const noexcept
Gets the maximum hierarchical level.
Definition mapping.cpp:49
std::size_t size() const noexcept
Gets the size of the mappings collection.
Definition mapping.cpp:47
ConstIteratorType cbegin() const noexcept
Gets an read-only iterator to the beginning of the mappings.
Definition mapping.h:115
ConstIteratorType begin() const noexcept
Gets an read-only iterator to the beginning of the mappings.
Definition mapping.h:107
std::vector< MappingEntry > at_level(int level) const noexcept
Gets the mapping entries at a given hierarchical level.
Definition mapping.cpp:68
MappingEntry at(const core::Identifier &key) const
Gets a mapping entry by identifier.
Definition mapping.cpp:57
Defines risk factor mapping entry data type.
Definition mapping.h:22
int level() const noexcept
Gets the factor hierarchical level.
Definition mapping.cpp:16
const core::Identifier & key() const noexcept
Gets the factor unique identification.
Definition mapping.cpp:18
double get_bounded_value(double value) const noexcept
Adjusts a value to the factor range, if provided.
Definition mapping.cpp:22
const OptionalInterval & range() const noexcept
Gets the factor allowed values range.
Definition mapping.cpp:20
const std::string & name() const noexcept
Gets the factor name.
Definition mapping.cpp:14
Top-level namespace for Health-GPS Console host application.
Definition command_options.cpp:8
std::optional< core::DoubleInterval > OptionalInterval
Optional Range of doubles data type.
Definition mapping.h:16
const core::Identifier InterceptKey
The constant in the regression model presentation identifier.
Definition mapping.h:13
Global namespace.
Definition column_iterator.h:123
Entity unique identifier data type.
Definition identifier.h:20