Browse Source

Added logging to all Settings classes

Removed unnecessary instance variables in the Settings.h


Former-commit-id: 9a0261e82b
main
PBerger 12 years ago
parent
commit
a30f570c2a
  1. 59
      src/settings/Argument.h
  2. 6
      src/settings/ArgumentBase.h
  3. 32
      src/settings/ArgumentBuilder.h
  4. 10
      src/settings/ArgumentType.h
  5. 37
      src/settings/ArgumentTypeInferationHelper.h
  6. 62
      src/settings/Option.h
  7. 24
      src/settings/OptionBuilder.h
  8. 28
      src/settings/Settings.cpp
  9. 44
      src/settings/Settings.h
  10. 2
      src/utility/ErrorHandling.h

59
src/settings/Argument.h

@ -19,6 +19,10 @@
#include "src/exceptions/IllegalArgumentValueException.h" #include "src/exceptions/IllegalArgumentValueException.h"
#include "src/exceptions/IllegalFunctionCallException.h" #include "src/exceptions/IllegalFunctionCallException.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
extern log4cplus::Logger logger;
namespace storm { namespace storm {
namespace settings { namespace settings {
@ -41,7 +45,8 @@ namespace storm {
Argument(std::string const& argumentName, std::string const& argumentDescription, std::vector<userValidationFunction_t> const& validationFunctions, bool isOptional): ArgumentBase(argumentName, argumentDescription, isOptional), argumentType(ArgumentTypeInferation::inferToEnumType<T>()), userValidationFunction(validationFunctions), hasDefaultValue(false) { Argument(std::string const& argumentName, std::string const& argumentDescription, std::vector<userValidationFunction_t> const& validationFunctions, bool isOptional): ArgumentBase(argumentName, argumentDescription, isOptional), argumentType(ArgumentTypeInferation::inferToEnumType<T>()), userValidationFunction(validationFunctions), hasDefaultValue(false) {
if (isOptional) { if (isOptional) {
throw storm::exceptions::IllegalArgumentException() << "Error: The Argument \"" << argumentName << "\" is flaged as optional but no default value was given!";
LOG4CPLUS_ERROR(logger, "Argument::Argument: The Argument \"" << argumentName << "\" is flaged as optional but no default value was given!");
throw storm::exceptions::IllegalArgumentException() << "The Argument \"" << argumentName << "\" is flaged as optional but no default value was given!";
} }
} }
@ -57,7 +62,7 @@ namespace storm {
} }
virtual ~Argument() { virtual ~Argument() {
std::cout << "Destructing an Argument: " << this->getArgumentName() << " of Type " << ArgumentTypeHelper::toString(this->getArgumentType()) << std::endl;
//LOG4CPLUS_DEBUG(logger, "Argument::~Argument: Destructing Argument \"" << this->getArgumentName() << "\" of Type " << ArgumentTypeHelper::toString(this->getArgumentType()));
this->userValidationFunction.clear(); this->userValidationFunction.clear();
this->argumentType = ArgumentType::Invalid; this->argumentType = ArgumentType::Invalid;
@ -97,26 +102,26 @@ namespace storm {
template <typename S> template <typename S>
void unify(Argument<S> &rhs) { void unify(Argument<S> &rhs) {
if (this->getArgumentType() != rhs.getArgumentType()) { if (this->getArgumentType() != rhs.getArgumentType()) {
// LOG
throw storm::exceptions::ArgumentUnificationException() << "Error while unifying Argument \"" << this->getArgumentName() << "\" and Argument \"" << rhs.getArgumentName() << "\": Type Missmatch: \"" << ArgumentTypeHelper::toString(this->getArgumentType()) << "\" against \"" << ArgumentTypeHelper::toString(rhs.getArgumentType()) << "\"";
LOG4CPLUS_ERROR(logger, "Argument::unify: While unifying Argument \"" << this->getArgumentName() << "\" and Argument \"" << rhs.getArgumentName() << "\": Type Missmatch: \"" << ArgumentTypeHelper::toString(this->getArgumentType()) << "\" against \"" << ArgumentTypeHelper::toString(rhs.getArgumentType()) << "\"");
throw storm::exceptions::ArgumentUnificationException() << "While unifying Argument \"" << this->getArgumentName() << "\" and Argument \"" << rhs.getArgumentName() << "\": Type Missmatch: \"" << ArgumentTypeHelper::toString(this->getArgumentType()) << "\" against \"" << ArgumentTypeHelper::toString(rhs.getArgumentType()) << "\"";
} }
if (this->getIsOptional() != rhs.getIsOptional()) { if (this->getIsOptional() != rhs.getIsOptional()) {
// LOG
throw storm::exceptions::ArgumentUnificationException() << "Error while unifying Argument \"" << this->getArgumentName() << "\" and Argument \"" << rhs.getArgumentName() << "\": IsOptional Missmatch!";
LOG4CPLUS_ERROR(logger, "Argument::unify: While unifying Argument \"" << this->getArgumentName() << "\" and Argument \"" << rhs.getArgumentName() << "\": IsOptional Missmatch!");
throw storm::exceptions::ArgumentUnificationException() << "While unifying Argument \"" << this->getArgumentName() << "\" and Argument \"" << rhs.getArgumentName() << "\": IsOptional Missmatch!";
} }
if (this->getHasDefaultValue() != rhs.getHasDefaultValue()) { if (this->getHasDefaultValue() != rhs.getHasDefaultValue()) {
// LOG
throw storm::exceptions::ArgumentUnificationException() << "Error while unifying Argument \"" << this->getArgumentName() << "\" and Argument \"" << rhs.getArgumentName() << "\": defaultValue Missmatch!";
LOG4CPLUS_ERROR(logger, "Argument::unify: While unifying Argument \"" << this->getArgumentName() << "\" and Argument \"" << rhs.getArgumentName() << "\": defaultValue Missmatch!");
throw storm::exceptions::ArgumentUnificationException() << "While unifying Argument \"" << this->getArgumentName() << "\" and Argument \"" << rhs.getArgumentName() << "\": defaultValue Missmatch!";
} }
if (this->getArgumentDescription().compare(rhs.getArgumentDescription()) != 0) { if (this->getArgumentDescription().compare(rhs.getArgumentDescription()) != 0) {
// LOG Warning: Descriptions of unified arguments do not match
LOG4CPLUS_WARN(logger, "Argument::unify: While unifying Argument \"" << this->getArgumentName() << "\" and Argument \"" << rhs.getArgumentName() << "\": descriptions Missmatch!");
} }
if (this->getArgumentName().compare(rhs.getArgumentName()) != 0) { if (this->getArgumentName().compare(rhs.getArgumentName()) != 0) {
// LOG Warning: Names of unified arguments do not match
LOG4CPLUS_WARN(logger, "Argument::unify: While unifying Argument \"" << this->getArgumentName() << "\" and Argument \"" << rhs.getArgumentName() << "\": ArgumentName Missmatch!");
} }
// Add Validation functions // Add Validation functions
@ -128,8 +133,8 @@ namespace storm {
T getArgumentValue() const { T getArgumentValue() const {
if (!this->getHasBeenSet()) { if (!this->getHasBeenSet()) {
// LOG
throw storm::exceptions::IllegalFunctionCallException() << "Error: Called getArgumentValue() on Argument \"" << this->getArgumentName() << "\", but it was never set and does not contain a default value.";
LOG4CPLUS_ERROR(logger, "Argument::getArgumentValue: Called getArgumentValue() on Argument \"" << this->getArgumentName() << "\", but it was never set and does not contain a default value.");
throw storm::exceptions::IllegalFunctionCallException() << "Called getArgumentValue() on Argument \"" << this->getArgumentName() << "\", but it was never set and does not contain a default value.";
} }
return this->argumentValue; return this->argumentValue;
} }
@ -144,12 +149,14 @@ namespace storm {
void setFromDefaultValue() override { void setFromDefaultValue() override {
if (!this->hasDefaultValue) { if (!this->hasDefaultValue) {
throw storm::exceptions::IllegalFunctionCallException() << "Error: The Argument \"" << this->getArgumentName() << "\" (" << this->getArgumentDescription() << ") was asked to set its default value but none was set!";
LOG4CPLUS_ERROR(logger, "Argument::setFromDefaultValue: The Argument \"" << this->getArgumentName() << "\" (" << this->getArgumentDescription() << ") was asked to set its default value but none was set!");
throw storm::exceptions::IllegalFunctionCallException() << "The Argument \"" << this->getArgumentName() << "\" (" << this->getArgumentDescription() << ") was asked to set its default value but none was set!";
} }
// this call also sets the hasBeenSet flag // this call also sets the hasBeenSet flag
assignmentResult_t result = this->fromTypeValue(this->defaultValue); assignmentResult_t result = this->fromTypeValue(this->defaultValue);
if (!result.first) { if (!result.first) {
throw storm::exceptions::IllegalArgumentValueException() << "Error: While parsing a given configuration the Argument \"" << this->getArgumentName() << "\" (" << this->getArgumentDescription() << ") could not receive its Default Value as it was rejected by its Validation Functions with message: " << result.second;
LOG4CPLUS_ERROR(logger, "Argument::setFromDefaultValue: While parsing a given configuration the Argument \"" << this->getArgumentName() << "\" (" << this->getArgumentDescription() << ") could not receive its Default Value as it was rejected by its Validation Functions with message: " << result.second);
throw storm::exceptions::IllegalArgumentValueException() << "While parsing a given configuration the Argument \"" << this->getArgumentName() << "\" (" << this->getArgumentDescription() << ") could not receive its Default Value as it was rejected by its Validation Functions with message: " << result.second;
} }
} }
@ -176,9 +183,10 @@ namespace storm {
switch (this->argumentType) { switch (this->argumentType) {
case ArgumentType::Integer: case ArgumentType::Integer:
return ArgumentTypeInferation::inferToInteger(ArgumentType::Integer, this->getArgumentValue()); return ArgumentTypeInferation::inferToInteger(ArgumentType::Integer, this->getArgumentValue());
default:
throw storm::exceptions::IllegalFunctionCallException() << "Error: getValueAsInteger() was called on Argument \"" << getArgumentName() << "\" of Type \"" << ArgumentTypeHelper::toString(getArgumentType()) << "\"!";
default: {
LOG4CPLUS_ERROR(logger, "Argument::getValueAsInteger() was called on Argument \"" << getArgumentName() << "\" of Type \"" << ArgumentTypeHelper::toString(getArgumentType()) << "\"!");
throw storm::exceptions::IllegalFunctionCallException() << "getValueAsInteger() was called on Argument \"" << getArgumentName() << "\" of Type \"" << ArgumentTypeHelper::toString(getArgumentType()) << "\"!";
}
} }
} }
@ -186,9 +194,10 @@ namespace storm {
switch (this->argumentType) { switch (this->argumentType) {
case ArgumentType::UnsignedInteger: case ArgumentType::UnsignedInteger:
return ArgumentTypeInferation::inferToUnsignedInteger(ArgumentType::UnsignedInteger, this->getArgumentValue()); return ArgumentTypeInferation::inferToUnsignedInteger(ArgumentType::UnsignedInteger, this->getArgumentValue());
default:
default: {
LOG4CPLUS_ERROR(logger, "Argument::getValueAsUnsignedInteger() was called on Argument \"" << getArgumentName() << "\" of Type \"" << ArgumentTypeHelper::toString(getArgumentType()) << "\"!");
throw storm::exceptions::IllegalFunctionCallException() << "Error: getValueAsUnsignedInteger() was called on Argument \"" << getArgumentName() << "\" of Type \"" << ArgumentTypeHelper::toString(getArgumentType()) << "\"!"; throw storm::exceptions::IllegalFunctionCallException() << "Error: getValueAsUnsignedInteger() was called on Argument \"" << getArgumentName() << "\" of Type \"" << ArgumentTypeHelper::toString(getArgumentType()) << "\"!";
}
} }
} }
@ -196,9 +205,10 @@ namespace storm {
switch (this->argumentType) { switch (this->argumentType) {
case ArgumentType::Double: case ArgumentType::Double:
return ArgumentTypeInferation::inferToDouble(ArgumentType::Double, this->getArgumentValue()); return ArgumentTypeInferation::inferToDouble(ArgumentType::Double, this->getArgumentValue());
default:
default: {
LOG4CPLUS_ERROR(logger, "Argument::getValueAsDouble() was called on Argument \"" << getArgumentName() << "\" of Type \"" << ArgumentTypeHelper::toString(getArgumentType()) << "\"!");
throw storm::exceptions::IllegalFunctionCallException() << "Error: getValueAsDouble() was called on Argument \"" << getArgumentName() << "\" of Type \"" << ArgumentTypeHelper::toString(getArgumentType()) << "\"!"; throw storm::exceptions::IllegalFunctionCallException() << "Error: getValueAsDouble() was called on Argument \"" << getArgumentName() << "\" of Type \"" << ArgumentTypeHelper::toString(getArgumentType()) << "\"!";
}
} }
} }
@ -206,9 +216,10 @@ namespace storm {
switch (this->argumentType) { switch (this->argumentType) {
case ArgumentType::Boolean: case ArgumentType::Boolean:
return ArgumentTypeInferation::inferToBoolean(ArgumentType::Boolean, this->getArgumentValue()); return ArgumentTypeInferation::inferToBoolean(ArgumentType::Boolean, this->getArgumentValue());
default:
default: {
LOG4CPLUS_ERROR(logger, "Argument::getValueAsBoolean() was called on Argument \"" << getArgumentName() << "\" of Type \"" << ArgumentTypeHelper::toString(getArgumentType()) << "\"!");
throw storm::exceptions::IllegalFunctionCallException() << "Error: getValueAsBoolean() was called on Argument \"" << getArgumentName() << "\" of Type \"" << ArgumentTypeHelper::toString(getArgumentType()) << "\"!"; throw storm::exceptions::IllegalFunctionCallException() << "Error: getValueAsBoolean() was called on Argument \"" << getArgumentName() << "\" of Type \"" << ArgumentTypeHelper::toString(getArgumentType()) << "\"!";
}
} }
} }
private: private:
@ -224,7 +235,7 @@ namespace storm {
std::string errorText = ""; std::string errorText = "";
if (!this->validateForEach(newDefault, errorText)) { if (!this->validateForEach(newDefault, errorText)) {
// A user defined Validation Function was given and it rejected the Input. // A user defined Validation Function was given and it rejected the Input.
// LOG
LOG4CPLUS_ERROR(logger, "Argument::setDefaultValue: Illegal Default Value for Argument \"" << this->getArgumentName() << "\".\nThe Validation Function rejected the Value: " << errorText);
throw storm::exceptions::IllegalArgumentValueException() << "Illegal Default Value for Argument \"" << this->getArgumentName() << "\".\nThe Validation Function rejected the Value: " << errorText; throw storm::exceptions::IllegalArgumentValueException() << "Illegal Default Value for Argument \"" << this->getArgumentName() << "\".\nThe Validation Function rejected the Value: " << errorText;
} }
this->defaultValue = newDefault; this->defaultValue = newDefault;

6
src/settings/ArgumentBase.h

@ -7,6 +7,10 @@
#include "ArgumentType.h" #include "ArgumentType.h"
#include "src/utility/StringHelper.h" #include "src/utility/StringHelper.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
extern log4cplus::Logger logger;
namespace storm { namespace storm {
namespace settings { namespace settings {
@ -16,7 +20,7 @@ namespace storm {
public: public:
ArgumentBase(std::string const& argumentName, std::string const& argumentDescription, bool isOptional) : isOptional(isOptional), hasBeenSet(false), argumentName(argumentName), argumentDescription(argumentDescription) {} ArgumentBase(std::string const& argumentName, std::string const& argumentDescription, bool isOptional) : isOptional(isOptional), hasBeenSet(false), argumentName(argumentName), argumentDescription(argumentDescription) {}
virtual ~ArgumentBase() { virtual ~ArgumentBase() {
std::cout << "Destructing an ArgumentBase." << std::endl;
//LOG4CPLUS_DEBUG(logger, "ArgumentBase::~ArgumentBase: Destructing ArgumentBase \"" << this->getArgumentName() << "\"");
} }
virtual ArgumentType getArgumentType() const = 0; virtual ArgumentType getArgumentType() const = 0;

32
src/settings/ArgumentBuilder.h

@ -20,6 +20,10 @@
#include "src/exceptions/IllegalFunctionCallException.h" #include "src/exceptions/IllegalFunctionCallException.h"
#include "src/exceptions/IllegalArgumentTypeException.h" #include "src/exceptions/IllegalArgumentTypeException.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
extern log4cplus::Logger logger;
namespace storm { namespace storm {
namespace settings { namespace settings {
@ -75,12 +79,14 @@ namespace storm {
#define PPCAT(A, B) PPCAT_NX(A, B) #define PPCAT(A, B) PPCAT_NX(A, B)
#define MACROaddValidationFunction(funcName, funcType) ArgumentBuilder& PPCAT(addValidationFunction, funcName) (storm::settings::Argument< funcType >::userValidationFunction_t userValidationFunction) { \ #define MACROaddValidationFunction(funcName, funcType) ArgumentBuilder& PPCAT(addValidationFunction, funcName) (storm::settings::Argument< funcType >::userValidationFunction_t userValidationFunction) { \
if (this->argumentType != ArgumentType::funcName) { \ if (this->argumentType != ArgumentType::funcName) { \
throw storm::exceptions::IllegalFunctionCallException() << "Error: You tried adding a Validation-Function for a \"" << ArgumentTypeHelper::toString(ArgumentType::funcName) << "\" Argument, but this Argument is configured to be of Type \"" << ArgumentTypeHelper::toString(this->argumentType) << "\"."; \
LOG4CPLUS_ERROR(logger, "ArgumentBuilder::addValidationFunction: Tried adding a Validation-Function for a \"" << ArgumentTypeHelper::toString(ArgumentType::funcName) << "\" Argument, but this Argument is configured to be of Type \"" << ArgumentTypeHelper::toString(this->argumentType) << "\"."); \
throw storm::exceptions::IllegalFunctionCallException() << "Tried adding a Validation-Function for a \"" << ArgumentTypeHelper::toString(ArgumentType::funcName) << "\" Argument, but this Argument is configured to be of Type \"" << ArgumentTypeHelper::toString(this->argumentType) << "\"."; \
} \ } \
( PPCAT(this->userValidationFunction_, funcName) ).push_back(userValidationFunction); \ ( PPCAT(this->userValidationFunction_, funcName) ).push_back(userValidationFunction); \
std::string errorMessageTarget = ""; \ std::string errorMessageTarget = ""; \
if (this->hasDefaultValue && !this->validateDefaultForEach(errorMessageTarget)) { \ if (this->hasDefaultValue && !this->validateDefaultForEach(errorMessageTarget)) { \
throw storm::exceptions::IllegalArgumentValueException() << "Error: You tried adding a Validation-Function for an Argument which has a Default Value set which is rejected by this Validation-Function:\r\n" << errorMessageTarget; \
LOG4CPLUS_ERROR(logger, "ArgumentBuilder::addValidationFunction: Tried adding a Validation-Function for an Argument which has a Default Value set which is rejected by this Validation-Function:\r\n" << errorMessageTarget); \
throw storm::exceptions::IllegalArgumentValueException() << "Tried adding a Validation-Function for an Argument which has a Default Value set which is rejected by this Validation-Function:\r\n" << errorMessageTarget; \
} \ } \
return *this; \ return *this; \
} }
@ -94,12 +100,14 @@ namespace storm {
#define MACROsetDefaultValue(funcName, funcType) ArgumentBuilder& PPCAT(setDefaultValue, funcName) (funcType const& defaultValue) { \ #define MACROsetDefaultValue(funcName, funcType) ArgumentBuilder& PPCAT(setDefaultValue, funcName) (funcType const& defaultValue) { \
if (this->argumentType != ArgumentType::funcName) { \ if (this->argumentType != ArgumentType::funcName) { \
throw storm::exceptions::IllegalFunctionCallException() << "Error: You tried adding a default Value for a \"" << ArgumentTypeHelper::toString(ArgumentType::String) << "\" Argument, but the Argument \"" << this->argumentName << "\" is configured to be of Type \"" << ArgumentTypeHelper::toString(this->argumentType) << "\"."; \
LOG4CPLUS_ERROR(logger, "ArgumentBuilder::addValidationFunction: Tried adding a default Value for a \"" << ArgumentTypeHelper::toString(ArgumentType::String) << "\" Argument, but the Argument \"" << this->argumentName << "\" is configured to be of Type \"" << ArgumentTypeHelper::toString(this->argumentType) << "\"."); \
throw storm::exceptions::IllegalFunctionCallException() << "Tried adding a default Value for a \"" << ArgumentTypeHelper::toString(ArgumentType::String) << "\" Argument, but the Argument \"" << this->argumentName << "\" is configured to be of Type \"" << ArgumentTypeHelper::toString(this->argumentType) << "\"."; \
} \ } \
PPCAT(this->defaultValue_, funcName) = defaultValue; \ PPCAT(this->defaultValue_, funcName) = defaultValue; \
std::string errorMessageTarget = ""; \ std::string errorMessageTarget = ""; \
if (!this->validateDefaultForEach(errorMessageTarget)) { \ if (!this->validateDefaultForEach(errorMessageTarget)) { \
throw storm::exceptions::IllegalArgumentValueException() << "Error: You tried adding a default Value for the Argument \"" << this->argumentName << "\", but a Validation Function rejected it:\r\n" << errorMessageTarget; \
LOG4CPLUS_ERROR(logger, "ArgumentBuilder::setDefaultValue: Tried adding a default Value for the Argument \"" << this->argumentName << "\", but a Validation Function rejected it:\r\n" << errorMessageTarget); \
throw storm::exceptions::IllegalArgumentValueException() << "Tried adding a default Value for the Argument \"" << this->argumentName << "\", but a Validation Function rejected it:\r\n" << errorMessageTarget; \
} \ } \
this->hasDefaultValue = true; \ this->hasDefaultValue = true; \
return *this; \ return *this; \
@ -113,8 +121,8 @@ namespace storm {
ArgumentBase* build() { ArgumentBase* build() {
if (this->hasBeenBuild) { if (this->hasBeenBuild) {
// LOG
throw storm::exceptions::IllegalFunctionCallException() << "Error: Called build() on an instance of ArgumentBuilder which has already build an Instance.";
LOG4CPLUS_ERROR(logger, "ArgumentBuilder::build: Called build() on an instance of ArgumentBuilder which has already build an Instance.");
throw storm::exceptions::IllegalFunctionCallException() << "Called build() on an instance of ArgumentBuilder which has already build an Instance.";
} }
this->hasBeenBuild = true; this->hasBeenBuild = true;
switch (this->argumentType) { switch (this->argumentType) {
@ -154,9 +162,10 @@ namespace storm {
return dynamic_cast<ArgumentBase*>(new Argument<bool>(this->argumentName, this->argumentDescription, userValidationFunction_Boolean, this->isOptional)); return dynamic_cast<ArgumentBase*>(new Argument<bool>(this->argumentName, this->argumentDescription, userValidationFunction_Boolean, this->isOptional));
} }
break; break;
default:
// LOG
throw storm::exceptions::InternalTypeErrorException() << "Error: Missing Case in ArgumentBuilder's switch/case Code.";
default: {
LOG4CPLUS_ERROR(logger, "ArgumentBuilder::build: Missing Case in ArgumentBuilder's switch/case Code.");
throw storm::exceptions::InternalTypeErrorException() << "Missing Case in ArgumentBuilder's switch/case Code.";
}
} }
} }
private: private:
@ -242,10 +251,11 @@ namespace storm {
result = result && lambda(this->defaultValue_Boolean, errorMessageTarget); result = result && lambda(this->defaultValue_Boolean, errorMessageTarget);
} }
break; break;
default:
// LOG
default: {
LOG4CPLUS_ERROR(logger, "ArgumentBuilder::build: Missing Case in ArgumentBuilder's switch/case Code.");
throw storm::exceptions::InternalTypeErrorException() << "Error: Missing Case in ArgumentBuilder's switch/case Code."; throw storm::exceptions::InternalTypeErrorException() << "Error: Missing Case in ArgumentBuilder's switch/case Code.";
} }
}
return result; return result;
} }

10
src/settings/ArgumentType.h

@ -3,6 +3,10 @@
#include "src/exceptions/InternalTypeErrorException.h" #include "src/exceptions/InternalTypeErrorException.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
extern log4cplus::Logger logger;
namespace storm { namespace storm {
namespace settings { namespace settings {
enum class ArgumentType { enum class ArgumentType {
@ -38,8 +42,10 @@ namespace storm {
case ArgumentType::Boolean: case ArgumentType::Boolean:
return argumentTypeBoolean; return argumentTypeBoolean;
break; break;
default:
throw storm::exceptions::InternalTypeErrorException() << "ERROR:\n" << "Missing a Switch Case in the ArgumentTypeHelper!\n" << "It seems there is a new ArgumentType, but it was not added to the Helper Class!";
default: {
LOG4CPLUS_ERROR(logger, "ArgumentTypeHelper::toString: Missing Case in ArgumentTypeHelper's switch/case Code.");
throw storm::exceptions::InternalTypeErrorException() << "Missing a Switch Case in the ArgumentTypeHelper!\n" << "It seems there is a new ArgumentType, but it was not added to the Helper Class!";
}
} }
} }
private: private:

37
src/settings/ArgumentTypeInferationHelper.h

@ -15,6 +15,10 @@
#include "ArgumentType.h" #include "ArgumentType.h"
#include "src/exceptions/InternalTypeErrorException.h" #include "src/exceptions/InternalTypeErrorException.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
extern log4cplus::Logger logger;
namespace storm { namespace storm {
namespace settings { namespace settings {
class ArgumentTypeInferation { class ArgumentTypeInferation {
@ -41,7 +45,8 @@ namespace storm {
template <typename T> template <typename T>
ArgumentType ArgumentTypeInferation::inferToEnumType() { ArgumentType ArgumentTypeInferation::inferToEnumType() {
// "Missing Template Specialization Case in ArgumentTypeInferation" // "Missing Template Specialization Case in ArgumentTypeInferation"
throw storm::exceptions::InternalTypeErrorException() << "ERROR:\n" << "Missing a Template Specialization Case in the ArgumentTypeInferationHelper!\n" << "It seems you tried to use a new, non-standard Type as a Settings Parameter-Type!";
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToEnumType: Missing a Template Specialization Case in the ArgumentTypeInferationHelper! It seems you tried to use a new, non-standard Type as a Settings Parameter-Type!");
throw storm::exceptions::InternalTypeErrorException() << "Missing a Template Specialization Case in the ArgumentTypeInferationHelper!\n" << "It seems you tried to use a new, non-standard Type as a Settings Parameter-Type!";
return ArgumentType::Invalid; return ArgumentType::Invalid;
} }
@ -67,14 +72,16 @@ namespace storm {
*/ */
template <typename T> template <typename T>
std::string ArgumentTypeInferation::inferToString(ArgumentType argumentType, T value) { std::string ArgumentTypeInferation::inferToString(ArgumentType argumentType, T value) {
throw storm::exceptions::InternalTypeErrorException() << "ERROR:\n " << "inferToString was called on a non-string Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToString: inferToString was called on a non-string Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!");
throw storm::exceptions::InternalTypeErrorException() << "inferToString was called on a non-string Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
return std::string(); return std::string();
} }
template <> inline std::string ArgumentTypeInferation::inferToString<std::string>(ArgumentType argumentType, std::string value) { template <> inline std::string ArgumentTypeInferation::inferToString<std::string>(ArgumentType argumentType, std::string value) {
if (argumentType != ArgumentType::String) { if (argumentType != ArgumentType::String) {
throw storm::exceptions::InternalTypeErrorException() << "ERROR:\n " << "inferToString was called on a string Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToString: inferToString was called on a string Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!");
throw storm::exceptions::InternalTypeErrorException() << "inferToString was called on a string Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
} }
return value; return value;
} }
@ -84,14 +91,16 @@ namespace storm {
*/ */
template <typename T> template <typename T>
int_fast64_t ArgumentTypeInferation::inferToInteger(ArgumentType argumentType, T value) { int_fast64_t ArgumentTypeInferation::inferToInteger(ArgumentType argumentType, T value) {
throw storm::exceptions::InternalTypeErrorException() << "ERROR:\n " << "inferToInteger was called on a non-int_fast64_t Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToInteger: inferToInteger was called on a non-int_fast64_t Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!");
throw storm::exceptions::InternalTypeErrorException() << "inferToInteger was called on a non-int_fast64_t Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
return 0; return 0;
} }
template <> inline int_fast64_t ArgumentTypeInferation::inferToInteger<int_fast64_t>(ArgumentType argumentType, int_fast64_t value) { template <> inline int_fast64_t ArgumentTypeInferation::inferToInteger<int_fast64_t>(ArgumentType argumentType, int_fast64_t value) {
if (argumentType != ArgumentType::Integer) { if (argumentType != ArgumentType::Integer) {
throw storm::exceptions::InternalTypeErrorException() << "ERROR:\n " << "inferToInteger was called on an int_fast64_t Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToInteger: inferToInteger was called on a int_fast64_t Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!");
throw storm::exceptions::InternalTypeErrorException() << "inferToInteger was called on an int_fast64_t Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
} }
return value; return value;
} }
@ -101,14 +110,16 @@ namespace storm {
*/ */
template <typename T> template <typename T>
uint_fast64_t ArgumentTypeInferation::inferToUnsignedInteger(ArgumentType argumentType, T value) { uint_fast64_t ArgumentTypeInferation::inferToUnsignedInteger(ArgumentType argumentType, T value) {
throw storm::exceptions::InternalTypeErrorException() << "ERROR:\n " << "inferToUnsignedInteger was called on a non-uint_fast64_t Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToUnsignedInteger: inferToUnsignedInteger was called on a non-uint_fast64_t Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!");
throw storm::exceptions::InternalTypeErrorException() << "inferToUnsignedInteger was called on a non-uint_fast64_t Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
return 0; return 0;
} }
template <> inline uint_fast64_t ArgumentTypeInferation::inferToUnsignedInteger<uint_fast64_t>(ArgumentType argumentType, uint_fast64_t value) { template <> inline uint_fast64_t ArgumentTypeInferation::inferToUnsignedInteger<uint_fast64_t>(ArgumentType argumentType, uint_fast64_t value) {
if (argumentType != ArgumentType::UnsignedInteger) { if (argumentType != ArgumentType::UnsignedInteger) {
throw storm::exceptions::InternalTypeErrorException() << "ERROR:\n " << "inferToUnsignedInteger was called on an uint_fast64_t Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToUnsignedInteger: inferToUnsignedInteger was called on a uint_fast64_t Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!");
throw storm::exceptions::InternalTypeErrorException() << "inferToUnsignedInteger was called on an uint_fast64_t Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
} }
return value; return value;
} }
@ -118,14 +129,16 @@ namespace storm {
*/ */
template <typename T> template <typename T>
double ArgumentTypeInferation::inferToDouble(ArgumentType argumentType, T value) { double ArgumentTypeInferation::inferToDouble(ArgumentType argumentType, T value) {
throw storm::exceptions::InternalTypeErrorException() << "ERROR:\n " << "inferToDouble was called on a non-double Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToDouble: inferToDouble was called on a non-double Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!");
throw storm::exceptions::InternalTypeErrorException() << "inferToDouble was called on a non-double Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
return 0.0; return 0.0;
} }
template <> inline double ArgumentTypeInferation::inferToDouble<double>(ArgumentType argumentType, double value) { template <> inline double ArgumentTypeInferation::inferToDouble<double>(ArgumentType argumentType, double value) {
if (argumentType != ArgumentType::Double) { if (argumentType != ArgumentType::Double) {
throw storm::exceptions::InternalTypeErrorException() << "ERROR:\n " << "inferToDouble was called on a double Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToDouble: inferToDouble was called on a double Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!");
throw storm::exceptions::InternalTypeErrorException() << "inferToDouble was called on a double Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
} }
return value; return value;
} }
@ -135,14 +148,16 @@ namespace storm {
*/ */
template <typename T> template <typename T>
bool ArgumentTypeInferation::inferToBoolean(ArgumentType argumentType, T value) { bool ArgumentTypeInferation::inferToBoolean(ArgumentType argumentType, T value) {
throw storm::exceptions::InternalTypeErrorException() << "ERROR:\n " << "inferToBoolean was called on a non-bool Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToBoolean: inferToBoolean was called on a non-bool Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!");
throw storm::exceptions::InternalTypeErrorException() << "inferToBoolean was called on a non-bool Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
return false; return false;
} }
template <> inline bool ArgumentTypeInferation::inferToBoolean<bool>(ArgumentType argumentType, bool value) { template <> inline bool ArgumentTypeInferation::inferToBoolean<bool>(ArgumentType argumentType, bool value) {
if (argumentType != ArgumentType::Boolean) { if (argumentType != ArgumentType::Boolean) {
throw storm::exceptions::InternalTypeErrorException() << "ERROR:\n " << "inferToBoolean was called on a bool Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
LOG4CPLUS_ERROR(logger, "ArgumentTypeInferation::inferToBoolean: inferToBoolean was called on a bool Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!");
throw storm::exceptions::InternalTypeErrorException() << "inferToBoolean was called on a bool Template Object to cast to " << ArgumentTypeHelper::toString(argumentType) << "!";
} }
return value; return value;
} }

62
src/settings/Option.h

@ -25,6 +25,10 @@
#include "src/exceptions/IllegalArgumentException.h" #include "src/exceptions/IllegalArgumentException.h"
#include "src/exceptions/OptionUnificationException.h" #include "src/exceptions/OptionUnificationException.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
extern log4cplus::Logger logger;
namespace storm { namespace storm {
namespace settings { namespace settings {
@ -34,17 +38,7 @@ namespace storm {
public: public:
friend class storm::settings::Settings; friend class storm::settings::Settings;
/*
std::string longName;
std::string shortName;
std::string description;
std::string moduleName;
bool isRequired;
bool hasBeenSet;
std::vector<std::shared_ptr<ArgumentBase>> arguments;
*/
Option(std::string const& moduleName, std::string const& longOptionName, std::string const& shortOptionName, std::string const& optionDescription, bool isOptionRequired) Option(std::string const& moduleName, std::string const& longOptionName, std::string const& shortOptionName, std::string const& optionDescription, bool isOptionRequired)
: longName(longOptionName), shortName(shortOptionName), description(optionDescription), moduleName(moduleName), isRequired(isOptionRequired), hasBeenSet(false) { : longName(longOptionName), shortName(shortOptionName), description(optionDescription), moduleName(moduleName), isRequired(isOptionRequired), hasBeenSet(false) {
validateFields(); validateFields();
@ -78,7 +72,7 @@ namespace storm {
} }
~Option() { ~Option() {
std::cout << "Destructing an Option." << std::endl;
//std::cout << "Destructing an Option." << std::endl;
this->arguments.clear(); this->arguments.clear();
this->argumentNameMap.clear(); this->argumentNameMap.clear();
@ -90,25 +84,25 @@ namespace storm {
void unify(Option& other) { void unify(Option& other) {
if (this->getLongName().compare(other.getLongName()) != 0) { if (this->getLongName().compare(other.getLongName()) != 0) {
// LOG
throw storm::exceptions::OptionUnificationException() << "Error: Could not unify Option \"" << getLongName() << "\" because the Names are different (\"" << getLongName() << "\" vs. \"" << other.getLongName() << "\")!";
LOG4CPLUS_ERROR(logger, "Option::unify: Could not unify Option \"" << getLongName() << "\" because the Names are different (\"" << getLongName() << "\" vs. \"" << other.getLongName() << "\")!");
throw storm::exceptions::OptionUnificationException() << "Could not unify Option \"" << getLongName() << "\" because the Names are different (\"" << getLongName() << "\" vs. \"" << other.getLongName() << "\")!";
} }
if (this->getShortName().compare(other.getShortName()) != 0) { if (this->getShortName().compare(other.getShortName()) != 0) {
// LOG
throw storm::exceptions::OptionUnificationException() << "Error: Could not unify Option \"" << getLongName() << "\" because the Shortnames are different (\"" << getShortName() << "\" vs. \"" << other.getShortName() << "\")!";
LOG4CPLUS_ERROR(logger, "Option::unify: Could not unify Option \"" << getLongName() << "\" because the Shortnames are different (\"" << getShortName() << "\" vs. \"" << other.getShortName() << "\")!");
throw storm::exceptions::OptionUnificationException() << "Could not unify Option \"" << getLongName() << "\" because the Shortnames are different (\"" << getShortName() << "\" vs. \"" << other.getShortName() << "\")!";
} }
if (this->getArgumentCount() != other.getArgumentCount()) { if (this->getArgumentCount() != other.getArgumentCount()) {
// LOG
throw storm::exceptions::OptionUnificationException() << "Error: Could not unify Option \"" << getLongName() << "\" because the Argument Counts are different!";
LOG4CPLUS_ERROR(logger, "Option::unify: Could not unify Option \"" << getLongName() << "\" because the Argument Counts are different!");
throw storm::exceptions::OptionUnificationException() << "Could not unify Option \"" << getLongName() << "\" because the Argument Counts are different!";
} }
for(auto i = 0; i != this->arguments.size(); i++) { for(auto i = 0; i != this->arguments.size(); i++) {
ArgumentBase* A = this->arguments.at(i).get(); ArgumentBase* A = this->arguments.at(i).get();
ArgumentBase* B = other.arguments.at(i).get(); ArgumentBase* B = other.arguments.at(i).get();
if (A->getArgumentType() != B->getArgumentType()) { if (A->getArgumentType() != B->getArgumentType()) {
// LOG
throw storm::exceptions::OptionUnificationException() << "Error: Could not unify Option \"" << getLongName() << "\" because the Argument Types at Index " << i << " are different!";
LOG4CPLUS_ERROR(logger, "Option::unify: Could not unify Option \"" << getLongName() << "\" because the Argument Types at Index " << i << " are different!");
throw storm::exceptions::OptionUnificationException() << "Could not unify Option \"" << getLongName() << "\" because the Argument Types at Index " << i << " are different!";
} }
switch (A->getArgumentType()) { switch (A->getArgumentType()) {
@ -128,8 +122,8 @@ namespace storm {
static_cast<storm::settings::Argument<bool>*>(A)->unify(*static_cast<storm::settings::Argument<bool>*>(B)); static_cast<storm::settings::Argument<bool>*>(A)->unify(*static_cast<storm::settings::Argument<bool>*>(B));
break; break;
default: default:
// LOG
throw storm::exceptions::InternalTypeErrorException() << "Error: Missing Case in ArgumentBuilder's switch/case Code.";
LOG4CPLUS_ERROR(logger, "Option::unify: Missing Case in ArgumentBuilder's switch/case Code.");
throw storm::exceptions::InternalTypeErrorException() << "Missing Case in ArgumentBuilder's switch/case Code.";
} }
} }
@ -144,8 +138,8 @@ namespace storm {
ArgumentBase& getArgument(uint_fast64_t argumentIndex) const { ArgumentBase& getArgument(uint_fast64_t argumentIndex) const {
if (argumentIndex >= getArgumentCount()) { if (argumentIndex >= getArgumentCount()) {
// LOG
throw storm::exceptions::IllegalArgumentException() << "Error: Option::getArgument(): argumentIndex out of bounds!";
LOG4CPLUS_ERROR(logger, "Option::getArgument: argumentIndex out of bounds!");
throw storm::exceptions::IllegalArgumentException() << "Option::getArgument(): argumentIndex out of bounds!";
} }
return *this->arguments.at(argumentIndex).get(); return *this->arguments.at(argumentIndex).get();
} }
@ -158,7 +152,7 @@ namespace storm {
auto argumentIterator = this->argumentNameMap.find(storm::utility::StringHelper::stringToLower(argumentName)); auto argumentIterator = this->argumentNameMap.find(storm::utility::StringHelper::stringToLower(argumentName));
if (argumentIterator == this->argumentNameMap.end()) { if (argumentIterator == this->argumentNameMap.end()) {
// LOG
LOG4CPLUS_ERROR(logger, "Option::getArgumentByName: The Option \"" << this->getLongName() << "\" does not contain an Argument with Name \"" << argumentName << "\"!");
throw storm::exceptions::IllegalArgumentException() << "The Option \"" << this->getLongName() << "\" does not contain an Argument with Name \"" << argumentName << "\"!"; throw storm::exceptions::IllegalArgumentException() << "The Option \"" << this->getLongName() << "\" does not contain an Argument with Name \"" << argumentName << "\"!";
} }
@ -207,21 +201,25 @@ namespace storm {
void validateFields() const { void validateFields() const {
if (longName.empty()) { if (longName.empty()) {
throw storm::exceptions::IllegalArgumentException() << "Error: Tried constructing an Option with an empty longName field!";
LOG4CPLUS_ERROR(logger, "Option::validateFields: Tried constructing an Option with an empty longName field!");
throw storm::exceptions::IllegalArgumentException() << "Tried constructing an Option with an empty longName field!";
} }
if (moduleName.empty()) { if (moduleName.empty()) {
throw storm::exceptions::IllegalArgumentException() << "Error: Tried constructing an Option with an empty moduleName field!";
LOG4CPLUS_ERROR(logger, "Option::validateFields: Tried constructing an Option with an empty moduleName field!");
throw storm::exceptions::IllegalArgumentException() << "Tried constructing an Option with an empty moduleName field!";
} }
bool longNameContainsNonAlpha = std::find_if(longName.begin(), longName.end(), [](char c) { return !std::isalpha(c); }) != longName.end(); bool longNameContainsNonAlpha = std::find_if(longName.begin(), longName.end(), [](char c) { return !std::isalpha(c); }) != longName.end();
bool shortNameContainsNonAlpha = std::find_if(shortName.begin(), shortName.end(), [](char c) { return !std::isalpha(c); }) != shortName.end(); bool shortNameContainsNonAlpha = std::find_if(shortName.begin(), shortName.end(), [](char c) { return !std::isalpha(c); }) != shortName.end();
if (longNameContainsNonAlpha) { if (longNameContainsNonAlpha) {
throw storm::exceptions::IllegalArgumentException() << "Error: Tried constructing an Option with a longName that contains non-alpha characters!";
LOG4CPLUS_ERROR(logger, "Option::validateFields: Tried constructing an Option with a longName that contains non-alpha characters!");
throw storm::exceptions::IllegalArgumentException() << "Tried constructing an Option with a longName that contains non-alpha characters!";
} }
if (shortNameContainsNonAlpha) { if (shortNameContainsNonAlpha) {
throw storm::exceptions::IllegalArgumentException() << "Error: Tried constructing an Option with a shortName that contains non-alpha characters!";
LOG4CPLUS_ERROR(logger, "Option::validateFields: Tried constructing an Option with a shortName that contains non-alpha characters!");
throw storm::exceptions::IllegalArgumentException() << "Tried constructing an Option with a shortName that contains non-alpha characters!";
} }
} }
@ -236,13 +234,13 @@ namespace storm {
//} //}
if (!isCurrentArgumentOptional && lastEntryWasOptional) { if (!isCurrentArgumentOptional && lastEntryWasOptional) {
// LOG
throw storm::exceptions::IllegalArgumentException() << "Error: The Argument Vector specified for Option \"" << getLongName() << "\" is invalid!\nIt contains a non-optional argument AFTER an optional argument.";
LOG4CPLUS_ERROR(logger, "Option::isArgumentsVectorValid: The Argument Vector specified for Option \"" << getLongName() << "\" is invalid! It contains a non-optional argument AFTER an optional argument.");
throw storm::exceptions::IllegalArgumentException() << "The Argument Vector specified for Option \"" << getLongName() << "\" is invalid! It contains a non-optional argument AFTER an optional argument.";
} }
std::string lowerArgumentName = storm::utility::StringHelper::stringToLower(i->get()->getArgumentName()); std::string lowerArgumentName = storm::utility::StringHelper::stringToLower(i->get()->getArgumentName());
if (argumentNameSet.find(lowerArgumentName) != argumentNameSet.end()) { if (argumentNameSet.find(lowerArgumentName) != argumentNameSet.end()) {
// LOG
throw storm::exceptions::IllegalArgumentException() << "Error: The Argument Vector specified for Option \"" << getLongName() << "\" is invalid!\nIt contains two arguments with the same name.";
LOG4CPLUS_ERROR(logger, "Option::isArgumentsVectorValid: The Argument Vector specified for Option \"" << getLongName() << "\" is invalid!\nIt contains two arguments with the same name.");
throw storm::exceptions::IllegalArgumentException() << "The Argument Vector specified for Option \"" << getLongName() << "\" is invalid!\nIt contains two arguments with the same name.";
} }
argumentNameSet.insert(lowerArgumentName); argumentNameSet.insert(lowerArgumentName);

24
src/settings/OptionBuilder.h

@ -29,9 +29,7 @@ namespace storm {
public: public:
OptionBuilder(std::string const& newOptionModuleName, std::string const& newOptionLongName, std::string const& newOptionShortName, std::string const& newOptionDescription): longName(newOptionLongName), shortName(newOptionShortName), description(newOptionDescription), moduleName(newOptionModuleName), isRequired(false), isBuild(false) {} OptionBuilder(std::string const& newOptionModuleName, std::string const& newOptionLongName, std::string const& newOptionShortName, std::string const& newOptionDescription): longName(newOptionLongName), shortName(newOptionShortName), description(newOptionDescription), moduleName(newOptionModuleName), isRequired(false), isBuild(false) {}
~OptionBuilder() {
std::cout << "Destructing an OptionBuilder." << std::endl;
}
~OptionBuilder() {}
OptionBuilder& setLongName(std::string const& newLongName) { OptionBuilder& setLongName(std::string const& newLongName) {
this->longName = newLongName; this->longName = newLongName;
@ -87,24 +85,24 @@ namespace storm {
// For automatic management of newArgument's lifetime // For automatic management of newArgument's lifetime
std::shared_ptr<ArgumentBase> argumentPtr(newArgument); std::shared_ptr<ArgumentBase> argumentPtr(newArgument);
if (this->isBuild) { if (this->isBuild) {
// LOG
throw storm::exceptions::IllegalFunctionCallException() << "Error: Called addArgument() on an instance of OptionBuilder which has already build an Instance.";
LOG4CPLUS_ERROR(logger, "OptionBuilder::addArgument: Called addArgument() on an instance of OptionBuilder which has already build an Instance.");
throw storm::exceptions::IllegalFunctionCallException() << "Called addArgument() on an instance of OptionBuilder which has already build an Instance.";
} }
if (newArgument->getArgumentType() == ArgumentType::Invalid) { if (newArgument->getArgumentType() == ArgumentType::Invalid) {
// LOG
throw storm::exceptions::InternalTypeErrorException() << "Error: Could not add Argument to Option \"" << getLongName() << "\" because its Type is Invalid!";
LOG4CPLUS_ERROR(logger, "OptionBuilder::addArgument: Could not add Argument to Option \"" << getLongName() << "\" because its Type is Invalid!");
throw storm::exceptions::InternalTypeErrorException() << "Could not add Argument to Option \"" << getLongName() << "\" because its Type is Invalid!";
} }
if (!newArgument->getIsOptional() && (this->arguments.size() > 0) && (this->arguments.at(this->arguments.size() - 1).get()->getIsOptional())) { if (!newArgument->getIsOptional() && (this->arguments.size() > 0) && (this->arguments.at(this->arguments.size() - 1).get()->getIsOptional())) {
// LOG
throw storm::exceptions::IllegalArgumentException() << "Error: Could not add Non-Optional Argument to Option \"" << getLongName() << "\" because it already contains an optional argument! Please note that after an optional argument has been added only arguments which are also optional can be appended.";
LOG4CPLUS_ERROR(logger, "OptionBuilder::addArgument: Could not add Non-Optional Argument to Option \"" << getLongName() << "\" because it already contains an optional argument! Please note that after an optional argument has been added only arguments which are also optional can be appended.");
throw storm::exceptions::IllegalArgumentException() << "Could not add Non-Optional Argument to Option \"" << getLongName() << "\" because it already contains an optional argument! Please note that after an optional argument has been added only arguments which are also optional can be appended.";
} }
std::string lowerArgumentName = storm::utility::StringHelper::stringToLower(newArgument->getArgumentName()); std::string lowerArgumentName = storm::utility::StringHelper::stringToLower(newArgument->getArgumentName());
if (argumentNameSet.find(lowerArgumentName) != argumentNameSet.end()) { if (argumentNameSet.find(lowerArgumentName) != argumentNameSet.end()) {
// LOG
throw storm::exceptions::IllegalArgumentException() << "Error: Could not add Argument with Name \"" << newArgument->getArgumentName() << "\" to Option \"" << getLongName() << "\" because it already contains an argument with the same name! Please note that all argument names must be unique in its respective option.";
LOG4CPLUS_ERROR(logger, "OptionBuilder::addArgument: Could not add Argument with Name \"" << newArgument->getArgumentName() << "\" to Option \"" << getLongName() << "\" because it already contains an argument with the same name! Please note that all argument names must be unique in its respective option.");
throw storm::exceptions::IllegalArgumentException() << "Could not add Argument with Name \"" << newArgument->getArgumentName() << "\" to Option \"" << getLongName() << "\" because it already contains an argument with the same name! Please note that all argument names must be unique in its respective option.";
} }
argumentNameSet.insert(lowerArgumentName); argumentNameSet.insert(lowerArgumentName);
@ -115,8 +113,8 @@ namespace storm {
Option* build() { Option* build() {
if (this->isBuild) { if (this->isBuild) {
// LOG
throw storm::exceptions::IllegalFunctionCallException() << "Error: Called build() on an instance of OptionBuilder which has already build an Instance.";
LOG4CPLUS_ERROR(logger, "OptionBuilder::addArgument: Called build() on an instance of OptionBuilder which has already build an Instance.");
throw storm::exceptions::IllegalFunctionCallException() << "Called build() on an instance of OptionBuilder which has already build an Instance.";
} }
this->isBuild = true; this->isBuild = true;

28
src/settings/Settings.cpp

@ -7,7 +7,6 @@
#include "src/exceptions/OptionParserException.h" #include "src/exceptions/OptionParserException.h"
// Static Inits // Static Inits
storm::settings::Settings* storm::settings::Settings::instance = nullptr;
storm::settings::Destroyer storm::settings::Settings::destroyer; storm::settings::Destroyer storm::settings::Settings::destroyer;
/*! /*!
@ -52,6 +51,7 @@ void storm::settings::Settings::handleAssignment(std::string const& longOptionNa
uint_fast64_t givenArgsCount = arguments.size(); uint_fast64_t givenArgsCount = arguments.size();
if (givenArgsCount > option->getArgumentCount()) { if (givenArgsCount > option->getArgumentCount()) {
LOG4CPLUS_ERROR(logger, "Settings::handleAssignment: Could not parse Arguments for Option \"" << longOptionName << "\": " << arguments.size() << " Arguments given, but max. " << option->getArgumentCount() << " Arguments expected.");
throw storm::exceptions::OptionParserException() << "Could not parse Arguments for Option \"" << longOptionName << "\": " << arguments.size() << " Arguments given, but max. " << option->getArgumentCount() << " Arguments expected."; throw storm::exceptions::OptionParserException() << "Could not parse Arguments for Option \"" << longOptionName << "\": " << arguments.size() << " Arguments given, but max. " << option->getArgumentCount() << " Arguments expected.";
} }
@ -59,13 +59,13 @@ void storm::settings::Settings::handleAssignment(std::string const& longOptionNa
if (i < givenArgsCount) { if (i < givenArgsCount) {
storm::settings::fromStringAssignmentResult_t assignmentResult = option->getArgument(i).fromStringValue(arguments.at(i)); storm::settings::fromStringAssignmentResult_t assignmentResult = option->getArgument(i).fromStringValue(arguments.at(i));
if (!assignmentResult.first) { if (!assignmentResult.first) {
// LOG
LOG4CPLUS_ERROR(logger, "Settings::handleAssignment: Could not parse Arguments for Option \"" << longOptionName << "\": Argument " << option->getArgument(i).getArgumentName() << " rejected the given Value \"" << arguments.at(i) << "\" with Message:\r\n" << assignmentResult.second);
throw storm::exceptions::OptionParserException() << "Could not parse Arguments for Option \"" << longOptionName << "\": Argument " << option->getArgument(i).getArgumentName() << " rejected the given Value \"" << arguments.at(i) << "\" with Message:\r\n" << assignmentResult.second; throw storm::exceptions::OptionParserException() << "Could not parse Arguments for Option \"" << longOptionName << "\": Argument " << option->getArgument(i).getArgumentName() << " rejected the given Value \"" << arguments.at(i) << "\" with Message:\r\n" << assignmentResult.second;
} }
} else { } else {
// There is no given value for this argument, only optional // There is no given value for this argument, only optional
if (!option->getArgument(i).getIsOptional()) { if (!option->getArgument(i).getIsOptional()) {
// LOG
LOG4CPLUS_ERROR(logger, "Settings::handleAssignment: Could not parse Arguments for Option \"" << longOptionName << "\": " << arguments.size() << " Arguments given, but more Arguments were expected.");
throw storm::exceptions::OptionParserException() << "Could not parse Arguments for Option \"" << longOptionName << "\": " << arguments.size() << " Arguments given, but more Arguments were expected."; throw storm::exceptions::OptionParserException() << "Could not parse Arguments for Option \"" << longOptionName << "\": " << arguments.size() << " Arguments given, but more Arguments were expected.";
} else { } else {
option->getArgument(i).setFromDefaultValue(); option->getArgument(i).setFromDefaultValue();
@ -110,7 +110,7 @@ std::vector<bool> storm::settings::Settings::scanForOptions(std::vector<std::str
} }
void storm::settings::Settings::parseCommandLine(int const argc, char const * const argv[]) { void storm::settings::Settings::parseCommandLine(int const argc, char const * const argv[]) {
std::cout << "Parsing " << argc << " arguments." << std::endl;
LOG4CPLUS_DEBUG(logger, "Settings::parseCommandLine: Parsing " << argc << " arguments.");
std::vector<std::string> stringArgv = argvToStringArray(argc, argv); std::vector<std::string> stringArgv = argvToStringArray(argc, argv);
std::vector<bool> optionPositions = scanForOptions(stringArgv); std::vector<bool> optionPositions = scanForOptions(stringArgv);
@ -136,7 +136,7 @@ void storm::settings::Settings::parseCommandLine(int const argc, char const * co
// Short Option // Short Option
std::string nextShortOptionName = storm::utility::StringHelper::stringToLower(nextOption.substr(1, nextOption.size() - 1)); std::string nextShortOptionName = storm::utility::StringHelper::stringToLower(nextOption.substr(1, nextOption.size() - 1));
if (!this->containsShortName(nextShortOptionName)) { if (!this->containsShortName(nextShortOptionName)) {
// LOG
LOG4CPLUS_ERROR(logger, "Settings::parseCommandLine: Found an unknown ShortName for an Option: \"" << nextShortOptionName << "\".");
throw storm::exceptions::OptionParserException() << "Found an unknown ShortName for an Option: \"" << nextShortOptionName << "\"."; throw storm::exceptions::OptionParserException() << "Found an unknown ShortName for an Option: \"" << nextShortOptionName << "\".";
} else { } else {
longOptionName = this->getByShortName(nextShortOptionName).getLongName(); longOptionName = this->getByShortName(nextShortOptionName).getLongName();
@ -146,7 +146,7 @@ void storm::settings::Settings::parseCommandLine(int const argc, char const * co
// Long Option // Long Option
std::string nextLongOptionName = storm::utility::StringHelper::stringToLower(nextOption.substr(2, nextOption.size() - 2)); std::string nextLongOptionName = storm::utility::StringHelper::stringToLower(nextOption.substr(2, nextOption.size() - 2));
if (!this->containsLongName(nextLongOptionName)) { if (!this->containsLongName(nextLongOptionName)) {
// LOG
LOG4CPLUS_ERROR(logger, "Settings::parseCommandLine: Found an unknown LongName for an Option: \"" << nextLongOptionName << "\".");
throw storm::exceptions::OptionParserException() << "Found an unknown LongName for an Option: \"" << nextLongOptionName << "\"."; throw storm::exceptions::OptionParserException() << "Found an unknown LongName for an Option: \"" << nextLongOptionName << "\".";
} else { } else {
longOptionName = this->getByLongName(nextLongOptionName).getLongName(); longOptionName = this->getByLongName(nextLongOptionName).getLongName();
@ -158,7 +158,7 @@ void storm::settings::Settings::parseCommandLine(int const argc, char const * co
argCache.push_back(stringArgv.at(i)); argCache.push_back(stringArgv.at(i));
} else { } else {
// No Option active and this is no option. // No Option active and this is no option.
// LOG
LOG4CPLUS_ERROR(logger, "Settings::parseCommandLine: Found a stray argument while parsing a given configuration: \"" << stringArgv.at(i) << "\" is neither a known Option nor preceeded by an Option.");
throw storm::exceptions::OptionParserException() << "Found a stray argument while parsing a given configuration: \"" << stringArgv.at(i) << "\" is neither a known Option nor preceeded by an Option."; throw storm::exceptions::OptionParserException() << "Found a stray argument while parsing a given configuration: \"" << stringArgv.at(i) << "\" is neither a known Option nor preceeded by an Option.";
} }
} }
@ -166,6 +166,7 @@ void storm::settings::Settings::parseCommandLine(int const argc, char const * co
for (auto it = this->options.cbegin(); it != this->options.cend(); ++it) { for (auto it = this->options.cbegin(); it != this->options.cend(); ++it) {
if (!it->second.get()->getHasOptionBeenSet()) { if (!it->second.get()->getHasOptionBeenSet()) {
if (it->second.get()->getIsRequired()) { if (it->second.get()->getIsRequired()) {
LOG4CPLUS_ERROR(logger, "Settings::parseCommandLine: Option \"" << it->second.get()->getLongName() << "\" is marked as required, but was not set!");
throw storm::exceptions::OptionParserException() << "Option \"" << it->second.get()->getLongName() << "\" is marked as required, but was not set!"; throw storm::exceptions::OptionParserException() << "Option \"" << it->second.get()->getLongName() << "\" is marked as required, but was not set!";
} else { } else {
// Set defaults on optional values // Set defaults on optional values
@ -184,17 +185,22 @@ bool storm::settings::Settings::registerNewModule(ModuleRegistrationFunction_t r
bool result = false; bool result = false;
try { try {
result = registrationFunction(myInstance); result = registrationFunction(myInstance);
//LOG4CPLUS_DEBUG(logger, "Settings::registerNewModule: Successfully executed a registrationFunction");
} catch (storm::exceptions::IllegalArgumentException e) { } catch (storm::exceptions::IllegalArgumentException e) {
//LOG4CPLUS_ERROR(logger, "Settings::registerNewModule: Internal Error while setting up available Options!" << std::endl << "IllegalArgumentException: " << e.what() << ".");
std::cout << "Internal Error while setting up available Options!" << std::endl << "IllegalArgumentException: " << e.what() << "." << std::endl; std::cout << "Internal Error while setting up available Options!" << std::endl << "IllegalArgumentException: " << e.what() << "." << std::endl;
std::cout << std::endl << myInstance->getHelpText();
return false; return false;
} catch (storm::exceptions::IllegalArgumentValueException e) { } catch (storm::exceptions::IllegalArgumentValueException e) {
//LOG4CPLUS_ERROR(logger, "Settings::registerNewModule: Internal Error while setting up available Options!" << std::endl << "IllegalArgumentValueException: " << e.what() << ".");
std::cout << "Internal Error while setting up available Options!" << std::endl << "IllegalArgumentValueException: " << e.what() << "." << std::endl; std::cout << "Internal Error while setting up available Options!" << std::endl << "IllegalArgumentValueException: " << e.what() << "." << std::endl;
std::cout << std::endl << myInstance->getHelpText();
return false; return false;
} catch (storm::exceptions::IllegalFunctionCallException e) { } catch (storm::exceptions::IllegalFunctionCallException e) {
//LOG4CPLUS_ERROR(logger, "Settings::registerNewModule: Internal Error while setting up available Options!" << std::endl << "IllegalFunctionCallException: " << e.what() << ".");
std::cout << "Internal Error while setting up available Options!" << std::endl << "IllegalFunctionCallException: " << e.what() << "." << std::endl; std::cout << "Internal Error while setting up available Options!" << std::endl << "IllegalFunctionCallException: " << e.what() << "." << std::endl;
std::cout << std::endl << myInstance->getHelpText();
return false;
} catch (std::exception e) {
//LOG4CPLUS_ERROR(logger, "Settings::registerNewModule: Internal Error while setting up available Options!" << std::endl << "std::exception: " << e.what() << ".");
std::cout << "Internal Error while setting up available Options!" << std::endl << "std::exception: " << e.what() << "." << std::endl;
return false; return false;
} }
return result; return result;
@ -222,7 +228,7 @@ storm::settings::Settings& storm::settings::Settings::addOption(Option* option)
// Not found // Not found
if (!(shortNameIterator == this->shortNames.end())) { if (!(shortNameIterator == this->shortNames.end())) {
// There exists an option which uses the same shortname // There exists an option which uses the same shortname
// LOG
//LOG4CPLUS_ERROR(logger, "Settings::addOption: Error: The Option \"" << shortNameIterator->second << "\" from Module \"" << this->options.find(shortNameIterator->second)->second.get()->getModuleName() << "\" uses the same ShortName as the Option \"" << option->getLongName() << "\" from Module \"" << option->getModuleName() << "\"!");
throw storm::exceptions::OptionUnificationException() << "Error: The Option \"" << shortNameIterator->second << "\" from Module \"" << this->options.find(shortNameIterator->second)->second.get()->getModuleName() << "\" uses the same ShortName as the Option \"" << option->getLongName() << "\" from Module \"" << option->getModuleName() << "\"!"; throw storm::exceptions::OptionUnificationException() << "Error: The Option \"" << shortNameIterator->second << "\" from Module \"" << this->options.find(shortNameIterator->second)->second.get()->getModuleName() << "\" uses the same ShortName as the Option \"" << option->getLongName() << "\" from Module \"" << option->getModuleName() << "\"!";
} }

44
src/settings/Settings.h

@ -22,12 +22,15 @@
// Exceptions that should be catched when performing a parsing run // Exceptions that should be catched when performing a parsing run
#include "src/exceptions/OptionParserException.h" #include "src/exceptions/OptionParserException.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
extern log4cplus::Logger logger;
namespace storm { namespace storm {
/*! /*!
* @brief Contains Settings class and associated methods. * @brief Contains Settings class and associated methods.
*
* The settings namespace contains the Settings class some friend methods like instance().
*/ */
namespace settings { namespace settings {
class Settings; class Settings;
@ -60,6 +63,9 @@ namespace settings {
class Settings { class Settings {
public: public:
/*!
* This function handles the static initialization registration of modules and their options
*/
static bool registerNewModule(ModuleRegistrationFunction_t registrationFunction); static bool registerNewModule(ModuleRegistrationFunction_t registrationFunction);
/*! /*!
@ -131,12 +137,16 @@ namespace settings {
return this->getByLongName(longName).setHasOptionBeenSet(); return this->getByLongName(longName).setHasOptionBeenSet();
} }
/*
/*!
* This generated a list of all registered options and their arguments together with descriptions and defaults. * This generated a list of all registered options and their arguments together with descriptions and defaults.
* @return A std::string containing the help text, delimited by \n * @return A std::string containing the help text, delimited by \n
*/ */
std::string getHelpText() const; std::string getHelpText() const;
/*!
* This function is the Singleton interface for the Settings class
* @return Settings* A Pointer to the singleton instance of Settings
*/
static Settings* getInstance(); static Settings* getInstance();
friend class Destroyer; friend class Destroyer;
private: private:
@ -158,9 +168,14 @@ namespace settings {
* The object is automatically destroyed when the program terminates by the destroyer. * The object is automatically destroyed when the program terminates by the destroyer.
*/ */
virtual ~Settings() { virtual ~Settings() {
this->instance = nullptr;
//
} }
/*!
* Parser for the commdand line parameters of the program.
* The first entry of argv will be ignored, as it represents the program name.
* @throws OptionParserException
*/
void parseCommandLine(int const argc, char const * const argv[]); void parseCommandLine(int const argc, char const * const argv[]);
/*! /*!
@ -178,11 +193,6 @@ namespace settings {
*/ */
std::unordered_map<std::string, std::string> shortNames; std::unordered_map<std::string, std::string> shortNames;
/*!
* @brief actual instance of this class.
*/
static Settings* instance;
/*! /*!
* @brief Destroyer object. * @brief Destroyer object.
*/ */
@ -197,14 +207,16 @@ namespace settings {
bool checkArgumentSyntaxForOption(std::string const& argvString); bool checkArgumentSyntaxForOption(std::string const& argvString);
/*! /*!
* Returns true IFF this accumulator contains an option with the specified longName.
* Returns true IFF this contains an option with the specified longName.
* @return bool true iff there is an option with the specified longName
*/ */
bool containsLongName(std::string const& longName) const { bool containsLongName(std::string const& longName) const {
return (this->options.find(storm::utility::StringHelper::stringToLower(longName)) != this->options.end()); return (this->options.find(storm::utility::StringHelper::stringToLower(longName)) != this->options.end());
} }
/*! /*!
* Returns true IFF this accumulator contains an option with the specified shortName.
* Returns true IFF this contains an option with the specified shortName.
* @return bool true iff there is an option with the specified shortName
*/ */
bool containsShortName(std::string const& shortName) const { bool containsShortName(std::string const& shortName) const {
return (this->shortNames.find(storm::utility::StringHelper::stringToLower(shortName)) != this->shortNames.end()); return (this->shortNames.find(storm::utility::StringHelper::stringToLower(shortName)) != this->shortNames.end());
@ -213,10 +225,12 @@ namespace settings {
/*! /*!
* Returns a reference to the Option with the specified longName. * Returns a reference to the Option with the specified longName.
* Throws an Exception of Type InvalidArgumentException if there is no such Option. * Throws an Exception of Type InvalidArgumentException if there is no such Option.
* @throws InvalidArgumentException
*/ */
Option& getByLongName(std::string const& longName) const { Option& getByLongName(std::string const& longName) const {
auto longNameIterator = this->options.find(storm::utility::StringHelper::stringToLower(longName)); auto longNameIterator = this->options.find(storm::utility::StringHelper::stringToLower(longName));
if (longNameIterator == this->options.end()) { if (longNameIterator == this->options.end()) {
LOG4CPLUS_ERROR(logger, "Settings::getByLongName: This program does not contain an Option named \"" << longName << "\"!");
throw storm::exceptions::IllegalArgumentException() << "This program does not contain an Option named \"" << longName << "\"!"; throw storm::exceptions::IllegalArgumentException() << "This program does not contain an Option named \"" << longName << "\"!";
} }
return *longNameIterator->second.get(); return *longNameIterator->second.get();
@ -230,6 +244,7 @@ namespace settings {
Option* getPtrByLongName(std::string const& longName) const { Option* getPtrByLongName(std::string const& longName) const {
auto longNameIterator = this->options.find(storm::utility::StringHelper::stringToLower(longName)); auto longNameIterator = this->options.find(storm::utility::StringHelper::stringToLower(longName));
if (longNameIterator == this->options.end()) { if (longNameIterator == this->options.end()) {
LOG4CPLUS_ERROR(logger, "Settings::getPtrByLongName: This program does not contain an Option named \"" << longName << "\"!");
throw storm::exceptions::IllegalArgumentException() << "This program does not contain an Option named \"" << longName << "\"!"; throw storm::exceptions::IllegalArgumentException() << "This program does not contain an Option named \"" << longName << "\"!";
} }
return longNameIterator->second.get(); return longNameIterator->second.get();
@ -238,10 +253,12 @@ namespace settings {
/*! /*!
* Returns a reference to the Option with the specified shortName. * Returns a reference to the Option with the specified shortName.
* Throws an Exception of Type InvalidArgumentException if there is no such Option. * Throws an Exception of Type InvalidArgumentException if there is no such Option.
* @throws InvalidArgumentException
*/ */
Option& getByShortName(std::string const& shortName) const { Option& getByShortName(std::string const& shortName) const {
auto shortNameIterator = this->shortNames.find(storm::utility::StringHelper::stringToLower(shortName)); auto shortNameIterator = this->shortNames.find(storm::utility::StringHelper::stringToLower(shortName));
if (shortNameIterator == this->shortNames.end()) { if (shortNameIterator == this->shortNames.end()) {
LOG4CPLUS_ERROR(logger, "Settings::getByShortName: This program does not contain an Option named \"" << shortName << "\"!");
throw storm::exceptions::IllegalArgumentException() << "This program does not contain an Option with ShortName \"" << shortName << "\"!"; throw storm::exceptions::IllegalArgumentException() << "This program does not contain an Option with ShortName \"" << shortName << "\"!";
} }
return *(this->options.find(shortNameIterator->second)->second.get()); return *(this->options.find(shortNameIterator->second)->second.get());
@ -250,10 +267,12 @@ namespace settings {
/*! /*!
* Returns a pointer to the Option with the specified shortName. * Returns a pointer to the Option with the specified shortName.
* Throws an Exception of Type InvalidArgumentException if there is no such Option. * Throws an Exception of Type InvalidArgumentException if there is no such Option.
* @throws InvalidArgumentException
*/ */
Option* getPtrByShortName(std::string const& shortName) const { Option* getPtrByShortName(std::string const& shortName) const {
auto shortNameIterator = this->shortNames.find(storm::utility::StringHelper::stringToLower(shortName)); auto shortNameIterator = this->shortNames.find(storm::utility::StringHelper::stringToLower(shortName));
if (shortNameIterator == this->shortNames.end()) { if (shortNameIterator == this->shortNames.end()) {
LOG4CPLUS_ERROR(logger, "Settings::getPtrByShortName: This program does not contain an Option named \"" << shortName << "\"!");
throw storm::exceptions::IllegalArgumentException() << "This program does not contain an Option with ShortName \"" << shortName << "\"!"; throw storm::exceptions::IllegalArgumentException() << "This program does not contain an Option with ShortName \"" << shortName << "\"!";
} }
return this->options.find(shortNameIterator->second)->second.get(); return this->options.find(shortNameIterator->second)->second.get();
@ -281,8 +300,7 @@ namespace settings {
*/ */
virtual ~Destroyer() { virtual ~Destroyer() {
if (this->settingsInstance != nullptr) { if (this->settingsInstance != nullptr) {
std::cout << "Destroying Settings Instance..." << std::endl;
this->settingsInstance->instance = nullptr;
//LOG4CPLUS_DEBUG(logger, "Destroyer::~Destroyer: Destroying Settings Instance...");
// The C++11 Method of Singleton deletes its instance on its own // The C++11 Method of Singleton deletes its instance on its own
//delete this->settingsInstance; //delete this->settingsInstance;
this->settingsInstance = nullptr; this->settingsInstance = nullptr;

2
src/utility/ErrorHandling.h

@ -86,10 +86,10 @@ std::string demangle(char const* symbol) {
* @param sig The code of the signal that needs to be handled. * @param sig The code of the signal that needs to be handled.
*/ */
void signalHandler(int sig) { void signalHandler(int sig) {
#define SIZE 128
LOG4CPLUS_FATAL(logger, "The program received signal " << sig << ". The following backtrace shows the status upon reception of the signal."); LOG4CPLUS_FATAL(logger, "The program received signal " << sig << ". The following backtrace shows the status upon reception of the signal.");
#ifndef WINDOWS #ifndef WINDOWS
# define SIZE 128
void *buffer[SIZE]; void *buffer[SIZE];
char **strings; char **strings;
int nptrs; int nptrs;

Loading…
Cancel
Save