Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ArgumentBase.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <iostream>
5#include <string>
6
8
9namespace storm {
10namespace settings {
11
16 public:
25 ArgumentBase(std::string const& name, std::string const& description) : hasBeenSet(false), name(name), description(description) {
26 // Intentionally left empty.
27 }
28
29 virtual ~ArgumentBase() = default;
30
36 virtual ArgumentType getType() const = 0;
37
43 virtual bool getIsOptional() const = 0;
44
50 std::string const& getName() const {
51 return this->name;
52 }
53
59 std::string const& getDescription() const {
60 return this->description;
61 }
62
68 virtual bool getHasDefaultValue() const = 0;
69
75 virtual bool getHasBeenSet() const {
76 return this->hasBeenSet;
77 }
78
82 virtual void setFromDefaultValue() = 0;
83
84 virtual bool wasSetFromDefaultValue() const = 0;
85
92 virtual bool setFromStringValue(std::string const& stringValue) = 0;
93
99 virtual std::string getValueAsString() const = 0;
100
107 virtual int_fast64_t getValueAsInteger() const = 0;
108
115 virtual uint_fast64_t getValueAsUnsignedInteger() const = 0;
116
123 virtual double getValueAsDouble() const = 0;
124
131 virtual bool getValueAsBoolean() const = 0;
132
136 virtual void printToStream(std::ostream& out) const = 0;
137
138 friend std::ostream& operator<<(std::ostream& out, ArgumentBase const& argument);
139
140 protected:
141 // A flag indicating whether the argument has been set.
143
144 // The name of the argument.
145 std::string name;
146
147 // The description of the argument.
148 std::string description;
149
158 template<typename TargetType>
159 static TargetType convertFromString(std::string const& valueAsString, bool& conversionSuccessful);
160
167 template<typename ValueType>
168 static std::string convertToString(ValueType const& value);
169};
170} // namespace settings
171} // namespace storm
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.
ArgumentType
This enum captures all possible types for arguments.