Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Option.h
Go to the documentation of this file.
1#ifndef STORM_SETTINGS_OPTION_H_
2#define STORM_SETTINGS_OPTION_H_
3
4#include <cstdint>
5#include <iostream>
6#include <memory>
7#include <string>
8#include <vector>
9
10#include <unordered_map>
11
12#include "ArgumentBase.h"
13
14namespace storm {
15namespace settings {
16
17// Forward-declare settings manager and module settings classes.
18class SettingsManager;
19namespace modules {
20class ModuleSettings;
21}
22class ArgumentBase;
23
27class Option {
28 public:
29 // Declare settings manager and module settings classes as friends.
30 friend class SettingsManager;
32
45 Option(std::string const& moduleName, std::string const& longOptionName, std::string const& optionDescription, bool isOptionRequired,
46 bool requireModulePrefix, bool isAdvanced,
47 std::vector<std::shared_ptr<ArgumentBase>> const& optionArguments = std::vector<std::shared_ptr<ArgumentBase>>());
48
61 Option(std::string const& moduleName, std::string const& longOptionName, std::string const& shortOptionName, std::string const& optionDescription,
62 bool isOptionRequired, bool requireModulePrefix, bool isAdvanced,
63 std::vector<std::shared_ptr<ArgumentBase>> const& optionArguments = std::vector<std::shared_ptr<ArgumentBase>>());
64
71 bool isCompatibleWith(Option const& other);
72
79
87
95
102 ArgumentBase const& getArgumentByName(std::string const& argumentName) const;
103
110 ArgumentBase& getArgumentByName(std::string const& argumentName);
111
117 std::string const& getLongName() const;
118
124 bool getHasShortName() const;
125
131 std::string const& getShortName() const;
132
138 std::string const& getDescription() const;
139
145 std::string const& getModuleName() const;
146
152 bool getIsRequired() const;
153
159 bool getRequiresModulePrefix() const;
160
166 bool getHasOptionBeenSet() const;
167
174
178 bool getIsAdvanced() const;
179
185 std::vector<std::shared_ptr<ArgumentBase>> const& getArguments() const;
186
193
194 friend std::ostream& operator<<(std::ostream& out, Option const& option);
195
196 private:
197 // The long name of the option.
198 std::string longName;
199
200 // A flag that indicates whether the option has a short name.
201 bool hasShortName;
202
203 // The short name of the option if any is set and an empty string otherwise.
204 std::string shortName;
205
206 // The description of the option.
207 std::string description;
208
209 // The name of the module to which this option belongs.
210 std::string moduleName;
211
212 // A flag that indicates whether this option is required to appear.
213 bool isRequired;
214
215 // A flag that indicates whether this option is required to be prefixed with the module name.
216 bool requireModulePrefix;
217
218 // A flag that indicates whether this option is only displayed in the advanced help.
219 bool isAdvanced;
220
221 // A flag that indicates whether this option has been set.
222 bool hasBeenSet;
223
224 // A flag that indicates whether this option has been set.
225 bool hasBeenSetWithModulePrefix;
226
227 // The arguments of this option (possibly empty).
228 std::vector<std::shared_ptr<ArgumentBase>> arguments;
229
230 // A mapping from argument names of this option to the actual arguments.
231 std::unordered_map<std::string, std::shared_ptr<ArgumentBase>> argumentNameMap;
232
247 Option(std::string const& moduleName, std::string const& longOptionName, std::string const& shortOptionName, bool hasShortOptionName,
248 std::string const& optionDescription, bool isOptionRequired, bool requireModulePrefix, bool isAdvanced,
249 std::vector<std::shared_ptr<ArgumentBase>> const& optionArguments = std::vector<std::shared_ptr<ArgumentBase>>());
250
256 void setHasOptionBeenSet(bool newValue = true);
257
263 void setHasOptionBeenSetWithModulePrefix(bool newValue = true);
264};
265} // namespace settings
266} // namespace storm
267
268#endif // STORM_SETTINGS_OPTION_H_
This class serves as the (untemplated) base class of argument classes.
This class represents one command-line option.
Definition Option.h:27
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
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
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.
SettingsType const & getModule()
Get module.
LabParser.cpp.
Definition cli.cpp:18