From 46dc2ca05a3994e2add0daeb522fa3c6d08abca0 Mon Sep 17 00:00:00 2001 From: dehnert Date: Mon, 22 Sep 2014 21:17:20 +0200 Subject: [PATCH] Further work on option system (we're getting there...). Former-commit-id: cae593d5a13dc85ca29a794dff3c4a69235a935f --- src/settings/SettingsManager.cpp | 22 ++- src/settings/SettingsManager.h | 7 +- .../CounterexampleGeneratorSettings.cpp | 36 +++- .../modules/CounterexampleGeneratorSettings.h | 8 +- src/settings/modules/CuddSettings.cpp | 56 +++++- src/settings/modules/DebugSettings.cpp | 22 ++- src/settings/modules/GeneralSettings.cpp | 178 ++++++++++++++++-- src/settings/modules/ModuleSettings.cpp | 12 ++ src/settings/modules/ModuleSettings.h | 8 + 9 files changed, 313 insertions(+), 36 deletions(-) diff --git a/src/settings/SettingsManager.cpp b/src/settings/SettingsManager.cpp index d8a5ab506..525cefc29 100644 --- a/src/settings/SettingsManager.cpp +++ b/src/settings/SettingsManager.cpp @@ -65,7 +65,7 @@ namespace storm { if (currentArgument.at(0) == '-') { // At this point we know that a new option is about to come. Hence, we need to assign the current // cache content to the option that was active until now. - this->setOptionsArguments(activeOptionName, activeOptionIsShortName ? this->longNameToOptions : this->shortNameToOptions, argumentCache); + setOptionsArguments(activeOptionName, activeOptionIsShortName ? this->longNameToOptions : this->shortNameToOptions, argumentCache); if (currentArgument.at(1) == '-') { // In this case, the argument has to be the long name of an option. Try to get all options that @@ -121,18 +121,36 @@ namespace storm { // not required for this option, we have to add both versions to our mappings, the prefixed one and the // non-prefixed one. if (!option->getRequiresModulePrefix()) { + bool isCompatible = this->isCompatible(option, option->getLongName(), this->longNameToOptions); + LOG_THROW(isCompatible, storm::exceptions::IllegalFunctionCallException, "Unable to add option '" << option->getLongName() << "', because an option with the same name is incompatible with it."); this->longNameToOptions.emplace(option->getLongName(), option); } + // For the prefixed name, we don't need a compatibility check, because a module is not allowed to register the same option twice. this->longNameToOptions.emplace(option->getModuleName() + ":" + option->getLongName(), option); if (option->getHasShortName()) { if (!option->getRequiresModulePrefix()) { - this->shortNameToOptions.emplace(option->getLongName(), option); + this->shortNameToOptions.emplace(option->getShortName(), option); + bool isCompatible = this->isCompatible(option, option->getShortName(), this->shortNameToOptions); + LOG_THROW(isCompatible, storm::exceptions::IllegalFunctionCallException, "Unable to add option '" << option->getLongName() << "', because an option with the same name is incompatible with it."); } this->shortNameToOptions.emplace(option->getModuleName() + ":" + option->getShortName(), option); } } + bool SettingsManager::isCompatible(std::shared_ptr