From 0a0485c8f01ce56264f0a8a7acfed7f4b3c5319d Mon Sep 17 00:00:00 2001 From: dehnert Date: Wed, 1 Oct 2014 18:34:40 +0200 Subject: [PATCH] Added the functionality to specify and parse a configuration file to set command line options. Former-commit-id: 3488b527f7c7ee3c64e92efbbe7a4082f1ec3841 --- src/settings/SettingsManager.cpp | 148 +++++++++++++++++++++++++++---- src/settings/SettingsManager.h | 18 ++++ src/utility/cli.h | 3 +- 3 files changed, 150 insertions(+), 19 deletions(-) diff --git a/src/settings/SettingsManager.cpp b/src/settings/SettingsManager.cpp index 53d31f6f0..a9eac4a9a 100644 --- a/src/settings/SettingsManager.cpp +++ b/src/settings/SettingsManager.cpp @@ -110,9 +110,30 @@ namespace storm { if (optionActive) { setOptionsArguments(activeOptionName, activeOptionIsShortName ? this->shortNameToOptions : this->longNameToOptions, argumentCache); } - - // Finally check whether all modules are okay with the current settings. - this->checkAllModules(); + + if (storm::settings::generalSettings().isConfigSet()) { + std::map> configurationFileSettings = parseConfigFile(storm::settings::generalSettings().getConfigFilename()); + + for (auto const& optionArgumentsPair : configurationFileSettings) { + auto options = this->longNameToOptions.find(optionArgumentsPair.first); + + // We don't need to check whether this option exists or not, because this is already checked when + // parsing the configuration file. + + // Now go through all the matching options and set them according to the values. + for (auto option : options->second) { + if (option->getHasOptionBeenSet()) { + // If the option was already set from the command line, we issue a warning and ignore the + // settings from the configuration file. + STORM_LOG_WARN("The option '" << option->getLongName() << " of module '" << option->getModuleName() << "' has been set in the configuration file, but was overriden on the command line."); + } else { + // If, however, the option has not been set yet, we try to assign values ot its arguments + // based on the argument strings. + setOptionArguments(optionArgumentsPair.first, option, optionArgumentsPair.second); + } + } + } + } } void SettingsManager::setFromConfigurationFile(std::string const& configFilename) { @@ -293,6 +314,23 @@ namespace storm { return true; } + void SettingsManager::setOptionArguments(std::string const& optionName, std::shared_ptr