| 1 | /*
|
|---|
| 2 | * ContinuousValue.hpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Sep 28, 2011
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #ifndef CONTINUOUSVALUE_HPP_
|
|---|
| 9 | #define CONTINUOUSVALUE_HPP_
|
|---|
| 10 |
|
|---|
| 11 | // include config.h
|
|---|
| 12 | #ifdef HAVE_CONFIG_H
|
|---|
| 13 | #include <config.h>
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | #include <string>
|
|---|
| 17 |
|
|---|
| 18 | #include "CodePatterns/Range.hpp"
|
|---|
| 19 | #include "CodePatterns/toString.hpp"
|
|---|
| 20 |
|
|---|
| 21 | #include "ValueInterface.hpp"
|
|---|
| 22 |
|
|---|
| 23 | class ContinuousValueTest;
|
|---|
| 24 |
|
|---|
| 25 | /** This class represents a discrete value, it implements ValueInterface.
|
|---|
| 26 | *
|
|---|
| 27 | */
|
|---|
| 28 | template <class T>
|
|---|
| 29 | class ContinuousValue : virtual public ParserValueInterface
|
|---|
| 30 | {
|
|---|
| 31 | //!> unit test needs to have access to internal values
|
|---|
| 32 | friend class ContinuousValueTest;
|
|---|
| 33 | public:
|
|---|
| 34 | ContinuousValue();
|
|---|
| 35 | ContinuousValue(const range<T> &_ValidRange);
|
|---|
| 36 | virtual ~ContinuousValue();
|
|---|
| 37 |
|
|---|
| 38 | // functions for ValueInterface
|
|---|
| 39 | bool isValid(const std::string _value) const;
|
|---|
| 40 | const std::string get() const;
|
|---|
| 41 | void set(const std::string _value);
|
|---|
| 42 |
|
|---|
| 43 | // comparator
|
|---|
| 44 | bool operator==(const ContinuousValue<T> &_instance) const;
|
|---|
| 45 | bool operator!=(const ContinuousValue<T> &_instance) const
|
|---|
| 46 | { return !((*this)==(_instance)); }
|
|---|
| 47 |
|
|---|
| 48 | // getter/setter for valid ranges
|
|---|
| 49 | void setValidRange(const range<T> &_range);
|
|---|
| 50 | const range<T> & getValidRange() const;
|
|---|
| 51 |
|
|---|
| 52 | // internal functions alike to ValueInterface
|
|---|
| 53 | bool isValidValue(const T &_value) const;
|
|---|
| 54 | void setValue(const T &_value);
|
|---|
| 55 | const T &getValue() const;
|
|---|
| 56 |
|
|---|
| 57 | private:
|
|---|
| 58 | //!> Internal converter from string to internal type
|
|---|
| 59 | static ConvertTo<T> Converter;
|
|---|
| 60 |
|
|---|
| 61 | //!> whether \a value has been set
|
|---|
| 62 | bool ValueSet;
|
|---|
| 63 | //!> contained value
|
|---|
| 64 | T value;
|
|---|
| 65 |
|
|---|
| 66 | //!> whether \a min, i.e. a minimal value, has been set
|
|---|
| 67 | range<bool> ValidRangeSet;
|
|---|
| 68 | //!> valid range of values
|
|---|
| 69 | range<T> ValidRange;
|
|---|
| 70 | };
|
|---|
| 71 |
|
|---|
| 72 | #include "ContinuousValue_impl.hpp"
|
|---|
| 73 |
|
|---|
| 74 | #endif /* CONTINUOUSVALUE_HPP_ */
|
|---|