Browse Source
Further refactoring of option system.
Further refactoring of option system.
Former-commit-id: 350ac4c654
tempestpy_adaptions
dehnert
10 years ago
23 changed files with 700 additions and 333 deletions
-
8src/settings/Argument.cpp
-
22src/settings/Argument.h
-
80src/settings/ArgumentBase.h
-
30src/settings/ArgumentBuilder.h
-
90src/settings/ArgumentTypeInferationHelper.cpp
-
167src/settings/ArgumentTypeInferationHelper.h
-
36src/settings/ArgumentValidators.h
-
28src/settings/Option.h
-
2src/settings/OptionBuilder.h
-
35src/settings/SettingsManager.h
-
27src/settings/modules/CounterexampleGeneratorSettings.cpp
-
65src/settings/modules/CounterexampleGeneratorSettings.h
-
18src/settings/modules/CuddSettings.cpp
-
36src/settings/modules/CuddSettings.h
-
19src/settings/modules/DebugSettings.cpp
-
41src/settings/modules/DebugSettings.h
-
42src/settings/modules/GeneralSettings.cpp
-
142src/settings/modules/GeneralSettings.h
-
10src/settings/modules/GlpkSettings.cpp
-
17src/settings/modules/GlpkSettings.h
-
47src/settings/modules/GmmxxSettings.cpp
-
71src/settings/modules/GmmxxSettings.h
-
0src/settings/modules/NativeEquationSolverSettings.cpp
@ -0,0 +1,8 @@ |
|||
#include "src/settings/Argument.h"
|
|||
|
|||
namespace storm { |
|||
namespace settings { |
|||
const std::string Argument::trueString = "true"; |
|||
const std::string Argument::falseString = "false"; |
|||
} |
|||
} |
@ -0,0 +1,90 @@ |
|||
#include "src/settings/ArgumentTypeInferationHelper.h"
|
|||
|
|||
namespace storm { |
|||
namespace settings { |
|||
template <typename T> |
|||
ArgumentType ArgumentTypeInferation::inferToEnumType() { |
|||
LOG_THROW(false, storm::exceptions::InternalTypeErrorException, "Unable to infer type of argument."); |
|||
} |
|||
|
|||
template <> |
|||
ArgumentType ArgumentTypeInferation::inferToEnumType<std::string>() { |
|||
return ArgumentType::String; |
|||
} |
|||
|
|||
template <> |
|||
ArgumentType ArgumentTypeInferation::inferToEnumType<int_fast64_t>() { |
|||
return ArgumentType::Integer; |
|||
} |
|||
|
|||
template <> |
|||
ArgumentType ArgumentTypeInferation::inferToEnumType<uint_fast64_t>() { |
|||
return ArgumentType::UnsignedInteger; |
|||
} |
|||
|
|||
template <> |
|||
ArgumentType ArgumentTypeInferation::inferToEnumType<double>() { |
|||
return ArgumentType::Double; |
|||
} |
|||
|
|||
template <> |
|||
ArgumentType ArgumentTypeInferation::inferToEnumType<bool>() { |
|||
return ArgumentType::Boolean; |
|||
} |
|||
|
|||
template <typename T> |
|||
std::string const& ArgumentTypeInferation::inferToString(ArgumentType const& argumentType, T const& value) { |
|||
LOG_THROW(false, storm::exceptions::InternalTypeErrorException, "Unable to infer string from non-string argument value."); |
|||
} |
|||
|
|||
template <> |
|||
std::string const& ArgumentTypeInferation::inferToString<std::string>(ArgumentType const& argumentType, std::string const& value) { |
|||
LOG_THROW(argumentType == ArgumentType::String, storm::exceptions::InternalTypeErrorException, "Unable to infer string from non-string argument."); |
|||
return value; |
|||
} |
|||
|
|||
template <typename T> |
|||
int_fast64_t ArgumentTypeInferation::inferToInteger(ArgumentType const& argumentType, T const& value) { |
|||
LOG_THROW(false, storm::exceptions::InternalTypeErrorException, "Unable to infer integer from non-integer argument value."); |
|||
} |
|||
|
|||
template <> |
|||
int_fast64_t ArgumentTypeInferation::inferToInteger<int_fast64_t>(ArgumentType const& argumentType, int_fast64_t const& value) { |
|||
LOG_THROW(argumentType == ArgumentType::Integer, storm::exceptions::InternalTypeErrorException, "Unable to infer integer from non-integer argument."); |
|||
return value; |
|||
} |
|||
|
|||
template <typename T> |
|||
uint_fast64_t ArgumentTypeInferation::inferToUnsignedInteger(ArgumentType const& argumentType, T const& value) { |
|||
LOG_THROW(false, storm::exceptions::InternalTypeErrorException, "Unable to infer unsigned integer from non-unsigned argument value."); |
|||
} |
|||
|
|||
template <> |
|||
uint_fast64_t ArgumentTypeInferation::inferToUnsignedInteger<uint_fast64_t>(ArgumentType const& argumentType, uint_fast64_t const& value) { |
|||
LOG_THROW(argumentType == ArgumentType::UnsignedInteger, storm::exceptions::InternalTypeErrorException, "Unable to infer integer from non-integer argument."); |
|||
return value; |
|||
} |
|||
|
|||
template <typename T> |
|||
double ArgumentTypeInferation::inferToDouble(ArgumentType const& argumentType, T const& value) { |
|||
LOG_THROW(false, storm::exceptions::InternalTypeErrorException, "Unable to infer double from non-double argument value."); |
|||
} |
|||
|
|||
template <> |
|||
double ArgumentTypeInferation::inferToDouble<double>(ArgumentType const& argumentType, double const& value) { |
|||
LOG_THROW(argumentType == ArgumentType::UnsignedInteger, storm::exceptions::InternalTypeErrorException, "Unable to infer double from non-double argument."); |
|||
return value; |
|||
} |
|||
|
|||
template <typename T> |
|||
bool ArgumentTypeInferation::inferToBoolean(ArgumentType const& argumentType, T const& value) { |
|||
LOG_THROW(false, storm::exceptions::InternalTypeErrorException, "Unable to infer boolean from non-boolean argument value."); |
|||
} |
|||
|
|||
template <> |
|||
bool ArgumentTypeInferation::inferToBoolean<bool>(ArgumentType const& argumentType, bool const& value) { |
|||
LOG_THROW(argumentType == ArgumentType::Boolean, storm::exceptions::InternalTypeErrorException, "Unable to infer boolean from non-boolean argument."); |
|||
return value; |
|||
} |
|||
} |
|||
} |
@ -1,167 +1,38 @@ |
|||
/* |
|||
* ArgumentTypeInferationHelper.h |
|||
* |
|||
* Created on: 19.07.2013 |
|||
* Author: Philipp Berger |
|||
* Static Lookup Helper that detects whether the given Template Type is valid. |
|||
*/ |
|||
|
|||
#ifndef STORM_SETTINGS_ARGUMENTTYPEINFERATIONHELPER_H_ |
|||
#define STORM_SETTINGS_ARGUMENTTYPEINFERATIONHELPER_H_ |
|||
|
|||
#include <cstdint> |
|||
#include <string> |
|||
|
|||
#include "ArgumentType.h" |
|||
#include "src/settings/ArgumentType.h" |
|||
#include "src/exceptions/ExceptionMacros.h" |
|||
#include "src/exceptions/InternalTypeErrorException.h" |
|||
|
|||
#include "log4cplus/logger.h" |
|||
#include "log4cplus/loggingmacros.h" |
|||
extern log4cplus::Logger logger; |
|||
|
|||
namespace storm { |
|||
namespace settings { |
|||
/*! |
|||
* This class serves as a helper class to infer the types of arguments. |
|||
*/ |
|||
class ArgumentTypeInferation { |
|||
public: |
|||
// Specialized function template that infers the Type of T to our local enum |
|||
/*! |
|||
* This function infers the type in our enum of possible types from the template parameter. |
|||
* |
|||
* @return The argument type that has been inferred. |
|||
*/ |
|||
template <typename T> |
|||
static ArgumentType inferToEnumType(); |
|||
|
|||
// Specialized function templates that allow casting using the Enum Class as Target |
|||
template <typename T> static std::string inferToString(ArgumentType argumentType, T value); |
|||
template <typename T> static int_fast64_t inferToInteger(ArgumentType argumentType, T value); |
|||
template <typename T> static uint_fast64_t inferToUnsignedInteger(ArgumentType argumentType, T value); |
|||
template <typename T> static double inferToDouble(ArgumentType argumentType, T value); |
|||
template <typename T> static bool inferToBoolean(ArgumentType argumentType, T value); |
|||
|
|||
private: |
|||
ArgumentTypeInferation(); |
|||
~ArgumentTypeInferation(); |
|||
// Specialized function templates that allow casting the given value to the correct type. If the conversion |
|||
// fails, an exception is thrown. |
|||
template <typename T> static std::string const& inferToString(ArgumentType const& argumentType, T const& value); |
|||
template <typename T> static int_fast64_t inferToInteger(ArgumentType const& argumentType, T const& value); |
|||
template <typename T> static uint_fast64_t inferToUnsignedInteger(ArgumentType const& argumentType, T const& value); |
|||
template <typename T> static double inferToDouble(ArgumentType const& argumentType, T const& value); |
|||
template <typename T> static bool inferToBoolean(ArgumentType const& argumentType, T const& value); |
|||
}; |
|||
|
|||
/* |
|||
* All functions related to the EnumType Inferation from the Template Parameter |
|||
*/ |
|||
template <typename T> |
|||
ArgumentType ArgumentTypeInferation::inferToEnumType() { |
|||
// "Missing Template Specialization Case in ArgumentTypeInferation" |
|||
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToEnumType: Missing a template specialization case in the ArgumentTypeInferationHelper."); |
|||
throw storm::exceptions::InternalTypeErrorException() << "Missing a template specialization case in the ArgumentTypeInferationHelper."; |
|||
|
|||
return ArgumentType::Invalid; |
|||
} |
|||
|
|||
template <> inline ArgumentType ArgumentTypeInferation::inferToEnumType<std::string>() { |
|||
return ArgumentType::String; |
|||
} |
|||
template <> inline ArgumentType ArgumentTypeInferation::inferToEnumType<int_fast64_t>() { |
|||
return ArgumentType::Integer; |
|||
} |
|||
template <> inline ArgumentType ArgumentTypeInferation::inferToEnumType<uint_fast64_t>() { |
|||
return ArgumentType::UnsignedInteger; |
|||
} |
|||
template <> inline ArgumentType ArgumentTypeInferation::inferToEnumType<double>() { |
|||
return ArgumentType::Double; |
|||
} |
|||
template <> inline ArgumentType ArgumentTypeInferation::inferToEnumType<bool>() { |
|||
return ArgumentType::Boolean; |
|||
} |
|||
|
|||
/* |
|||
* All functions related to the conversion to std::string based on the Template and Enum Type |
|||
*/ |
|||
template <typename T> |
|||
std::string ArgumentTypeInferation::inferToString(ArgumentType argumentType, T value) { |
|||
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToString: Unable to perform inferToString on a non-string template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."); |
|||
throw storm::exceptions::InternalTypeErrorException() << "Unable to perform inferToString on a non-string template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."; |
|||
|
|||
return std::string(); |
|||
} |
|||
|
|||
template <> inline std::string ArgumentTypeInferation::inferToString<std::string>(ArgumentType argumentType, std::string value) { |
|||
if (argumentType != ArgumentType::String) { |
|||
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToString: Unable to perform inferToString on a non-string template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!"); |
|||
throw storm::exceptions::InternalTypeErrorException() << "Unable to perform inferToString on a non-string template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!"; |
|||
} |
|||
return value; |
|||
} |
|||
|
|||
/* |
|||
* All functions related to the conversion to int_fast64_t based on the Template and Enum Type |
|||
*/ |
|||
template <typename T> |
|||
int_fast64_t ArgumentTypeInferation::inferToInteger(ArgumentType argumentType, T value) { |
|||
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToInteger: Unable to perform inferToInteger on a non-int_fast64_t template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."); |
|||
throw storm::exceptions::InternalTypeErrorException() << "Unable to perform inferToInteger on a non-int_fast64_t template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."; |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
template <> inline int_fast64_t ArgumentTypeInferation::inferToInteger<int_fast64_t>(ArgumentType argumentType, int_fast64_t value) { |
|||
if (argumentType != ArgumentType::Integer) { |
|||
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToInteger: Unable to perform inferToInteger on a non-int_fast64_t template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!"); |
|||
throw storm::exceptions::InternalTypeErrorException() << "Unable to perform inferToInteger on a non-int_fast64_t template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!"; |
|||
} |
|||
return value; |
|||
} |
|||
|
|||
/* |
|||
* All functions related to the conversion to uint_fast64_t based on the Template and Enum Type |
|||
*/ |
|||
template <typename T> |
|||
uint_fast64_t ArgumentTypeInferation::inferToUnsignedInteger(ArgumentType argumentType, T value) { |
|||
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToUnsignedInteger: Unable to perform inferToUnsignedInteger on a non-uint_fast64_t template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."); |
|||
throw storm::exceptions::InternalTypeErrorException() << "Unable to perform inferToUnsignedInteger on a non-uint_fast64_t template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."; |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
template <> inline uint_fast64_t ArgumentTypeInferation::inferToUnsignedInteger<uint_fast64_t>(ArgumentType argumentType, uint_fast64_t value) { |
|||
if (argumentType != ArgumentType::UnsignedInteger) { |
|||
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToUnsignedInteger: Unable to perform inferToUnsignedInteger on a non-uint_fast64_t template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."); |
|||
throw storm::exceptions::InternalTypeErrorException() << "Unable to perform inferToUnsignedInteger on a non-uint_fast64_t template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."; |
|||
} |
|||
return value; |
|||
} |
|||
|
|||
/* |
|||
* All functions related to the conversion to double based on the Template and Enum Type |
|||
*/ |
|||
template <typename T> |
|||
double ArgumentTypeInferation::inferToDouble(ArgumentType argumentType, T value) { |
|||
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToDouble: Unable to perform inferToDouble on a non-double template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."); |
|||
throw storm::exceptions::InternalTypeErrorException() << "Unable to perform inferToDouble on a non-double template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."; |
|||
|
|||
return 0.0; |
|||
} |
|||
|
|||
template <> inline double ArgumentTypeInferation::inferToDouble<double>(ArgumentType argumentType, double value) { |
|||
if (argumentType != ArgumentType::Double) { |
|||
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToDouble: Unable to perform inferToDouble on a double template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."); |
|||
throw storm::exceptions::InternalTypeErrorException() << "Unable to perform inferToDouble on a double template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."; |
|||
} |
|||
return value; |
|||
} |
|||
|
|||
/* |
|||
* All functions related to the conversion to bool based on the Template and Enum Type |
|||
*/ |
|||
template <typename T> |
|||
bool ArgumentTypeInferation::inferToBoolean(ArgumentType argumentType, T value) { |
|||
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToBoolean: Unable to perform inferToBoolean on a non-bool template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."); |
|||
throw storm::exceptions::InternalTypeErrorException() << "Unable to perform inferToBoolean on a non-bool template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."; |
|||
|
|||
return false; |
|||
} |
|||
|
|||
template <> inline bool ArgumentTypeInferation::inferToBoolean<bool>(ArgumentType argumentType, bool value) { |
|||
if (argumentType != ArgumentType::Boolean) { |
|||
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToBoolean: Unable to perform inferToBoolean on a non-bool template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."); |
|||
throw storm::exceptions::InternalTypeErrorException() << "Unable to perform inferToBoolean on a non-bool template object to cast to " << ArgumentTypeHelper::toString(argumentType) << "."; |
|||
} |
|||
return value; |
|||
} |
|||
} |
|||
} |
|||
} // namespace settings |
|||
} // namespace storm |
|||
|
|||
#endif // STORM_SETTINGS_ARGUMENTTYPEINFERATIONHELPER_H_ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue