diff --git a/src/adapters/ExplicitModelAdapter.h b/src/adapters/ExplicitModelAdapter.h index 7befe5ee8..6fbb8cb00 100644 --- a/src/adapters/ExplicitModelAdapter.h +++ b/src/adapters/ExplicitModelAdapter.h @@ -312,7 +312,7 @@ namespace storm { } // Check that the resulting distribution is in fact a distribution. - LOG_THROW(std::abs(1 - probabilitySum) < storm::settings::SettingsManager::getInstance()->getOptionByLongName("precision").getArgument(0).getValueAsDouble(), storm::exceptions::WrongFormatException, "Probabilities do not sum to one for command '" << command << "'."); + LOG_THROW(std::abs(1 - probabilitySum) < storm::settings::generalSettings().getPrecision(), storm::exceptions::WrongFormatException, "Probabilities do not sum to one for command '" << command << "'."); } } @@ -418,7 +418,7 @@ namespace storm { } // Check that the resulting distribution is in fact a distribution. - if (std::abs(1 - probabilitySum) > storm::settings::SettingsManager::getInstance()->getOptionByLongName("precision").getArgument(0).getValueAsDouble()) { + if (std::abs(1 - probabilitySum) > storm::settings::generalSettings().getPrecision()) { LOG4CPLUS_ERROR(logger, "Sum of update probabilities do not some to one for some command."); throw storm::exceptions::WrongFormatException() << "Sum of update probabilities do not some to one for some command."; } @@ -502,7 +502,7 @@ namespace storm { // If the current state does not have a single choice, we equip it with a self-loop if that was // requested and issue an error otherwise. if (totalNumberOfChoices == 0) { - if (storm::settings::SettingsManager::getInstance()->isSet("fixDeadlocks")) { + if (storm::settings::generalSettings().isFixDeadlocksSet()) { // Insert empty choice labeling for added self-loop transitions. choiceLabels.push_back(boost::container::flat_set()); transitionMatrixBuilder.addNextValue(currentRow, currentState, storm::utility::constantOne()); diff --git a/src/counterexamples/MILPMinimalLabelSetGenerator.h b/src/counterexamples/MILPMinimalLabelSetGenerator.h index 5f999b06e..04face217 100644 --- a/src/counterexamples/MILPMinimalLabelSetGenerator.h +++ b/src/counterexamples/MILPMinimalLabelSetGenerator.h @@ -1025,7 +1025,7 @@ namespace storm { // Delegate the actual computation work to the function of equal name. auto startTime = std::chrono::high_resolution_clock::now(); - boost::container::flat_set usedLabelSet = getMinimalLabelSet(labeledMdp, phiStates, psiStates, bound, strictBound, true, storm::settings::SettingsManager::getInstance()->isSet("schedcuts")); + boost::container::flat_set usedLabelSet = getMinimalLabelSet(labeledMdp, phiStates, psiStates, bound, strictBound, true, storm::settings::counterexampleGeneratorSettings().useSchedulerCuts()); auto endTime = std::chrono::high_resolution_clock::now(); std::cout << std::endl << "Computed minimal label set of size " << usedLabelSet.size() << " in " << std::chrono::duration_cast(endTime - startTime).count() << "ms." << std::endl; diff --git a/src/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.h b/src/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.h index 345d9d721..b927b6203 100644 --- a/src/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.h +++ b/src/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.h @@ -235,7 +235,7 @@ namespace storm { // (1) Compute the accuracy we need to achieve the required error bound. ValueType maxExitRate = this->getModel().getMaximalExitRate(); - ValueType delta = (2 * storm::settings::SettingsManager::getInstance()->getOptionByLongName("digiprecision").getArgument(0).getValueAsDouble()) / (upperBound * maxExitRate * maxExitRate); + ValueType delta = (2 * storm::settings::generalSettings().getPrecision()) / (upperBound * maxExitRate * maxExitRate); // (2) Compute the number of steps we need to make for the interval. uint_fast64_t numberOfSteps = static_cast(std::ceil((upperBound - lowerBound) / delta)); diff --git a/src/modelchecker/prctl/CreatePrctlModelChecker.h b/src/modelchecker/prctl/CreatePrctlModelChecker.h index d07261ebc..f31fb246a 100644 --- a/src/modelchecker/prctl/CreatePrctlModelChecker.h +++ b/src/modelchecker/prctl/CreatePrctlModelChecker.h @@ -13,20 +13,8 @@ * @param dtmc A reference to the DTMC for which the model checker is to be created. * @return A pointer to the resulting model checker. */ -storm::modelchecker::prctl::AbstractModelChecker* createPrctlModelChecker(storm::models::Dtmc const & dtmc) { - // Create the appropriate model checker. - storm::settings::SettingsManager* s = storm::settings::SettingsManager::getInstance(); - std::string const& linsolver = s->getOptionByLongName("linsolver").getArgument(0).getValueAsString(); - if (linsolver == "gmm++") { - return new storm::modelchecker::prctl::SparseDtmcPrctlModelChecker(dtmc, new storm::solver::GmmxxLinearEquationSolver()); - } else if (linsolver == "native") { - return new storm::modelchecker::prctl::SparseDtmcPrctlModelChecker(dtmc, new storm::solver::NativeLinearEquationSolver()); - } - - // The control flow should never reach this point, as there is a default setting for matrixlib. - std::string message = "No matrix library suitable for DTMC model checking has been set."; - throw storm::exceptions::InvalidSettingsException() << message; - return nullptr; +storm::modelchecker::prctl::AbstractModelChecker* createPrctlModelChecker(storm::models::Dtmc const& dtmc) { + return new storm::modelchecker::prctl::SparseDtmcPrctlModelChecker(dtmc); } /*! diff --git a/src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h b/src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h index 40cec5558..a6fb9dd39 100644 --- a/src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h +++ b/src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h @@ -11,6 +11,7 @@ #include "src/modelchecker/prctl/AbstractModelChecker.h" #include "src/models/Dtmc.h" #include "src/solver/LinearEquationSolver.h" +#include "src/utility/solver.h" #include "src/utility/vector.h" #include "src/utility/graph.h" @@ -33,10 +34,14 @@ public: * * @param model The DTMC to be checked. */ - explicit SparseDtmcPrctlModelChecker(storm::models::Dtmc const& model, storm::solver::LinearEquationSolver* linearEquationSolver) : AbstractModelChecker(model), linearEquationSolver(linearEquationSolver) { + explicit SparseDtmcPrctlModelChecker(storm::models::Dtmc const& model, std::unique_ptr>&& linearEquationSolver) : AbstractModelChecker(model), linearEquationSolver(std::move(linearEquationSolver)) { // Intentionally left empty. } + explicit SparseDtmcPrctlModelChecker(storm::models::Dtmc const& model) : AbstractModelChecker(model), linearEquationSolver(storm::utility::solver::getLinearEquationSolver()) { + // Intentionally left empty. + } + /*! * Copy constructs a SparseDtmcPrctlModelChecker from the given model checker. In particular, this means that the newly * constructed model checker will have the model of the given model checker as its associated model. diff --git a/src/models/Ctmdp.h b/src/models/Ctmdp.h index c29c16b8c..103e3d264 100644 --- a/src/models/Ctmdp.h +++ b/src/models/Ctmdp.h @@ -126,9 +126,7 @@ private: * Checks probability matrix if all rows sum up to one. */ bool checkValidityOfProbabilityMatrix() { - // Get the settings object to customize linear solving. - storm::settings::SettingsManager* s = storm::settings::SettingsManager::getInstance(); - double precision = s->getOptionByLongName("precision").getArgument(0).getValueAsDouble(); + double precision = storm::settings::generalSettings().getPrecision(); for (uint_fast64_t row = 0; row < this->getTransitionMatrix().getRowCount(); row++) { T sum = this->getTransitionMatrix().getRowSum(row); if (sum == 0) continue; diff --git a/src/models/Dtmc.h b/src/models/Dtmc.h index ec625b6d8..0252b7533 100644 --- a/src/models/Dtmc.h +++ b/src/models/Dtmc.h @@ -297,9 +297,7 @@ private: * Checks probability matrix if all rows sum up to one. */ bool checkValidityOfProbabilityMatrix() { - // Get the settings object to customize linear solving. - storm::settings::SettingsManager* s = storm::settings::SettingsManager::getInstance(); - double precision = s->getOptionByLongName("precision").getArgument(0).getValueAsDouble(); + double precision = storm::settings::generalSettings().getPrecision(); if (this->getTransitionMatrix().getRowCount() != this->getTransitionMatrix().getColumnCount()) { // not square diff --git a/src/models/Mdp.h b/src/models/Mdp.h index b647f6813..53d7cc192 100644 --- a/src/models/Mdp.h +++ b/src/models/Mdp.h @@ -197,9 +197,7 @@ private: * Checks probability matrix if all rows sum up to one. */ bool checkValidityOfProbabilityMatrix() { - // Get the settings object to customize linear solving. - storm::settings::SettingsManager* s = storm::settings::SettingsManager::getInstance(); - double precision = s->getOptionByLongName("precision").getArgument(0).getValueAsDouble(); + double precision = storm::settings::generalSettings().getPrecision(); for (uint_fast64_t row = 0; row < this->getTransitionMatrix().getRowCount(); row++) { T sum = this->getTransitionMatrix().getRowSum(row); diff --git a/src/parser/DeterministicSparseTransitionParser.cpp b/src/parser/DeterministicSparseTransitionParser.cpp index 165f8d8f2..43c26f8fb 100644 --- a/src/parser/DeterministicSparseTransitionParser.cpp +++ b/src/parser/DeterministicSparseTransitionParser.cpp @@ -93,7 +93,7 @@ namespace storm { uint_fast64_t row, col, lastRow = 0; double val; - bool fixDeadlocks = storm::settings::SettingsManager::getInstance()->isSet("fixDeadlocks"); + bool fixDeadlocks = storm::settings::generalSettings().isFixDeadlocksSet(); bool hadDeadlocks = false; bool rowHadDiagonalEntry = false; diff --git a/src/parser/MarkovAutomatonSparseTransitionParser.cpp b/src/parser/MarkovAutomatonSparseTransitionParser.cpp index 7e235827c..e001d2b1d 100644 --- a/src/parser/MarkovAutomatonSparseTransitionParser.cpp +++ b/src/parser/MarkovAutomatonSparseTransitionParser.cpp @@ -15,7 +15,7 @@ namespace storm { MarkovAutomatonSparseTransitionParser::FirstPassResult MarkovAutomatonSparseTransitionParser::firstPass(char const* buf) { MarkovAutomatonSparseTransitionParser::FirstPassResult result; - bool fixDeadlocks = storm::settings::SettingsManager::getInstance()->isSet("fixDeadlocks"); + bool fixDeadlocks = storm::settings::generalSettings().isFixDeadlocksSet(); // Skip the format hint if it is there. buf = trimWhitespaces(buf); @@ -157,7 +157,7 @@ namespace storm { MarkovAutomatonSparseTransitionParser::Result MarkovAutomatonSparseTransitionParser::secondPass(char const* buf, FirstPassResult const& firstPassResult) { Result result(firstPassResult); - bool fixDeadlocks = storm::settings::SettingsManager::getInstance()->isSet("fixDeadlocks"); + bool fixDeadlocks = storm::settings::generalSettings().isFixDeadlocksSet(); // Skip the format hint if it is there. buf = trimWhitespaces(buf); diff --git a/src/parser/NondeterministicSparseTransitionParser.cpp b/src/parser/NondeterministicSparseTransitionParser.cpp index 01f3281cd..971f7cdfe 100644 --- a/src/parser/NondeterministicSparseTransitionParser.cpp +++ b/src/parser/NondeterministicSparseTransitionParser.cpp @@ -100,7 +100,7 @@ namespace storm { // Initialize variables for the parsing run. uint_fast64_t source = 0, target = 0, lastSource = 0, choice = 0, lastChoice = 0, curRow = 0; double val = 0.0; - bool fixDeadlocks = storm::settings::SettingsManager::getInstance()->isSet("fixDeadlocks"); + bool fixDeadlocks = storm::settings::generalSettings().isFixDeadlocksSet(); bool hadDeadlocks = false; // The first state already starts a new row group of the matrix. diff --git a/src/settings/Argument.cpp b/src/settings/Argument.cpp deleted file mode 100644 index 047dc13e9..000000000 --- a/src/settings/Argument.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "src/settings/Argument.h" - -namespace storm { - namespace settings { - const std::string Argument::trueString = "true"; - const std::string Argument::falseString = "false"; - } -} \ No newline at end of file diff --git a/src/settings/Argument.h b/src/settings/Argument.h index c756ff5d8..e93ce0c84 100644 --- a/src/settings/Argument.h +++ b/src/settings/Argument.h @@ -127,9 +127,9 @@ namespace storm { case ArgumentType::Boolean: { bool iValue = ArgumentTypeInferation::inferToBoolean(ArgumentType::Boolean, this->getArgumentValue()); if (iValue) { - return trueString; + return "true"; } else { - return falseString; + return "false"; } } default: return ArgumentBase::convertToString(this->argumentValue); @@ -190,10 +190,6 @@ namespace storm { // A flag indicating whether a default value has been provided. bool hasDefaultValue; - // Static constants for the string representations of true and false. - static const std::string trueString; - static const std::string falseString; - void setDefaultValue(T const& newDefault) { LOG_THROW(this->validate(newDefault), storm::exceptions::IllegalArgumentValueException, "The default value for the argument did not pass all validation functions."); this->defaultValue = newDefault; diff --git a/src/settings/Option.h b/src/settings/Option.h index 689c11191..0876b8741 100644 --- a/src/settings/Option.h +++ b/src/settings/Option.h @@ -21,16 +21,20 @@ namespace storm { namespace settings { - // Forward-declare settings manager class. + // Forward-declare settings manager and module settings classes. class SettingsManager; + namespace modules { + class ModuleSettings; + } /*! * This class represents one command-line option. */ class Option { public: - // Declare settings manager class as friend. + // Declare settings manager and module settings classes as friends. friend class SettingsManager; + friend class modules::ModuleSettings; /*! * Creates an option with the given parameters. diff --git a/src/settings/SettingMemento.cpp b/src/settings/SettingMemento.cpp index 5a1a55390..3f031b34a 100644 --- a/src/settings/SettingMemento.cpp +++ b/src/settings/SettingMemento.cpp @@ -1,17 +1,17 @@ -#include "src/settings/SettingsMemento.h" +#include "src/settings/SettingMemento.h" #include "src/settings/modules/ModuleSettings.h" namespace storm { namespace settings { - SettingMemento::SettingMemento(ModuleSettings& settings, std::string const& longOptionName, bool resetToState) : settings(settings), optionName(longOptionName), resetToState(resetToState) { + SettingMemento::SettingMemento(modules::ModuleSettings& settings, std::string const& longOptionName, bool resetToState) : settings(settings), optionName(longOptionName), resetToState(resetToState) { // Intentionally left empty. } /*! * Destructs the memento object and resets the value of the option to its original state. */ - virtual SettingMemento::~SettingMemento() { + SettingMemento::~SettingMemento() { if (resetToState) { settings.set(optionName); } else { diff --git a/src/settings/SettingMemento.h b/src/settings/SettingMemento.h index 342cdd666..551142fd2 100644 --- a/src/settings/SettingMemento.h +++ b/src/settings/SettingMemento.h @@ -6,7 +6,10 @@ namespace storm { namespace settings { - class ModuleSettings; + // Forward-declare the module settings. + namespace modules { + class ModuleSettings; + } /*! * This class is used to reset the state of an option that was temporarily set to a different status. @@ -21,7 +24,7 @@ namespace storm { * @param resetToState A flag that indicates the status to which the option is to be reset upon * deconstruction of this object. */ - SettingMemento(ModuleSettings& settings, std::string const& longOptionName, bool resetToState); + SettingMemento(modules::ModuleSettings& settings, std::string const& longOptionName, bool resetToState); /*! * Destructs the memento object and resets the value of the option to its original state. @@ -30,7 +33,7 @@ namespace storm { private: // The settings object in which the setting is to be restored. - ModuleSettings& settings; + modules::ModuleSettings& settings; // The long name of the option that was temporarily set. std::string const optionName; diff --git a/src/settings/SettingsManager.cpp b/src/settings/SettingsManager.cpp index 2581edd52..d9a109835 100644 --- a/src/settings/SettingsManager.cpp +++ b/src/settings/SettingsManager.cpp @@ -3,14 +3,23 @@ #include #include #include +#include #include "src/exceptions/OptionParserException.h" namespace storm { namespace settings { - SettingsManager::SettingsManager() : generalSettings(*this), debugSettings(*this), counterexampleGeneratorSettings(*this), cuddSettings(*this), gmmxxSettings(*this), nativeEquationSolverSettings(*this), glpkSettings(*this), gurobiSettings(*this) { - // Intentionally left empty. + SettingsManager::SettingsManager() { + // Register all known settings modules. + this->addModule(std::unique_ptr(new modules::GeneralSettings(*this))); + this->addModule(std::unique_ptr(new modules::DebugSettings(*this))); + this->addModule(std::unique_ptr(new modules::CounterexampleGeneratorSettings(*this))); + this->addModule(std::unique_ptr(new modules::CuddSettings(*this))); + this->addModule(std::unique_ptr(new modules::GmmxxEquationSolverSettings(*this))); + this->addModule(std::unique_ptr(new modules::NativeEquationSolverSettings(*this))); + this->addModule(std::unique_ptr(new modules::GlpkSettings(*this))); + this->addModule(std::unique_ptr(new modules::GurobiSettings(*this))); } SettingsManager::~SettingsManager() { @@ -18,283 +27,42 @@ namespace storm { } SettingsManager& SettingsManager::manager() { + static SettingsManager settingsManager; return settingsManager; } + void SettingsManager::setFromCommandLine(int const argc, char const * const argv[]) { + // We convert the arguments to a vector of strings and strip off the first element since it refers to the + // name of the program. + std::vector argumentVector(argc - 1); + for (uint_fast64_t i = 1; i < argc; ++i) { + argumentVector[i - 1] = std::string(argv[i]); + } + + this->setFromExplodedString(argumentVector); + } - } -} - - -/*! - * @brief Create new instance. - * - * Creates a new Settings instance and passes the arguments to the constructor of Settings. - * - * @param argc should be argc passed to main function - * @param argv should be argv passed to main function - * @param filename either NULL or name of config file - * @return The new instance of Settings. - */ -void storm::settings::SettingsManager::parse(int const argc, char const * const argv[]) { - storm::settings::SettingsManager* myInstance = storm::settings::SettingsManager::getInstance(); - myInstance->parseCommandLine(argc, argv); -} - -bool storm::settings::SettingsManager::hasAssignment(std::string const& option) { - return (option.find_first_of('=', 0) != std::string::npos); -} - -storm::settings::stringPair_t storm::settings::SettingsManager::splitOptionString(std::string const& option) { - size_t splitLocation = option.find_first_of('=', 0); - if (splitLocation == std::string::npos) { - // Second half is empty - return std::make_pair(option, ""); - } else if (splitLocation + 1 >= option.length()) { - // Remove the = character - return std::make_pair(option.substr(0, option.size() - 1), ""); - } - return std::make_pair(option.substr(0, splitLocation), option.substr(splitLocation + 1, std::string::npos)); -} - -void storm::settings::SettingsManager::handleAssignment(std::string const& longOptionName, std::vector arguments) { - std::string optionName = storm::utility::StringHelper::stringToLower(longOptionName); - - Option* option = this->getPtrByLongName(optionName); - - // Mark as Set - option->setHasOptionBeenSet(); - - uint_fast64_t givenArgsCount = arguments.size(); - - if (givenArgsCount > option->getArgumentCount()) { - LOG4CPLUS_ERROR(logger, "SettingsManager::handleAssignment: Unable to parse arguments for option \"" << longOptionName << "\": " << arguments.size() << " arguments given, but expected no more than " << option->getArgumentCount() << "."); - throw storm::exceptions::OptionParserException() << "Unable to parse arguments for option \"" << longOptionName << "\": " << arguments.size() << " arguments given, but expected no more than " << option->getArgumentCount() << "."; - } - - for (uint_fast64_t i = 0; i < option->getArgumentCount(); ++i) { - if (i < givenArgsCount) { - storm::settings::fromStringAssignmentResult_t assignmentResult = option->getArgument(i).fromStringValue(arguments.at(i)); - if (!assignmentResult.first) { - LOG4CPLUS_ERROR(logger, "SettingsManager::handleAssignment: Unable to parse arguments for option \"" << longOptionName << "\": argument " << option->getArgument(i).getArgumentName() << " rejected the given value \"" << arguments.at(i) << "\" with message:\r\n" << assignmentResult.second << "."); - throw storm::exceptions::OptionParserException() << "Unable to parse arguments for option \"" << longOptionName << "\": argument " << option->getArgument(i).getArgumentName() << " rejected the given value \"" << arguments.at(i) << "\" with message:\r\n" << assignmentResult.second << "."; - } - } else { - // There is no given value for this argument, only optional - if (!option->getArgument(i).getIsOptional()) { - LOG4CPLUS_ERROR(logger, "Settings::handleAssignment: Unable to parse arguments for option \"" << longOptionName << "\": " << arguments.size() << " arguments given, but more arguments were expected."); - throw storm::exceptions::OptionParserException() << "Unable to parse arguments for option \"" << longOptionName << "\": " << arguments.size() << " arguments given, but more arguments were expected."; - } else { - option->getArgument(i).setFromDefaultValue(); - } - } - } -} - -std::vector storm::settings::SettingsManager::argvToStringArray(int const argc, char const * const argv[]) { - // Ignore argv[0], it contains the program path and name - std::vector result; - for (int i = 1; i < argc; ++i) { - result.push_back(std::string(argv[i])); - } - return result; -} - -bool storm::settings::SettingsManager::checkArgumentSyntaxForOption(std::string const& argvString) { - if (argvString.size() < 2) { - return false; - } - - if ((argvString.at(0) != '-') || ((argvString.at(1) != '-') && !isalpha(argvString.at(1)))) { - return false; - } - - for (size_t i = 2; i < argvString.size(); ++i) { - if (!isalpha(argvString.at(i))) { - return false; - } - } - return true; -} - -std::vector storm::settings::SettingsManager::scanForOptions(std::vector const& arguments) { - std::vector result; - result.reserve(arguments.size()); - for (auto it = arguments.cbegin(); it != arguments.cend(); ++it) { - result.push_back(checkArgumentSyntaxForOption(*it)); - } - return result; -} - -void storm::settings::SettingsManager::parseCommandLine(int const argc, char const * const argv[]) { - LOG4CPLUS_DEBUG(logger, "Settings::parseCommandLine: Parsing " << argc << " arguments."); - - std::vector stringArgv = argvToStringArray(argc, argv); - std::vector optionPositions = scanForOptions(stringArgv); - - bool optionActive = false; - std::string longOptionName; - std::vector argCache; - for (size_t i = 0; i <= stringArgv.size(); ++i) { - if (i == stringArgv.size()) { - if (optionActive) { - this->handleAssignment(longOptionName, argCache); - argCache.clear(); - } - break; - } else if (optionPositions.at(i)) { - if (optionActive) { - this->handleAssignment(longOptionName, argCache); - argCache.clear(); - } - - std::string const& nextOption = stringArgv.at(i); - if (nextOption.at(0) == '-' && nextOption.at(1) != '-') { - // Short Option - std::string nextShortOptionName = storm::utility::StringHelper::stringToLower(nextOption.substr(1, nextOption.size() - 1)); - if (!this->containsShortName(nextShortOptionName)) { - LOG4CPLUS_ERROR(logger, "Settings::parseCommandLine: Unknown option name \"" << nextShortOptionName << "\"."); - throw storm::exceptions::OptionParserException() << "Unknown option name \"" << nextShortOptionName << "\"."; - } else { - longOptionName = this->getByShortName(nextShortOptionName).getLongName(); - optionActive = true; - } - } else { - // Long Option - std::string nextLongOptionName = storm::utility::StringHelper::stringToLower(nextOption.substr(2, nextOption.size() - 2)); - if (!this->containsLongName(nextLongOptionName)) { - LOG4CPLUS_ERROR(logger, "Settings::parseCommandLine: Unknown option name \"" << nextLongOptionName << "\"."); - throw storm::exceptions::OptionParserException() << "Unknown option name \"" << nextLongOptionName << "\"."; - } else { - longOptionName = this->getByLongName(nextLongOptionName).getLongName(); - optionActive = true; - } - } - } else if (optionActive) { - // Next argument for an Option found - argCache.push_back(stringArgv.at(i)); - } else { - // No Option active and this is no option. - LOG4CPLUS_ERROR(logger, "Settings::parseCommandLine: Found stray argument while parsing a given configuration, \"" << stringArgv.at(i) << "\" is neither a known option nor preceeded by an option."); - throw storm::exceptions::OptionParserException() << "Found stray argument while parsing a given configuration; \"" << stringArgv.at(i) << "\" is neither a known option nor preceeded by an option."; - } - } - - for (auto it = this->options.cbegin(); it != this->options.cend(); ++it) { - if (!it->second.get()->getHasOptionBeenSet()) { - if (it->second.get()->getIsRequired()) { - LOG4CPLUS_ERROR(logger, "Settings::parseCommandLine: Missing required option \"" << it->second.get()->getLongName() << "\"."); - throw storm::exceptions::OptionParserException() << "Missing required option \"" << it->second.get()->getLongName() << "\"."; - } else { - // Set defaults on optional values - for (uint_fast64_t i = 0; i < it->second.get()->getArgumentCount(); ++i) { - if (it->second.get()->getArgument(i).getHasDefaultValue()) { - it->second.get()->getArgument(i).setFromDefaultValue(); - } - } - } - } - } -} - -storm::settings::SettingsManager* storm::settings::SettingsManager::getInstance() { - // Usually, this would require double-checked locking. - // But since C++11, this is the way to go: - static storm::settings::SettingsManager pInstance; - - return &pInstance; -} - -storm::settings::SettingsManager& storm::settings::SettingsManager::addOption(Option* option) { - // For automatic management of option's lifetime - std::shared_ptr