25 #include <boost/archive/binary_iarchive.hpp>
26 #include <boost/archive/text_iarchive.hpp>
27 #include <boost/property_tree/ptree_serialization.hpp>
43 boost::property_tree::ptree app_config;
44 boost::property_tree::ptree modules_config;
48 std::string module_name;
49 boost::property_tree::ptree tree;
52 std::tie(module_name, tree) = it;
53 modules_config.add_child(
"module",
load_config(module_name));
55 app_config.get_child(
"kernel").add_child(
"modules", modules_config);
61 boost::property_tree::ptree general_cfg;
63 for (
const std::string &cfg_name :
64 {
"remote",
"plugin_directories",
"log",
"network",
"autosave",
"sync_dest",
65 "no_import",
"instance_name"})
69 general_cfg.add_child(cfg_name, *child_opt);
80 std::vector<std::string> exportable_config;
81 boost::property_tree::ptree ret;
86 general_cfg.erase(
"no_import");
87 general_cfg.erase(
"instance_name");
91 for (
const auto &c : *child_opt)
93 ASSERT_LOG(c.first !=
"no_import" || c.first ==
"instance_name",
94 "Cannot export the " << c.first
96 " `sync_source` configuration tag.");
97 if (c.first ==
"no_import" || c.first ==
"instance_name")
99 WARN(
"You cannot export the " << c.first <<
" tag.");
102 if (c.second.get_value<
bool>())
103 exportable_config.push_back(c.first);
106 for (
const auto &child : general_cfg)
108 if (std::find(exportable_config.begin(), exportable_config.end(),
109 child.first) != exportable_config.end())
111 ret.add_child(child.first, child.second);
118 boost::property_tree::ptree
const &cfg)
132 const boost::property_tree::ptree &
139 throw std::runtime_error(
"");
146 std::is_same<std::underlying_type<Leosac::ConfigManager::ConfigFormat>::type,
148 "Bad underlying type for enum");
159 std::is_same<std::underlying_type<Leosac::ConfigManager::ConfigFormat>::type,
161 "Bad underlying type for enum");
162 msg << static_cast<uint8_t>(fmt);
188 INFO(
"Attempting to set kernel config. We need to somehow merge.");
189 auto kernel_cfg_file =
kernel_config_.get<std::string>(
"kernel-cfg");
192 std::vector<std::string> exportable_config;
193 boost::property_tree::ptree ret;
197 auto no_import_child =
kernel_config_.get_child_optional(
"no_import");
198 boost::property_tree::ptree cpy;
201 cpy = *no_import_child;
213 for (
const auto &c : *child_opt)
215 if (c.second.get_value<
bool>())
216 exportable_config.push_back(c.first);
219 for (
const auto &child : new_cfg)
221 if (std::find(exportable_config.begin(), exportable_config.end(),
222 child.first) != exportable_config.end())
232 std::list<std::string> ret;
233 const auto &no_import =
kernel_config_.get_child_optional(
"no_import");
237 for (
const auto &module : *no_import)
239 ret.push_back(module.first);
248 return std::find(lst.begin(), lst.end(), module_name) == lst.end();