27 namespace po = boost::program_options;
30 namespace Configuration {
36 auto& manager_ptr = manager_map[id];
37 if (manager_ptr ==
nullptr) {
49 if (config_pair.second.find(root) != config_pair.second.end()) {
52 for (
auto& config : config_pair.second) {
56 for (
auto& type : found) {
67 logger.
debug() <<
"Cleaning dependencies of unregistered configurations...";
69 for (
auto& pair : dep_map) {
70 if (dict.find(pair.first) == dict.end()) {
75 for (
auto& value : pair.second) {
76 if (dict.find(value) == dict.end()) {
80 for (
auto& to_remove : unregistered_values) {
81 logger.
info() <<
"Removing configuration dependency " << pair.first.name() <<
" -> " << 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() <<
" -> " << value.name();
89 dep_map.erase(to_remove);
98 m_dependency_map[pair.first].
insert(pair.second->getDependencies().begin(), pair.second->getDependencies().end());
107 if (!found.empty()) {
108 logger.
error() <<
"Found circular dependency between configurations:";
110 logger.
error() <<
" " << ++count <<
" : " << pair.first.name();
111 for (
auto& type : found) {
112 logger.
error() <<
" " << ++count <<
" : " << type.name();
120 for (
auto& pair : config.second->getProgramOptions()) {
121 if (all_options.find(pair.first) == all_options.end()) {
122 all_options.
emplace(pair.first, po::options_description{pair.first});
124 auto& group = all_options.at(pair.first);
125 for (
auto& option : pair.second) {
126 group.add(boost::shared_ptr<po::option_description>{
new po::option_description{option}});
131 po::options_description result{};
132 for (
auto& pair : all_options) {
133 result.add(pair.second);
142 if (dictionary.at(config)->getCurrentState() >= Configuration::State::INITIALIZED) {
146 for (
auto& dependency : dependency_map.at(config)) {
150 dictionary.at(config)->initialize(user_values);
151 dictionary.at(config)->getCurrentState() = Configuration::State::INITIALIZED;
157 logger.
debug() <<
"Pre-Initializing configuration :" << pair.first.name();
158 pair.second->preInitialize(user_values);
162 logger.
debug() <<
"Initializing configuration :" << pair.first.name();
166 logger.
debug() <<
"Post-Initializing configuration :" << pair.first.name();
167 pair.second->postInitialize(user_values);