Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
storm::settings::Argument< T > Class Template Reference

This class subclasses the argument base to actually implement the pure virtual functions. More...

#include <Argument.h>

Inheritance diagram for storm::settings::Argument< T >:
Collaboration diagram for storm::settings::Argument< T >:

Public Member Functions

 Argument (std::string const &name, std::string const &description, std::vector< std::shared_ptr< ArgumentValidator< T > > > const &validators)
 Creates a new argument with the given parameters.
 
 Argument (std::string const &name, std::string const &description, std::vector< std::shared_ptr< ArgumentValidator< T > > > const &validators, bool isOptional, T defaultValue)
 Creates a new argument with the given parameters.
 
virtual bool getIsOptional () const override
 Retrieves whether the argument is optional.
 
bool setFromStringValue (std::string const &fromStringValue) override
 Tries to set the value of the argument from the given string.
 
bool setFromTypeValue (T const &newValue, bool hasBeenSet=true)
 
virtual ArgumentType getType () const override
 Retrieves the type of the argument.
 
template<typename S >
bool isCompatibleWith (Argument< S > const &other) const
 Checks whether the given argument is compatible with the current one.
 
T constgetArgumentValue () const
 Retrieves the value of the argument if any has been set.
 
virtual bool getHasDefaultValue () const override
 Retrieves whether the argument has a default value.
 
void setFromDefaultValue () override
 Sets the value of the argument from the default value.
 
virtual bool wasSetFromDefaultValue () const override
 
virtual std::string getValueAsString () const override
 Retrieves the value of this argument as a string.
 
virtual int_fast64_t getValueAsInteger () const override
 Retrieves the value of this argument as an integer.
 
virtual uint_fast64_t getValueAsUnsignedInteger () const override
 Retrieves the value of this argument as an unsigned integer.
 
virtual double getValueAsDouble () const override
 Retrieves the value of this argument as a double.
 
virtual bool getValueAsBoolean () const override
 Retrieves the value of this argument as a boolean.
 
virtual void printToStream (std::ostream &out) const override
 Prints a string representation of the argument to the provided stream.
 
- Public Member Functions inherited from storm::settings::ArgumentBase
 ArgumentBase (std::string const &name, std::string const &description)
 Constructs a new argument base with the given name, description and indication whether the argument is optional.
 
virtual ~ArgumentBase ()=default
 
std::string constgetName () const
 Retrieves the name of the argument.
 
std::string constgetDescription () const
 Retrieves the description of the argument.
 
virtual bool getHasBeenSet () const
 Retrieves whether the argument has been set.
 
template<>
std::string convertFromString (std::string const &valueAsString, bool &conversionSuccessful)
 

Additional Inherited Members

- Static Protected Member Functions inherited from storm::settings::ArgumentBase
template<typename TargetType >
static TargetType convertFromString (std::string const &valueAsString, bool &conversionSuccessful)
 Converts the given value represented as a string to the type of the template parameter.
 
template<typename ValueType >
static std::string convertToString (ValueType const &value)
 Converts the given value to a string representation.
 
template<>
bool convertFromString (std::string const &s, bool &ok)
 
- Protected Attributes inherited from storm::settings::ArgumentBase
bool hasBeenSet
 
std::string name
 
std::string description
 

Detailed Description

template<typename T>
class storm::settings::Argument< T >

This class subclasses the argument base to actually implement the pure virtual functions.

This construction is necessary so that it becomes easy to store a vector of arguments later despite variing template types, by keeping a vector of pointers to the base class.

Definition at line 32 of file Argument.h.

Constructor & Destructor Documentation

◆ Argument() [1/2]

template<typename T >
storm::settings::Argument< T >::Argument ( std::string const name,
std::string const description,
std::vector< std::shared_ptr< ArgumentValidator< T > > > const validators 
)

Creates a new argument with the given parameters.

Parameters
nameThe name of the argument.
descriptionThe description of the argument.
validatorsA vector of validators that are to be executed upon assigning a value to this argument.
isOptionalA flag indicating whether the argument is optional.

Definition at line 15 of file Argument.cpp.

◆ Argument() [2/2]

template<typename T >
storm::settings::Argument< T >::Argument ( std::string const name,
std::string const description,
std::vector< std::shared_ptr< ArgumentValidator< T > > > const validators,
bool  isOptional,
defaultValue 
)

Creates a new argument with the given parameters.

Parameters
nameThe name of the argument.
descriptionThe description of the argument.
validatorsA vector of validators that are to be executed upon assigning a value to this argument.
isOptionalA flag indicating whether the argument is optional.

Definition at line 28 of file Argument.cpp.

Member Function Documentation

◆ getArgumentValue()

template<typename T >
T const & storm::settings::Argument< T >::getArgumentValue ( ) const

