1#ifndef NGEN_REALIZATION_CONFIG_FORMULATION_H
2#define NGEN_REALIZATION_CONFIG_FORMULATION_H
5#include <boost/property_tree/ptree.hpp>
8#include "JSONProperty.hpp"
48 type = tree.get<std::string>(
"name");
49 for (std::pair<std::string, boost::property_tree::ptree> setting : tree.get_child(
"params")) {
56 if(
type==
"bmi_multi"){
57 for(
auto& module : tree.get_child(
"params.modules")){
64 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
81 if(
type ==
"bmi_multi"){
82 std::vector<geojson::JSONProperty> tmp;
85 if(n.parameters.count(
"model_params")){
86 n.link_external(feature);
99 if(
parameters.count(
"model_params") < 1 )
return;
102 for (
decltype(
auto) param : attr) {
105 attr.emplace(param.first, param.second);
109 decltype(
auto) param_source = param.second.at(
"source");
110 decltype(
auto) param_source_name = param_source.as_string();
111 if (param_source_name !=
"hydrofabric") {
113 throw std::logic_error(
"ERROR: 'model_params' source `" + param_source_name +
"` not currently supported. Only `hydrofabric` is supported.");
119 decltype(
auto) param_name = param.second.has_key(
"from")
120 ? param.second.at(
"from").as_string()
123 if (feature->has_property(param_name)) {
124 auto catchment_attribute = feature->get_property(param_name);
128 switch (catchment_attribute.get_type()) {
133 std::cerr <<
"WARNING: property type " <<
static_cast<int>(catchment_attribute.get_type()) <<
" not allowed as model parameter. "
134 <<
"Must be one of: Natural (int), Real (double), Boolean, or String" <<
'\n';
@TODO: Convert JSONProperty into a variant of the supported types
Definition JSONProperty.hpp:165
static void print_property(const geojson::JSONProperty &p, int tab=0, bool newline=true)
Pretty print the property to standard out stream.
Definition JSONProperty.hpp:441
std::map< std::string, JSONProperty > PropertyMap
Shorthand for a mapping between strings and properties.
Definition JSONProperty.hpp:21
std::shared_ptr< FeatureBase > Feature
An easy name for a smart pointer for FeatureBase and its children.
Definition FeatureBase.hpp:34
Definition Bmi_C_Formulation.hpp:11