Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ModuleSettings.cpp
Go to the documentation of this file.
2
8
9namespace storm {
10namespace settings {
11namespace modules {
12
13ModuleSettings::ModuleSettings(std::string const& moduleName) : moduleName(moduleName) {
14 // Intentionally left empty.
15}
16
18 return true;
19}
20
22
23void ModuleSettings::set(std::string const& name) {
24 return this->getOption(name).setHasOptionBeenSet();
25}
26
27void ModuleSettings::unset(std::string const& name) {
28 return this->getOption(name).setHasOptionBeenSet(false);
29 return this->getOption(name).setHasOptionBeenSetWithModulePrefix(false);
30}
31
32std::vector<std::shared_ptr<Option>> const& ModuleSettings::getOptions() const {
33 return this->options;
34}
35
36Option const& ModuleSettings::getOption(std::string const& longName) const {
37 auto optionIterator = this->optionMap.find(longName);
38 STORM_LOG_THROW(optionIterator != this->optionMap.end(), storm::exceptions::IllegalFunctionCallException,
39 "Cannot retrieve unknown option '" << longName << "'.");
40 return *optionIterator->second;
41}
42
43Option& ModuleSettings::getOption(std::string const& longName) {
44 auto optionIterator = this->optionMap.find(longName);
45 STORM_LOG_THROW(optionIterator != this->optionMap.end(), storm::exceptions::IllegalFunctionCallException,
46 "Cannot retrieve unknown option '" << longName << "'.");
47 return *optionIterator->second;
48}
49
50std::string const& ModuleSettings::getModuleName() const {
51 return this->moduleName;
52}
53
54std::unique_ptr<storm::settings::SettingMemento> ModuleSettings::overrideOption(std::string const& name, bool requiredStatus) {
55 bool currentStatus = this->isSet(name);
56 if (requiredStatus) {
57 this->set(name);
58 } else {
59 this->unset(name);
60 }
61 return std::unique_ptr<storm::settings::SettingMemento>(new storm::settings::SettingMemento(*this, name, currentStatus));
62}
63
64bool ModuleSettings::isSet(std::string const& optionName) const {
65 return this->getOption(optionName).getHasOptionBeenSet();
66}
67
68void ModuleSettings::addOption(std::shared_ptr<Option> const& option) {
69 auto optionIterator = this->optionMap.find(option->getLongName());
70 STORM_LOG_THROW(optionIterator == this->optionMap.end(), storm::exceptions::IllegalFunctionCallException,
71 "Unable to register the option '" << option->getLongName() << "' in module '" << this->getModuleName()
72 << "', because an option with this name already exists.");
73 this->optionMap.emplace(option->getLongName(), option);
74 this->options.push_back(option);
75}
76
79 for (auto const& option : this->options) {
80 if (includeAdvanced || !option->getIsAdvanced()) {
81 length = std::max(length, option->getPrintLength());
82 }
83 }
84 return length;
85}
86
88 for (auto& option : options) {
89 for (auto& argument : option->getArguments()) {
90 if (argument->getHasDefaultValue()) {
91 argument->setFromDefaultValue();
92 }
93 }
94 }
95}
96
97} // namespace modules
98} // namespace settings
99} // namespace storm
This class represents one command-line option.
Definition Option.h:27
bool getHasOptionBeenSet() const
Retrieves whether the option has been set.
Definition Option.cpp:125
This class is used to reset the state of an option that was temporarily set to a different status.
std::unique_ptr< storm::settings::SettingMemento > overrideOption(std::string const &name, bool requiredStatus)
Sets the option with the given name to the required status.
bool isSet(std::string const &optionName) const
Retrieves whether the option with the given name was set.
std::vector< std::shared_ptr< Option > > const & getOptions() const
Retrieves the options of this module.
ModuleSettings(std::string const &moduleName)
Constructs a new settings object.
void unset(std::string const &name)
Unsets the option with the specified name.
virtual bool check() const
Checks whether the settings are consistent.
void set(std::string const &name)
Sets the option with the specified name.
std::string const & getModuleName() const
Retrieves the name of the module to which these settings belong.
uint_fast64_t getPrintLengthOfLongestOption(bool includeAdvanced) const
Retrieves the (print) length of the longest option.
void addOption(std::shared_ptr< Option > const &option)
Adds and registers the given option.
virtual void finalize()
Prepares the modules for further usage, should be called at the end of the initialization,...
void restoreDefaults()
Restores the default values for all arguments of all options.
Option & getOption(std::string const &longName)
Retrieves the option with the given long name.
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
SettingsType const & getModule()
Get module.
LabParser.cpp.
Definition cli.cpp:18