Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ArgumentBase.h
Go to the documentation of this file.
1#ifndef STORM_SETTINGS_ARGUMENTBASE_H_
2#define STORM_SETTINGS_ARGUMENTBASE_H_
3
4#include <cstdint>
5#include <iostream>
6#include <string>
7
9
10namespace storm {
11namespace settings {
12
17 public:
26 ArgumentBase(std::string const& name, std::string const& description) : hasBeenSet(false), name(name), description(description) {
27 // Intentionally left empty.
28 }
29
30 virtual ~ArgumentBase() = default;
31
37 virtual ArgumentType getType() const = 0;
38
44 virtual bool getIsOptional() const = 0;
45
51 std::string const& getName() const {
52 return this->name;
53 }
54
60 std::string const& getDescription() const {
61 return this->description;
62 }
63
69 virtual bool getHasDefaultValue() const = 0;
70
76 virtual bool getHasBeenSet() const {
77 return this->hasBeenSet;
78 }
79
83 virtual void setFromDefaultValue() = 0;
84
85 virtual bool wasSetFromDefaultValue() const = 0;
86
93 virtual bool setFromStringValue(std::string const& stringValue) = 0;
94
100 virtual std::string getValueAsString() const = 0;
101
108 virtual int_fast64_t getValueAsInteger() const = 0;
109
117
124 virtual double getValueAsDouble() const = 0;
125
132 virtual bool getValueAsBoolean() const = 0;
133
137 virtual void printToStream(std::ostream& out) const = 0;
138
139 friend std::ostream& operator<<(std::ostream& out, ArgumentBase const& argument);
140
141 protected:
142 // A flag indicating whether the argument has been set.
144
145 // The name of the argument.
146 std::string name;
147
148 // The description of the argument.
149 std::string description;
150
159 template<typename TargetType>
160 static TargetType convertFromString(std::string const& valueAsString, bool& conversionSuccessful);
161
168 template<typename ValueType>
169 static std::string convertToString(ValueType const& value);
170};
171} // namespace settings
172} // namespace storm
173
174#endif // STORM_SETTINGS_ARGUMENTBASE_H_
This class serves as the (untemplated) base class of argument classes.
std::string const & getDescription() const
Retrieves the description of the argument.
virtual std::string getValueAsString() const =0
Retrieves the value of this argument as a string.
virtual ~ArgumentBase()=default
virtual bool setFromStringValue(std::string const &stringValue)=0
Tries to set the value of the argument from the given string.
static TargetType convertFromString(std::string const &valueAsString, bool &conversionSuccessful)
Converts the given value represented as a string to the type of the template parameter.
static std::string convertToString(ValueType const &value)
Converts the given value to a string representation.
virtual int_fast64_t getValueAsInteger() const =0
Retrieves the value of this argument as an integer.
virtual bool getIsOptional() const =0
Retrieves whether the argument is optional.
std::string const & getName() const
Retrieves the name of the argument.
virtual void setFromDefaultValue()=0
Sets the value of the argument from the default value.
virtual uint_fast64_t getValueAsUnsignedInteger() const =0
Retrieves the value of this argument as an unsigned integer.
virtual ArgumentType getType() const =0
Retrieves the type of the argument.
virtual bool getHasBeenSet() const
Retrieves whether the argument has been set.
virtual bool getValueAsBoolean() const =0
Retrieves the value of this argument as a boolean.
friend std::ostream & operator<<(std::ostream &out, ArgumentBase const &argument)
virtual void printToStream(std::ostream &out) const =0
Prints a string representation of the argument to the provided stream.
ArgumentBase(std::string const &name, std::string const &description)
Constructs a new argument base with the given name, description and indication whether the argument i...
virtual double getValueAsDouble() const =0
Retrieves the value of this argument as a double.
virtual bool wasSetFromDefaultValue() const =0
virtual bool getHasDefaultValue() const =0
Retrieves whether the argument has a default value.
SettingsType const & getModule()
Get module.
ArgumentType
This enum captures all possible types for arguments.
LabParser.cpp.
Definition cli.cpp:18