Health-GPS  1.2.2.0
Global Health Policy Simulation model (Health-GPS)
jsonparser.h
Go to the documentation of this file.
1 #pragma once
2 #include "options.h"
3 #include "riskmodel.h"
4 
5 #include <nlohmann/json.hpp>
6 #include <optional>
7 
8 namespace host::poco {
17 
18 //--------------------------------------------------------
19 // Full risk factor model POCO types mapping
20 //--------------------------------------------------------
21 
22 // Linear models
23 void to_json(json &j, const CoefficientInfo &p);
24 void from_json(const json &j, CoefficientInfo &p);
25 
26 void to_json(json &j, const LinearModelInfo &p);
27 void from_json(const json &j, LinearModelInfo &p);
28 
29 // Hierarchical levels
30 void to_json(json &j, const Array2Info &p);
31 void from_json(const json &j, Array2Info &p);
32 
33 void to_json(json &j, const HierarchicalLevelInfo &p);
34 void from_json(const json &j, HierarchicalLevelInfo &p);
35 
36 //--------------------------------------------------------
37 // Configuration sections POCO types mapping
38 //--------------------------------------------------------
39 
40 // Data file information
41 void to_json(json &j, const FileInfo &p);
42 void from_json(const json &j, FileInfo &p);
43 
44 // Settings Information
45 void to_json(json &j, const SettingsInfo &p);
46 void from_json(const json &j, SettingsInfo &p);
47 
48 // SES Model Information
49 void to_json(json &j, const SESInfo &p);
50 void from_json(const json &j, SESInfo &p);
51 
52 // Baseline scenario adjustments
53 void to_json(json &j, const BaselineInfo &p);
54 void from_json(const json &j, BaselineInfo &p);
55 
56 // Lite risk factors models (Energy Balance Model)
57 void to_json(json &j, const RiskFactorInfo &p);
58 void from_json(const json &j, RiskFactorInfo &p);
59 
60 void to_json(json &j, const VariableInfo &p);
61 void from_json(const json &j, VariableInfo &p);
62 
63 void to_json(json &j, const ModellingInfo &p);
64 void from_json(const json &j, ModellingInfo &p);
65 
66 void to_json(json &j, const FactorDynamicEquationInfo &p);
67 void from_json(const json &j, FactorDynamicEquationInfo &p);
68 
69 // Policy Scenario
70 void to_json(json &j, const PolicyPeriodInfo &p);
71 void from_json(const json &j, PolicyPeriodInfo &p);
72 
73 void to_json(json &j, const PolicyImpactInfo &p);
74 void from_json(const json &j, PolicyImpactInfo &p);
75 
76 void to_json(json &j, const PolicyAdjustmentInfo &p);
77 void from_json(const json &j, PolicyAdjustmentInfo &p);
78 
79 void to_json(json &j, const PolicyScenarioInfo &p);
80 void from_json(const json &j, PolicyScenarioInfo &p);
81 
82 // Output information
83 void to_json(json &j, const OutputInfo &p);
84 void from_json(const json &j, OutputInfo &p);
85 
86 } // namespace host::poco
87 
88 namespace std {
89 
90 // Optional parameters
91 template <typename T> void to_json(nlohmann::json &j, const std::optional<T> &p) {
92  if (p) {
93  j = *p;
94  } else {
95  j = nullptr;
96  }
97 }
98 template <typename T> void from_json(const nlohmann::json &j, std::optional<T> &p) {
99  if (j.is_null()) {
100  p = std::nullopt;
101  } else {
102  p = j.get<T>();
103  }
104 }
105 
106 } // namespace std
Plain old class object (POCO) types for loading configuration file.
Definition: jsonparser.cpp:3
void from_json(const json &j, CoefficientInfo &p)
Definition: jsonparser.cpp:14
void to_json(json &j, const CoefficientInfo &p)
Definition: jsonparser.cpp:9
nlohmann::json json
JSON parser namespace alias.
Definition: jsonparser.h:16
Global namespace.
Definition: jsonparser.h:88
void to_json(nlohmann::json &j, const std::optional< T > &p)
Definition: jsonparser.h:91
void from_json(const nlohmann::json &j, std::optional< T > &p)
Definition: jsonparser.h:98
Definition: riskmodel.h:28
Definition: poco.h:28
Definition: riskmodel.h:14
Definition: riskmodel.h:58
Definition: poco.h:9
Definition: riskmodel.h:34
Definition: riskmodel.h:21
Definition: poco.h:42
Definition: poco.h:49
Definition: poco.h:68
Definition: poco.h:55
Definition: poco.h:87
Definition: poco.h:35
Definition: poco.h:23
Definition: poco.h:17
Definition: riskmodel.h:52