27 namespace po = boost::program_options;
30 namespace Configuration {
36 auto& manager_ptr = manager_map[id];
37 if (manager_ptr ==
nullptr) {
48 if (config_pair.second.find(root) != config_pair.second.end()) {
51 for (
auto& config : config_pair.second) {
55 for (
auto& type : found) {
66 logger.
debug() <<
"Cleaning dependencies of unregistered configurations...";
68 for (
auto& pair : dep_map) {
69 if (dict.find(pair.first) == dict.end()) {
74 for (
auto& value : pair.second) {
75 if (dict.find(value) == dict.end()) {
79 for (
auto& to_remove : unregistered_values) {
80 logger.
info() <<
"Removing configuration dependency " << pair.first.name()
81 <<
" -> " << to_remove.name();
82 pair.second.erase(to_remove);
85 for (
auto& to_remove : unregistered_keys) {
86 for (
auto& value : dep_map.at(to_remove)) {
87 logger.
info() <<
"Removing configuration dependency " << to_remove.name()
88 <<
" -> " << value.name();
90 dep_map.erase(to_remove);
100 pair.second->getDependencies().end());
109 if (!found.empty()) {
110 logger.
error() <<
"Found circular dependency between configurations:";
112 logger.
error() <<
" " << ++count <<
" : " << pair.first.name();
113 for (
auto& type : found) {
114 logger.
error() <<
" " << ++count <<
" : " << type.name();
122 for (
auto& pair : config.second->getProgramOptions()) {
123 if (all_options.find(pair.first) == all_options.end()) {
124 all_options.
emplace(pair.first, po::options_description{pair.first});
126 auto& group = all_options.at(pair.first);
127 for (
auto& option : pair.second) {
128 group.add(boost::shared_ptr<po::option_description>{
new po::option_description{option}});
133 po::options_description result {};
134 for (
auto& pair : all_options) {
135 result.add(pair.second);
145 if (dictionary.at(config)->getCurrentState() >= Configuration::State::INITIALIZED) {
149 for (
auto& dependency : dependency_map.at(config)) {
153 dictionary.at(config)->initialize(user_values);
154 dictionary.at(config)->getCurrentState() = Configuration::State::INITIALIZED;
160 logger.
debug() <<
"Pre-Initializing configuration :" << pair.first.name();
161 pair.second->preInitialize(user_values);
165 logger.
debug() <<
"Initializing configuration :" << pair.first.name();
169 logger.
debug() <<
"Post-Initializing configuration :" << pair.first.name();
170 pair.second->postInitialize(user_values);