[c68409] | 1 | /*
|
---|
| 2 | * ContinuousParameter_impl.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Sep 30, 2011
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef CONTINUOUSPARAMETER_IMPL_HPP_
|
---|
| 9 | #define CONTINUOUSPARAMETER_IMPL_HPP_
|
---|
| 10 |
|
---|
| 11 | // include config.h
|
---|
| 12 | #ifdef HAVE_CONFIG_H
|
---|
| 13 | #include <config.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | #include <limits>
|
---|
| 17 |
|
---|
| 18 | #include "ContinuousParameter.hpp"
|
---|
| 19 |
|
---|
| 20 | /** Constructor for class ContinuousParameter.
|
---|
| 21 | *
|
---|
| 22 | */
|
---|
| 23 | template<typename T>
|
---|
| 24 | ContinuousParameter<T>::ContinuousParameter(const std::string &_name) :
|
---|
[9cd0d0] | 25 | ParameterInterface<T>(_name),
|
---|
[c68409] | 26 | ContinuousValue<T>(range<T>(std::numeric_limits<T>::min(), std::numeric_limits<T>::max()))
|
---|
| 27 | {};
|
---|
| 28 |
|
---|
| 29 | /** Constructor for class ContinuousParameter.
|
---|
| 30 | *
|
---|
| 31 | * @param _name name of this parameter
|
---|
| 32 | * @param _value initial value to set
|
---|
| 33 | */
|
---|
| 34 | template<typename T>
|
---|
| 35 | ContinuousParameter<T>::ContinuousParameter(const std::string &_name, const T &_value) :
|
---|
[9cd0d0] | 36 | ParameterInterface<T>(_name),
|
---|
[c68409] | 37 | ContinuousValue<T>(range<T>(std::numeric_limits<T>::min(), std::numeric_limits<T>::max()))
|
---|
| 38 | {
|
---|
| 39 | setValue(_value);
|
---|
| 40 | };
|
---|
| 41 |
|
---|
| 42 | /** Constructor for class ContinuousParameter.
|
---|
| 43 | *
|
---|
| 44 | * @param _name name of this parameter
|
---|
| 45 | * @param _ValidRange valid range for this ContinuousValue
|
---|
| 46 | */
|
---|
| 47 | template<typename T>
|
---|
| 48 | ContinuousParameter<T>::ContinuousParameter(const std::string &_name, const range<T> &_ValidRange) :
|
---|
[9cd0d0] | 49 | ParameterInterface<T>(_name),
|
---|
[c68409] | 50 | ContinuousValue<T>(_ValidRange)
|
---|
| 51 | {};
|
---|
| 52 |
|
---|
| 53 | /** Constructor for class ContinuousParameter.
|
---|
| 54 | *
|
---|
| 55 | * @param _name name of this parameter
|
---|
| 56 | * @param _ValidRange valid range for this ContinuousValue
|
---|
| 57 | * @param _value initial value to set
|
---|
| 58 | */
|
---|
| 59 | template<typename T>
|
---|
| 60 | ContinuousParameter<T>::ContinuousParameter(const std::string &_name, const range<T> &_ValidRange, const T &_value) :
|
---|
[9cd0d0] | 61 | ParameterInterface<T>(_name),
|
---|
[c68409] | 62 | ContinuousValue<T>(_ValidRange)
|
---|
| 63 | {
|
---|
[047cad] | 64 | set(_value);
|
---|
[c68409] | 65 | };
|
---|
| 66 |
|
---|
| 67 | /** Destructor for class ContinuousParameter.
|
---|
| 68 | *
|
---|
| 69 | */
|
---|
| 70 | template<typename T>
|
---|
| 71 | ContinuousParameter<T>::~ContinuousParameter()
|
---|
| 72 | {};
|
---|
| 73 |
|
---|
| 74 | /** Compares this continuous value against another \a _instance.
|
---|
| 75 | *
|
---|
| 76 | * @param _instance other value to compare to
|
---|
| 77 | * @return true - if contained ContinuousValue and name are the same, false - else
|
---|
| 78 | */
|
---|
| 79 | template <class T>
|
---|
| 80 | bool ContinuousParameter<T>::operator==(const ContinuousParameter<T> &_instance) const
|
---|
| 81 | {
|
---|
| 82 | bool status = true;
|
---|
| 83 | status = status &&
|
---|
| 84 | (*dynamic_cast<const ContinuousValue<T> *>(this) == dynamic_cast<const ContinuousValue<T> &>(_instance));
|
---|
[9cd0d0] | 85 | status = status && (ParameterInterface<T>::getName() == _instance.ParameterInterface<T>::getName());
|
---|
[c68409] | 86 | return status;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | /** Creates a clone of this Parameter instance.
|
---|
| 90 | *
|
---|
| 91 | * @return cloned instance
|
---|
| 92 | */
|
---|
| 93 | template<typename T>
|
---|
[9cd0d0] | 94 | ParameterInterface<T>* ContinuousParameter<T>::clone() const
|
---|
[c68409] | 95 | {
|
---|
[9cd0d0] | 96 | ContinuousParameter<T> *instance = new ContinuousParameter<T>(ParameterInterface<T>::getName(), ContinuousValue<T>::getValidRange());
|
---|
[c68409] | 97 | instance->setValue(ContinuousValue<T>::getValue());
|
---|
| 98 | return instance;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 | #endif /* CONTINUOUSPARAMETER_IMPL_HPP_ */
|
---|