Health-GPS  1.2.2.0
Global Health Policy Simulation model (Health-GPS)
modulefactory.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "interfaces.h"
4 #include "modelinput.h"
5 #include "repository.h"
6 #include <functional>
7 #include <unordered_map>
8 
9 namespace hgps {
10 
22  public:
24  using ModuleType = std::shared_ptr<SimulationModule>;
25 
28 
32  SimulationModuleFactory(Repository &data_repository);
33 
36  std::size_t size() const noexcept;
37 
41  bool contains(const SimulationModuleType type) const noexcept;
42 
46  void register_builder(const SimulationModuleType type, const ConcreteBuilder builder);
47 
52  ModuleType create(const SimulationModuleType type, const ModelInput &config);
53 
54  private:
55  std::reference_wrapper<Repository> repository_;
56  std::unordered_map<SimulationModuleType, ConcreteBuilder> builders_;
57 };
58 } // namespace hgps
Defines the Simulation model inputs data type.
Definition: modelinput.h:43
Define the data repository interface for input datasets and back-end storage.
Definition: repository.h:18
Defines the SimulationModule factory data type.
Definition: modulefactory.h:21
ModuleType create(const SimulationModuleType type, const ModelInput &config)
Create a polymorphic SimulationModule instance.
Definition: modulefactory.cpp:21
ModuleType(*)(Repository &, const ModelInput &) ConcreteBuilder
Concrete module builder function signature.
Definition: modulefactory.h:27
std::size_t size() const noexcept
Gets the number of registered module instance.
Definition: modulefactory.cpp:9
void register_builder(const SimulationModuleType type, const ConcreteBuilder builder)
Registers a simulation module type builder function.
Definition: modulefactory.cpp:15
bool contains(const SimulationModuleType type) const noexcept
Determine whether the factory contains an instance of a module type.
Definition: modulefactory.cpp:11
std::shared_ptr< SimulationModule > ModuleType
Base module type.
Definition: modulefactory.h:24
Top-level namespace for Health-GPS C++ API.
Definition: analysis_definition.h:8
SimulationModuleType
Health GPS simulation modules types enumeration.
Definition: interfaces.h:11
Global namespace.
Definition: jsonparser.h:88