Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ModuleSettings.cpp
Go to the documentation of this file.
2
6
7namespace storm {
8namespace settings {
9namespace modules {
10
11ModuleSettings::ModuleSettings(std::string const& moduleName) : moduleName(moduleName) {
12 // Intentionally left empty.
13}
14
16 return true;
17}
18
20
21std::vector<std::shared_ptr<Option>> const& ModuleSettings::getOptions() const {
22 return this->options;
23}
24
25Option const& ModuleSettings::getOption(std::string const& longName) const {
26 auto optionIterator = this->optionMap.find(longName);
27 STORM_LOG_THROW(optionIterator != this->optionMap.end(), storm::exceptions::IllegalFunctionCallException,
28 "Cannot retrieve unknown option '" << longName << "'.");
29 return *optionIterator->second;
30}
31
32Option& ModuleSettings::getOption(std::string const& longName) {
33 auto optionIterator = this->optionMap.find(longName);
34 STORM_LOG_THROW(optionIterator != this->optionMap.end(), storm::exceptions::IllegalFunctionCallException,
35 "Cannot retrieve unknown option '" << longName << "'.");
36 return *optionIterator->second;
37}
38
39std::string const& ModuleSettings::getModuleName() const {
40 return this->moduleName;
41}
42
43bool ModuleSettings::isSet(std::string const& optionName) const {
44 return this->getOption(optionName).getHasOptionBeenSet();
45}
46
47void ModuleSettings::addOption(std::shared_ptr<Option> const& option) {
48 auto optionIterator = this->optionMap.find(option->getLongName());
49 STORM_LOG_THROW(optionIterator == this->optionMap.end(), storm::exceptions::IllegalFunctionCallException,
50 "Unable to register the option '" << option->getLongName() << "' in module '" << this->getModuleName()
51 << "', because an option with this name already exists.");
52 this->optionMap.emplace(option->getLongName(), option);
53 this->options.push_back(option);
54}
55
56uint_fast64_t ModuleSettings::getPrintLengthOfLongestOption(bool includeAdvanced) const {
57 uint_fast64_t length = 0;
58 for (auto const& option : this->options) {
59 if (includeAdvanced || !option->getIsAdvanced()) {
60 length = std::max(length, option->getPrintLength());
61 }
62 }
63 return length;
64}
65
67 for (auto& option : options) {
68 for (auto& argument : option->getArguments()) {
69 if (argument->getHasDefaultValue()) {
70 argument->setFromDefaultValue();
71 }
72 }
73 }
74}
75
76} // namespace modules
77} // namespace settings
78} // namespace storm
This class represents one command-line option.
Definition Option.h:26
bool getHasOptionBeenSet() const
Retrieves whether the option has been set.
Definition Option.cpp:125
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.
virtual bool check() const
Checks whether the settings are consistent.
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:28