NGen
Loading...
Searching...
No Matches
time.hpp
1#ifndef NGEN_REALIZATION_CONFIG_TIME_H
2#define NGEN_REALIZATION_CONFIG_TIME_H
3
4#include <boost/property_tree/ptree.hpp>
5#include <string>
6
7#include "Simulation_Time.hpp"
8
9namespace realization{
10 namespace config{
14 struct Time{
15 std::string start_time;
16 std::string end_time;
17 unsigned int output_interval;
18
30 Time(const boost::property_tree::ptree& tree){
31 start_time = tree.get("start_time", std::string());
32 end_time = tree.get("end_time", std::string());
33 output_interval = tree.get("output_interval", 0);
34 }
35
43 std::vector<std::string> missing_simulation_time_parameters;
44
45 if (start_time.empty()){
46 missing_simulation_time_parameters.push_back("start_time");
47 }
48
49 if (end_time.empty()) {
50 missing_simulation_time_parameters.push_back("end_time");
51 }
52
53 if (output_interval == 0) {
54 missing_simulation_time_parameters.push_back("output_interval");
55 }
56
57 if (missing_simulation_time_parameters.size() > 0) {
58 std::string message = "ERROR: A simulation time parameter cannot be created; the following parameters are missing or invalid: ";
59
60 for (int missing_parameter_index = 0; missing_parameter_index < missing_simulation_time_parameters.size(); missing_parameter_index++) {
61 message += missing_simulation_time_parameters[missing_parameter_index];
62
63 if (missing_parameter_index < missing_simulation_time_parameters.size() - 1) {
64 message += ", ";
65 }
66 }
67
68 throw std::runtime_error(message);
69 }
74 );
75 }
76 };
77 }//end namespace config
78}//end namespace realization
79#endif //NGEN_REALIZATION_CONFIG_TIME_H
Definition Bmi_C_Formulation.hpp:11
Simple structure for holding time bounds and output interval (seconds)
Definition time.hpp:14
std::string start_time
Definition time.hpp:15
simulation_time_params make_params()
Converts string based parameters start_time and end_time into time structs for use as simulation_time...
Definition time.hpp:42
Time(const boost::property_tree::ptree &tree)
Construct a new Time object from a boost property tree.
Definition time.hpp:30
unsigned int output_interval
Definition time.hpp:17
std::string end_time
Definition time.hpp:16
simulation_time_params providing configuration information for simulation time period.
Definition Simulation_Time.hpp:13