1#ifndef NGEN_REALIZATION_SERIALIZATION_HELPER_H
2#define NGEN_REALIZATION_SERIALIZATION_HELPER_H
4#include "JSONProperty.hpp"
5#include "global_config.hpp"
6#include "path_tokens.hpp"
8#include <boost/property_tree/ptree.hpp>
32 boost::property_tree::ptree& block)
34 for (
const auto* path_key : {
"path",
"save.path",
"restore.path"}) {
35 auto path_val = block.get_optional<std::string>(path_key);
67 const std::vector<std::string>& known_ids)
69 if (known_ids.empty())
return;
72 auto ser_it = global_configs.find(ser_key);
73 if (ser_it == global_configs.end())
return;
78 auto restore_it = ser_map.find(
"restore");
79 if (restore_it == ser_map.end())
return;
83 if (restore_map.count(
"id_subset") != 0)
return;
88 std::vector<geojson::JSONProperty> id_list;
89 id_list.reserve(known_ids.size());
90 for (
const auto&
id : known_ids) {
91 id_list.emplace_back(std::string(
""),
id);
103 ser_map.erase(
"restore");
104 ser_map.emplace(
"restore", std::move(restore_prop));
107 global_configs.erase(ser_key);
108 global_configs.emplace(ser_key, std::move(ser_prop));
@TODO: Convert JSONProperty into a variant of the supported types
Definition JSONProperty.hpp:161
std::map< std::string, JSONProperty > PropertyMap
Shorthand for a mapping between strings and properties.
Definition JSONProperty.hpp:21
@ SERIALIZATION
The serialization block consumed by the BMI serialization protocols (Ngen{Serialization,...
void apply_serialization_restore_subset_default(geojson::PropertyMap &global_configs, const std::vector< std::string > &known_ids)
Auto-populate serialization.restore.id_subset with the set of catchment identifiers that this realiza...
Definition serialization_helper.hpp:65
void apply_serialization_path_token_resolution(boost::property_tree::ptree &block)
Resolve {{rank}}/{{pid}}/{{host}}/{{date}} tokens in every path field the serialization block may car...
Definition serialization_helper.hpp:31
const char * to_key_string(GlobalConfigKey which)
Top-level JSON key string for a given GlobalConfigKey.
Definition global_config.hpp:33
Definition HY_Features.hpp:13
std::string resolve_path_tokens(const std::string &path)
Expand {{rank}}, {{pid}}, {{host}}, {{date}} tokens in path and return the resolved string.
Definition path_tokens.cpp:102