| 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 |  | 
|---|
| 20 | #include "Value.hpp" | 
|---|
| 21 | #include "ValueInterface.hpp" | 
|---|
| 22 |  | 
|---|
| 23 | class ContinuousValueTest; | 
|---|
| 24 | class ParameterException; | 
|---|
| 25 | class ParameterValidatorException; | 
|---|
| 26 | class ParameterValueException; | 
|---|
| 27 |  | 
|---|
| 28 | /** This class represents a discrete value, it implements ValueInterface. | 
|---|
| 29 | * | 
|---|
| 30 | */ | 
|---|
| 31 | template <class T> | 
|---|
| 32 | class ContinuousValue : public Value<T> | 
|---|
| 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 | 
|---|
| 42 | bool isValid(const T & _value) const throw(ParameterValidatorException); | 
|---|
| 43 |  | 
|---|
| 44 | // comfortable setter | 
|---|
| 45 | void operator=(const T &_value) | 
|---|
| 46 | { set(_value);  } | 
|---|
| 47 |  | 
|---|
| 48 | // comparator | 
|---|
| 49 | bool operator==(const ContinuousValue<T> &_instance) const throw(ParameterException); | 
|---|
| 50 | bool operator!=(const ContinuousValue<T> &_instance) const throw(ParameterException) | 
|---|
| 51 | { return !((*this)==(_instance)); } | 
|---|
| 52 |  | 
|---|
| 53 | // getter/setter for valid ranges | 
|---|
| 54 | void setValidRange(const range<T> &_range) throw(ParameterValueException); | 
|---|
| 55 | const range<T> & getValidRange() const throw(ParameterValidatorException); | 
|---|
| 56 |  | 
|---|
| 57 | // string functions for ValueInterface, taken from Value | 
|---|
| 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_ */ | 
|---|