Browse Source

settings: Detect whether an option was set with or without the module prefix.

tempestpy_adaptions
TimQu 6 years ago
parent
commit
208854bf02
  1. 10
      src/storm/settings/Option.cpp
  2. 17
      src/storm/settings/Option.h
  3. 3
      src/storm/settings/SettingsManager.cpp
  4. 1
      src/storm/settings/modules/ModuleSettings.cpp

10
src/storm/settings/Option.cpp

@ -117,8 +117,12 @@ namespace storm {
bool Option::getHasOptionBeenSet() const {
return this->hasBeenSet;
}
bool Option::getHasOptionBeenSetWithModulePrefix() const {
return this->hasBeenSetWithModulePrefix;
}
Option::Option(std::string const& moduleName, std::string const& longOptionName, std::string const& shortOptionName, bool hasShortOptionName, std::string const& optionDescription, bool isOptionRequired, bool requireModulePrefix, bool isAdvanced, std::vector<std::shared_ptr<ArgumentBase>> const& optionArguments) : longName(longOptionName), hasShortName(hasShortOptionName), shortName(shortOptionName), description(optionDescription), moduleName(moduleName), isRequired(isOptionRequired), requireModulePrefix(requireModulePrefix), isAdvanced(isAdvanced), hasBeenSet(false), arguments(optionArguments), argumentNameMap() {
Option::Option(std::string const& moduleName, std::string const& longOptionName, std::string const& shortOptionName, bool hasShortOptionName, std::string const& optionDescription, bool isOptionRequired, bool requireModulePrefix, bool isAdvanced, std::vector<std::shared_ptr<ArgumentBase>> const& optionArguments) : longName(longOptionName), hasShortName(hasShortOptionName), shortName(shortOptionName), description(optionDescription), moduleName(moduleName), isRequired(isOptionRequired), requireModulePrefix(requireModulePrefix), isAdvanced(isAdvanced), hasBeenSet(false), hasBeenSetWithModulePrefix(false), arguments(optionArguments), argumentNameMap() {
// First, do some sanity checks.
STORM_LOG_THROW(!longName.empty(), storm::exceptions::IllegalArgumentException, "Unable to construct option with empty name.");
STORM_LOG_THROW(!moduleName.empty(), storm::exceptions::IllegalArgumentException, "Unable to construct option with empty module name.");
@ -138,6 +142,10 @@ namespace storm {
void Option::setHasOptionBeenSet(bool newValue) {
this->hasBeenSet = newValue;
}
void Option::setHasOptionBeenSetWithModulePrefix(bool newValue) {
this->hasBeenSetWithModulePrefix = newValue;
}
uint_fast64_t Option::getPrintLength() const {
uint_fast64_t length = 2;

17
src/storm/settings/Option.h

@ -161,6 +161,13 @@ namespace storm {
* @return True iff the option has been set.
*/
bool getHasOptionBeenSet() const;
/*!
* Retrieves whether the option has been set by including the module prefix.
*
* @return True iff the option has been set by including the module prefix.
*/
bool getHasOptionBeenSetWithModulePrefix() const;
/*!
* Retrieves whether the option is only displayed in the advanced help.
@ -210,6 +217,9 @@ namespace storm {
// A flag that indicates whether this option has been set.
bool hasBeenSet;
// A flag that indicates whether this option has been set.
bool hasBeenSetWithModulePrefix;
// The arguments of this option (possibly empty).
std::vector<std::shared_ptr<ArgumentBase>> arguments;
@ -239,6 +249,13 @@ namespace storm {
* @param newValue The new status of the flag.
*/
void setHasOptionBeenSet(bool newValue = true);
/*!
* Sets the flag that marks the option as being (un)set by including the module prefix.
*
* @param newValue The new status of the flag.
*/
void setHasOptionBeenSetWithModulePrefix(bool newValue = true);
};
}
}

3
src/storm/settings/SettingsManager.cpp

@ -494,6 +494,9 @@ namespace storm {
}
option->setHasOptionBeenSet();
if (optionName != option->getLongName() && optionName != option->getShortName() && boost::starts_with(optionName, option->getModuleName())) {
option->setHasOptionBeenSetWithModulePrefix();
}
}
void SettingsManager::setOptionsArguments(std::string const& optionName, std::unordered_map<std::string, std::vector<std::shared_ptr<Option>>> const& optionMap, std::vector<std::string> const& argumentCache) {

1
src/storm/settings/modules/ModuleSettings.cpp

@ -26,6 +26,7 @@ namespace storm {
void ModuleSettings::unset(std::string const& name) {
return this->getOption(name).setHasOptionBeenSet(false);
return this->getOption(name).setHasOptionBeenSetWithModulePrefix(false);
}
std::vector<std::shared_ptr<Option>> const& ModuleSettings::getOptions() const {
Loading…
Cancel
Save