Retrieves the value of the argument if any has been set.

Otherwise, an exception is thrown.

Returns
The value of the argument.

Definition at line 72 of file Argument.cpp.

◆ getHasDefaultValue()

template<typename T >
bool storm::settings::Argument< T >::getHasDefaultValue ( ) const
overridevirtual

Retrieves whether the argument has a default value.

Returns
True iff the argument has a default value.

Implements storm::settings::ArgumentBase.

Definition at line 83 of file Argument.cpp.

◆ getIsOptional()

template<typename T >
bool storm::settings::Argument< T >::getIsOptional ( ) const
overridevirtual

Retrieves whether the argument is optional.

Returns
True iff the argument is optional.

Implements storm::settings::ArgumentBase.

Definition at line 42 of file Argument.cpp.

◆ getType()

template<typename T >
ArgumentType storm::settings::Argument< T >::getType ( ) const
overridevirtual

Retrieves the type of the argument.

Returns
The type of the argument.

Implements storm::settings::ArgumentBase.

Definition at line 67 of file Argument.cpp.

◆ getValueAsBoolean()

template<typename T >
bool storm::settings::Argument< T >::getValueAsBoolean ( ) const
overridevirtual

Retrieves the value of this argument as a boolean.

If the conversion cannot be performed, an exception is thrown.

Returns
The value of this argument as an boolean.

Implements storm::settings::ArgumentBase.

Definition at line 155 of file Argument.cpp.

◆ getValueAsDouble()

template<typename T >
double storm::settings::Argument< T >::getValueAsDouble ( ) const
overridevirtual

Retrieves the value of this argument as a double.

If the conversion cannot be performed, an exception is thrown.

Returns
The value of this argument as an double.

Implements storm::settings::ArgumentBase.

Definition at line 144 of file Argument.cpp.

◆ getValueAsInteger()

template<typename T >
int_fast64_t storm::settings::Argument< T >::getValueAsInteger ( ) const
overridevirtual

Retrieves the value of this argument as an integer.

If the conversion cannot be performed, an exception is thrown.

Returns
The value of this argument as an integer.

Implements storm::settings::ArgumentBase.

Definition at line 121 of file Argument.cpp.

◆ getValueAsString()

template<typename T >
std::string storm::settings::Argument< T >::getValueAsString ( ) const
overridevirtual

Retrieves the value of this argument as a string.

Returns
The value of this argument as a string.

Implements storm::settings::ArgumentBase.

Definition at line 103 of file Argument.cpp.

◆ getValueAsUnsignedInteger()

template<typename T >
uint_fast64_t storm::settings::Argument< T >::getValueAsUnsignedInteger ( ) const
overridevirtual

Retrieves the value of this argument as an unsigned integer.

If the conversion cannot be performed, an exception is thrown.

Returns
The value of this argument as an unsigned integer.

Implements storm::settings::ArgumentBase.

Definition at line 132 of file Argument.cpp.

◆ isCompatibleWith()

template<typename T >
template<typename S >
bool storm::settings::Argument< T >::isCompatibleWith ( Argument< S > const other) const
inline

Checks whether the given argument is compatible with the current one.

If not, an exception is thrown.

Parameters
otherThe other argument with which to check compatibility.
Returns
True iff the given argument is compatible with the current one.

Definition at line 70 of file Argument.h.

◆ printToStream()

template<typename T >
void storm::settings::Argument< T >::printToStream ( std::ostream &  out) const
overridevirtual

Prints a string representation of the argument to the provided stream.

Implements storm::settings::ArgumentBase.

Definition at line 197 of file Argument.cpp.

◆ setFromDefaultValue()

template<typename T >
void storm::settings::Argument< T >::setFromDefaultValue ( )
overridevirtual

Sets the value of the argument from the default value.

Implements storm::settings::ArgumentBase.

Definition at line 88 of file Argument.cpp.

◆ setFromStringValue()

template<typename T >
bool storm::settings::Argument< T >::setFromStringValue ( std::string const stringValue)
overridevirtual

Tries to set the value of the argument from the given string.

Parameters
stringValueThe new value of the argument given as a string.
Returns
True iff the assignment was successful.

Implements storm::settings::ArgumentBase.

Definition at line 47 of file Argument.cpp.

◆ setFromTypeValue()

template<typename T >
bool storm::settings::Argument< T >::setFromTypeValue ( T const newValue,
bool  hasBeenSet = true 
)

Definition at line 57 of file Argument.cpp.

◆ wasSetFromDefaultValue()

template<typename T >
bool storm::settings::Argument< T >::wasSetFromDefaultValue ( ) const
overridevirtual

Implements storm::settings::ArgumentBase.

Definition at line 98 of file Argument.cpp.


The documentation for this class was generated from the following files: