/* * Value.hpp * * Created on: Apr 13, 2012 * Author: ankele */ #ifndef VALUE_HPP_ #define VALUE_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include "ValueInterface.hpp" #include "Validators/Validator.hpp" #include "CodePatterns/Range.hpp" #include "CodePatterns/toString.hpp" class ValueTest; /** This class represents a general value. * */ template class Value : virtual public ValueInterface { //!> unit test needs to have access to internal values friend class ValueTest; public: Value(); Value(const Validator &_validator); Value(const std::vector &_ValidValues); Value(const range &_ValidRange); virtual ~Value(); // functions for ValueInterface bool isValid(const T &_value) const; const T & get() const; void set(const T & _value); // string functions for ValueInterface bool isValidAsString(const std::string _value) const; const std::string getAsString() const; void setAsString(const std::string _value); // comfortable setter void operator=(const T &_value) { set(_value); } // comparator bool operator==(const Value &_instance) const; bool operator!=(const Value &_instance) const { return !((*this)==(_instance)); } const Validator & getValidator() const; Validator & getValidator(); private: //!> Internal converter from string to internal type static ConvertTo Converter; //!> whether a value has been set or not bool ValueSet; //!> contained value T value; //!> the validator Validator *validator; }; #include "Value_impl.hpp" #endif /* VALUE_HPP_ */