Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Option.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <iostream>
5#include <memory>
6#include <string>
7#include <vector>
8
9#include <unordered_map>
10
11#include "ArgumentBase.h"
12
13namespace storm {
14namespace settings {
15
16// Forward-declare settings manager and module settings classes.
17class SettingsManager;
18namespace modules {
19class ModuleSettings;
20}
21class ArgumentBase;
22
26class Option {
27 public:
28 // Declare settings manager and module settings classes as friends.
29 friend class SettingsManager;
31
44 Option(std::string const& moduleName, std::string const& longOptionName, std::string const& optionDescription, bool isOptionRequired,
45 bool requireModulePrefix, bool isAdvanced,
46 std::vector<std::shared_ptr<ArgumentBase>> const& optionArguments = std::vector<std::shared_ptr<ArgumentBase>>());
47
60 Option(std::string const& moduleName, std::string const& longOptionName, std::string const& shortOptionName, std::string const& optionDescription,
61 bool isOptionRequired, bool requireModulePrefix, bool isAdvanced,
62 std::vector<std::shared_ptr<ArgumentBase>> const& optionArguments = std::vector<std::shared_ptr<ArgumentBase>>());
63
70 bool isCompatibleWith(Option const& other);
71
77 uint_fast64_t getArgumentCount() const;
78
85 ArgumentBase const& getArgument(uint_fast64_t argumentIndex) const;
86
93 ArgumentBase& getArgument(uint_fast64_t argumentIndex);
94
101 ArgumentBase const& getArgumentByName(std::string const& argumentName) const;
102
109 ArgumentBase& getArgumentByName(std::string const& argumentName);
110
116 std::string const& getLongName() const;
117
123 bool getHasShortName() const;
124
130 std::string const& getShortName() const;
131
137 std::string const& getDescription() const;
138
144 std::string const& getModuleName() const;
145
151 bool getIsRequired() const;
152
158 bool getRequiresModulePrefix() const;
159
165 bool getHasOptionBeenSet() const;
166
173
177 bool getIsAdvanced() const;
178
184 std::vector<std::shared_ptr<ArgumentBase>> const& getArguments() const;
185
191 uint_fast64_t getPrintLength() const;
192
193 friend std::ostream& operator<<(std::ostream& out, Option const& option);
194
195 private:
196 // The long name of the option.
197 std::string longName;
198
199 // A flag that indicates whether the option has a short name.
200 bool hasShortName;
201
202 // The short name of the option if any is set and an empty string otherwise.
203 std::string shortName;
204
205 // The description of the option.
206 std::string description;
207
208 // The name of the module to which this option belongs.
209 std::string moduleName;
210
211 // A flag that indicates whether this option is required to appear.
212 bool isRequired;
213
214 // A flag that indicates whether this option is required to be prefixed with the module name.
215 bool requireModulePrefix;
216
217 // A flag that indicates whether this option is only displayed in the advanced help.
218 bool isAdvanced;
219
220 // A flag that indicates whether this option has been set.
221 bool hasBeenSet;
222
223 // A flag that indicates whether this option has been set.
224 bool hasBeenSetWithModulePrefix;
225
226 // The arguments of this option (possibly empty).
227 std::vector<std::shared_ptr<ArgumentBase>> arguments;
228
229 // A mapping from argument names of this option to the actual arguments.
230 std::unordered_map<std::string, std::shared_ptr<ArgumentBase>> argumentNameMap;
231
246 Option(std::string const& moduleName, std::string const& longOptionName, std::string const& shortOptionName, bool hasShortOptionName,
247 std::string const& optionDescription, bool isOptionRequired, bool requireModulePrefix, bool isAdvanced,
248 std::vector<std::shared_ptr<ArgumentBase>> const& optionArguments = std::vector<std::shared_ptr<ArgumentBase>>());
249
255 void setHasOptionBeenSet(bool newValue = true);
256
262 void setHasOptionBeenSetWithModulePrefix(bool newValue = true);
263};
264} // namespace settings
265} // namespace storm
This class serves as the (untemplated) base class of argument classes.
bool getHasShortName() const
Retrieves whether this option has a short name.
Definition Option.cpp:97
std::string const & getModuleName() const
Retrieves the name of the module to which this option belongs.
Definition Option.cpp:109
std::string const & getDescription() const
Retrieves the description of the option.
Definition Option.cpp:105
uint_fast64_t getArgumentCount() const
Retrieves the argument count this option expects.
Definition Option.cpp:65
friend class SettingsManager
Definition Option.h:29
ArgumentBase const & getArgumentByName(std::string const &argumentName) const
Returns a reference to the argument with the specified long name.
Definition Option.cpp:79
bool getHasOptionBeenSetWithModulePrefix() const
Retrieves whether the option has been set by including the module prefix.
Definition Option.cpp:129
friend std::ostream & operator<<(std::ostream &out, Option const &option)
Definition Option.cpp:200
std::string const & getShortName() const
Retrieves the short name of this option.
Definition Option.cpp:101
std::vector< std::shared_ptr< ArgumentBase > > const & getArguments() const
Retrieves the arguments of the option.
Definition Option.cpp:196
bool getIsAdvanced() const
Retrieves whether the option is only displayed in the advanced help.
Definition Option.cpp:121
ArgumentBase const & getArgument(uint_fast64_t argumentIndex) const
Retrieves the i-th argument of this option.
Definition Option.cpp:69
std::string const & getLongName() const
Retrieves the long name of this option.
Definition Option.cpp:93
uint_fast64_t getPrintLength() const
Retrieves the (print) length of the option.
Definition Option.cpp:177
bool getRequiresModulePrefix() const
Retrieves whether the option requires the module name as a prefix.
Definition Option.cpp:117
Option(std::string const &moduleName, std::string const &longOptionName, std::string const &optionDescription, bool isOptionRequired, bool requireModulePrefix, bool isAdvanced, std::vector< std::shared_ptr< ArgumentBase > > const &optionArguments=std::vector< std::shared_ptr< ArgumentBase > >())
Creates an option with the given parameters.
Definition Option.cpp:16
bool getIsRequired() const
Retrieves whether the option is required.
Definition Option.cpp:113
bool getHasOptionBeenSet() const
Retrieves whether the option has been set.
Definition Option.cpp:125
bool isCompatibleWith(Option const &other)
Checks whether the given option is compatible with the current one.
Definition Option.cpp:28
Provides the central API for the registration of command line options and parsing the options from th...
This is the base class of the settings for a particular module.