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 "Range.hpp"
|
---|
19 |
|
---|
20 | #include "ValueInterface.hpp"
|
---|
21 |
|
---|
22 | class ContinuousValueTest;
|
---|
23 |
|
---|
24 | /** This class represents a discrete value, it implements ValueInterface.
|
---|
25 | *
|
---|
26 | */
|
---|
27 | template <class T>
|
---|
28 | class ContinuousValue : virtual public ValueInterface<T>
|
---|
29 | {
|
---|
30 | //!> unit test needs to have access to internal values
|
---|
31 | friend class ContinuousValueTest;
|
---|
32 | public:
|
---|
33 | ContinuousValue();
|
---|
34 | ContinuousValue(const range<T> &_ValidRange);
|
---|
35 | virtual ~ContinuousValue();
|
---|
36 |
|
---|
37 | // functions for ValueInterface
|
---|
38 | bool isValid(const T & _value) const;
|
---|
39 | const T & get() const;
|
---|
40 | void set(const T & _value);
|
---|
41 |
|
---|
42 | // comfortable setter
|
---|
43 | void operator=(const T &_value)
|
---|
44 | { set(_value); }
|
---|
45 |
|
---|
46 | // comparator
|
---|
47 | bool operator==(const ContinuousValue<T> &_instance) const;
|
---|
48 | bool operator!=(const ContinuousValue<T> &_instance) const
|
---|
49 | { return !((*this)==(_instance)); }
|
---|
50 |
|
---|
51 | // getter/setter for valid ranges
|
---|
52 | void setValidRange(const range<T> &_range);
|
---|
53 | const range<T> & getValidRange() const;
|
---|
54 |
|
---|
55 | // internal functions alike to ValueInterface
|
---|
56 | bool isValidValue(const T &_value) const;
|
---|
57 | void setValue(const T &_value);
|
---|
58 | const T &getValue() const;
|
---|
59 |
|
---|
60 | private:
|
---|
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_ */
|
---|