[c68409] | 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 |
|
---|
[3c5ef5] | 18 | #include "CodePatterns/Range.hpp"
|
---|
[c68409] | 19 |
|
---|
[e45c1d] | 20 | #include "Value.hpp"
|
---|
[c68409] | 21 | #include "ValueInterface.hpp"
|
---|
| 22 |
|
---|
| 23 | class ContinuousValueTest;
|
---|
[e45c1d] | 24 | class ParameterException;
|
---|
| 25 | class ParameterValidatorException;
|
---|
| 26 | class ParameterValueException;
|
---|
[c68409] | 27 |
|
---|
| 28 | /** This class represents a discrete value, it implements ValueInterface.
|
---|
| 29 | *
|
---|
| 30 | */
|
---|
| 31 | template <class T>
|
---|
[e45c1d] | 32 | class ContinuousValue : public Value<T>
|
---|
[c68409] | 33 | {
|
---|
| 34 | //!> unit test needs to have access to internal values
|
---|
| 35 | friend class ContinuousValueTest;
|
---|
| 36 | public:
|
---|
| 37 | ContinuousValue();
|
---|
| 38 | ContinuousValue(const range<T> &_ValidRange);
|
---|
| 39 | virtual ~ContinuousValue();
|
---|
| 40 |
|
---|
| 41 | // functions for ValueInterface
|
---|
[e45c1d] | 42 | bool isValid(const T & _value) const throw(ParameterValidatorException);
|
---|
[c68409] | 43 |
|
---|
[c5e7313] | 44 | // comfortable setter
|
---|
| 45 | void operator=(const T &_value)
|
---|
| 46 | { set(_value); }
|
---|
| 47 |
|
---|
[c68409] | 48 | // comparator
|
---|
[e45c1d] | 49 | bool operator==(const ContinuousValue<T> &_instance) const throw(ParameterException);
|
---|
| 50 | bool operator!=(const ContinuousValue<T> &_instance) const throw(ParameterException)
|
---|
[c68409] | 51 | { return !((*this)==(_instance)); }
|
---|
| 52 |
|
---|
| 53 | // getter/setter for valid ranges
|
---|
[e45c1d] | 54 | void setValidRange(const range<T> &_range) throw(ParameterValueException);
|
---|
| 55 | const range<T> & getValidRange() const throw(ParameterValidatorException);
|
---|
[c68409] | 56 |
|
---|
[e45c1d] | 57 | // string functions for ValueInterface, taken from Value
|
---|
[c68409] | 58 |
|
---|
| 59 | private:
|
---|
| 60 | //!> whether \a value has been set
|
---|
| 61 | bool ValueSet;
|
---|
| 62 | //!> contained value
|
---|
| 63 | T value;
|
---|
| 64 |
|
---|
| 65 | //!> whether \a min, i.e. a minimal value, has been set
|
---|
| 66 | range<bool> ValidRangeSet;
|
---|
| 67 | //!> valid range of values
|
---|
| 68 | range<T> ValidRange;
|
---|
| 69 | };
|
---|
| 70 |
|
---|
| 71 | #include "ContinuousValue_impl.hpp"
|
---|
| 72 |
|
---|
| 73 | #endif /* CONTINUOUSVALUE_HPP_ */
|
---|