#ifndef STORM_SETTINGS_SETTINGSMANAGER_H_ #define STORM_SETTINGS_SETTINGSMANAGER_H_ #include #include #include #include #include #include #include #include #include #include #include "src/settings/Option.h" #include "src/settings/OptionBuilder.h" #include "src/settings/ArgumentBase.h" #include "src/settings/Argument.h" #include "src/settings/ArgumentBuilder.h" #include "src/settings/ArgumentType.h" #include "src/settings/modules/ModuleSettings.h" #include "src/settings/modules/GeneralSettings.h" #include "src/settings/modules/DebugSettings.h" #include "src/settings/modules/CounterexampleGeneratorSettings.h" #include "src/settings/modules/CuddSettings.h" #include "src/settings/modules/GmmxxEquationSolverSettings.h" #include "src/settings/modules/NativeEquationSolverSettings.h" #include "src/settings/modules/BisimulationSettings.h" #include "src/settings/modules/GlpkSettings.h" #include "src/settings/modules/GurobiSettings.h" #include "src/settings/modules/ParametricSettings.h" #include "src/utility/macros.h" #include "src/exceptions/OptionParserException.h" namespace storm { namespace settings { /*! * Provides the central API for the registration of command line options and parsing the options from the * command line. Since this class is a singleton, the only instance is accessible via a call to the manager() * function. */ class SettingsManager { public: /*! * This function parses the given command line arguments and sets all registered options accordingly. If the * command line cannot be matched using the known options, an exception is thrown. * * @param argc The number of command line arguments. * @param argv The command line arguments. */ void setFromCommandLine(int const argc, char const * const argv[]); /*! * This function parses the given command line arguments (represented by one big string) and sets all * registered options accordingly. If the command line cannot be matched using the known options, an * exception is thrown. * * @param commandLineString The command line arguments as one string. */ void setFromString(std::string const& commandLineString); /*! * This function parses the given command line arguments (represented by several strings) and sets all * registered options accordingly. If the command line cannot be matched using the known options, an * exception is thrown. * * @param commandLineArguments The command line arguments. */ void setFromExplodedString(std::vector const& commandLineArguments); /*! * This function parses the given file and sets all registered options accordingly. If the settings cannot * be matched using the known options, an exception is thrown. */ void setFromConfigurationFile(std::string const& configFilename); /*! * This function prints a help message to the standard output. Optionally, a string can be given as a hint. * If it is 'all', the complete help is shown. Otherwise, the string is interpreted as a regular expression * and matched against the known modules and options to restrict the help output. * * @param hint A regular expression to restrict the help output or "all" for the full help text. */ void printHelp(std::string const& hint = "all") const; /*! * This function prints a help message for the specified module to the standard output. * * @param moduleName The name of the module for which to show the help. * @param maxLength The maximal length of an option name (necessary for proper alignment). */ void printHelpForModule(std::string const& moduleName, uint_fast64_t maxLength = 30) const; /*! * This function prints the version string to the command line. */ void printVersion() const; /*! * Retrieves the only existing instance of a settings manager. * * @return The only existing instance of a settings manager */ static SettingsManager& manager(); /*! * Adds a new module with the given name. If the module could not be successfully added, an exception is * thrown. * * @param moduleSettings The settings of the module to add. */ void addModule(std::unique_ptr&& moduleSettings); /*! * Retrieves the settings of the module with the given name. * * @param moduleName The name of the module for which to retrieve the settings. * @return An object that provides access to the settings of the module. */ modules::ModuleSettings const& getModule(std::string const& moduleName) const; /*! * Retrieves the settings of the module with the given name. * * @param moduleName The name of the module for which to retrieve the settings. * @return An object that provides access to the settings of the module. */ modules::ModuleSettings& getModule(std::string const& moduleName); private: /*! * Constructs a new manager. This constructor is private to forbid instantiation of this class. The only * way to create a new instance is by calling the static manager() method. */ SettingsManager(); /*! * This destructor is private, since we need to forbid explicit destruction of the manager. */ virtual ~SettingsManager(); // The registered modules. std::vector moduleNames; std::unordered_map> modules; // Mappings from all known option names to the options that match it. All options for one option name need // to be compatible in the sense that calling isCompatible(...) pairwise on all options must always return true. std::unordered_map>> longNameToOptions; std::unordered_map>> shortNameToOptions; // A mapping of module names to the corresponding options. std::unordered_map>> moduleOptions; // A list of long option names to keep the order in which they were registered. This is, for example, used // to match the regular expression given to the help option against the option names. std::vector longOptionNames; /*! * Adds the given option to the known options. * * @param option The option to add. */ void addOption(std::shared_ptr