Health-GPS  1.2.2.0
Global Health Policy Simulation model (Health-GPS)
runtime_context.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "event_aggregator.h"
4 #include "mapping.h"
5 #include "population.h"
6 #include "random_algorithm.h"
7 #include "runtime_metric.h"
9 
10 #include <functional>
11 #include <vector>
12 
13 namespace hgps {
14 
22  public:
23  RuntimeContext() = delete;
28 
31  int time_now() const noexcept;
32 
35  int start_time() const noexcept;
36 
39  unsigned int current_run() const noexcept;
40 
43  int sync_timeout_millis() const noexcept;
44 
47  Population &population() noexcept;
48 
51  RuntimeMetric &metrics() noexcept;
52 
55  Scenario &scenario() noexcept;
56 
59  Random &random() noexcept;
60 
63  const HierarchicalMapping &mapping() const noexcept;
64 
67  const std::vector<core::DiseaseInfo> &diseases() const noexcept;
68 
71  const core::IntegerInterval &age_range() const noexcept;
72 
75  const std::string identifier() const noexcept;
76 
79  void set_current_time(const int time_now) noexcept;
80 
83  void set_current_run(const unsigned int run_number) noexcept;
84 
88  void reset_population(const std::size_t initial_pop_size, const int model_start_time);
89 
92  void publish(std::unique_ptr<EventMessage> message) const noexcept;
93 
96  void publish_async(std::unique_ptr<EventMessage> message) const noexcept;
97 
98  private:
99  std::reference_wrapper<EventAggregator> event_bus_;
100  std::reference_wrapper<SimulationDefinition> definition_;
101  Population population_;
102  Random generator_;
103  RuntimeMetric metrics_{};
104  unsigned int current_run_{};
105  int model_start_time_{};
106  int time_now_{};
107 };
108 } // namespace hgps
Defines the event aggregator interface type.
Definition: event_aggregator.h:59
Defines the hierarchical model mapping data type.
Definition: mapping.h:128
Defines the virtual population data type.
Definition: population.h:14
General purpose Random number generator algorithms.
Definition: random_algorithm.h:8
Defines the Simulation runtime context data type.
Definition: runtime_context.h:21
RuntimeMetric & metrics() noexcept
Gets a reference to the runtime metrics container.
Definition: runtime_context.cpp:20
const core::IntegerInterval & age_range() const noexcept
Gets a read-only reference to the population age range constraints.
Definition: runtime_context.cpp:34
Scenario & scenario() noexcept
Gets a reference to the simulation experiment scenario.
Definition: runtime_context.cpp:22
unsigned int current_run() const noexcept
Gets the experiment current run number.
Definition: runtime_context.cpp:12
int sync_timeout_millis() const noexcept
Gets the data synchronisation timeout in milliseconds.
Definition: runtime_context.cpp:14
void set_current_time(const int time_now) noexcept
Sets the current simulation time value.
Definition: runtime_context.cpp:42
Population & population() noexcept
Gets a reference to the virtual population container.
Definition: runtime_context.cpp:18
Random & random() noexcept
Gets a reference to the engine random number generator.
Definition: runtime_context.cpp:24
const std::vector< core::DiseaseInfo > & diseases() const noexcept
Gets a read-only reference to the select diseases information.
Definition: runtime_context.cpp:30
void reset_population(const std::size_t initial_pop_size, const int model_start_time)
Resets the virtual population to an initial size, with only new individuals.
Definition: runtime_context.cpp:48
const std::string identifier() const noexcept
Gets the simulation identifier for outside world messages.
Definition: runtime_context.cpp:38
void publish_async(std::unique_ptr< EventMessage > message) const noexcept
Publishes a polymorphic new message to the outside world asynchronously.
Definition: runtime_context.cpp:58
int time_now() const noexcept
Gets the current simulation time.
Definition: runtime_context.cpp:8
const HierarchicalMapping & mapping() const noexcept
Gets a read-only reference to the hierarchical risk factors mapping.
Definition: runtime_context.cpp:26
void publish(std::unique_ptr< EventMessage > message) const noexcept
Publishes a polymorphic new message to the outside world synchronously.
Definition: runtime_context.cpp:54
void set_current_run(const unsigned int run_number) noexcept
Sets the current simulation run number.
Definition: runtime_context.cpp:44
int start_time() const noexcept
Gets the experiment start time.
Definition: runtime_context.cpp:10
Defines the Simulation run-time metrics container data type.
Definition: runtime_metric.h:12
Health-GPS simulation scenario interface.
Definition: scenario.h:30
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
Simulation event messages interface.
Definition: event_message.h:25
Simulation experiment definition data type.
Definition: simulation_definition.h:13