/* * Value_vector.hpp * * Created on: Mar 29, 2017 * Author: heber */ #ifndef VALUE_VECTOR_HPP_ #define VALUE_VECTOR_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include "LinearAlgebra/Vector.hpp" #include "Parameters/Value.hpp" /** This class represents a the Vector class specialization of a general value. * * Instead of a Vector we internally store a string. * This allows us to override the default get() behavior and allows us to first * do the parsing of the string into vector components. * */ template <> class Value : public ValueAsString, public ValueInterface { //!> unit test needs to have access to internal values friend class ValueTest; friend class ContinuousValueTest; friend class Parameter; public: Value(); Value(const Validator &_validator); Value(const std::vector &_ValidValues); Value(const range &_ValidRange); virtual ~Value(); // functions for ValueInterface bool isValid(const Vector &_value) const throw(ParameterValidatorException); const Vector & getUnvalidated() const throw(ParameterValueException); const Vector & get() const throw(ParameterValueException); void set(const Vector & _value) throw(ParameterException); bool isSet() const; // string functions for ValueInterface bool isValidAsString(const std::string &_value) const throw(ParameterValidatorException); const std::string getAsString() const throw(ParameterValueException); const std::string getAsStringUnvalidated() const throw(ParameterValueException); void setAsString(const std::string &_value) throw(ParameterException); // comfortable setter Value &operator=(const Vector &_value) { set(_value); return *this; } // comparator bool operator==(const Value &_instance) const throw(ParameterValidatorException); bool operator!=(const Value &_instance) const throw(ParameterValidatorException) { return !((*this)==(_instance)); } const Validator & getValidator() const; Validator & getValidator(); // comfortable validator functions const range & getValidRange() const throw(ParameterValidatorException); void setValidRange(const range &_range) throw(ParameterValueException); void appendValidValue(const Vector &_value) throw(ParameterValidatorException); const std::vector &getValidValues() const throw(ParameterValidatorException); static const Vector parseAsVector(const std::string &_value); static const std::string setFromVector(const Vector &_vec); private: //!> whether a value has been set or not bool ValueSet; //!> contained value std::string value; //!> converted value for allowing to return a ref mutable Vector converted_value; //!> the validator Validator *validator; }; #endif /* VALUE_VECTOR_HPP_ */