| 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) :
 | 
|---|
| 25 |   Parameter(_name),
 | 
|---|
| 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) :
 | 
|---|
| 36 |   Parameter(_name),
 | 
|---|
| 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) :
 | 
|---|
| 49 |   Parameter(_name),
 | 
|---|
| 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) :
 | 
|---|
| 61 |   Parameter(_name),
 | 
|---|
| 62 |   ContinuousValue<T>(_ValidRange)
 | 
|---|
| 63 | {
 | 
|---|
| 64 |   setValue(_value);
 | 
|---|
| 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));
 | 
|---|
| 85 |   status = status && (Parameter::getName() == _instance.Parameter::getName());
 | 
|---|
| 86 |   return status;
 | 
|---|
| 87 | }
 | 
|---|
| 88 | 
 | 
|---|
| 89 | /** Creates a clone of this Parameter instance.
 | 
|---|
| 90 |  *
 | 
|---|
| 91 |  * @return cloned instance
 | 
|---|
| 92 |  */
 | 
|---|
| 93 | template<typename T>
 | 
|---|
| 94 | Parameter* ContinuousParameter<T>::clone() const
 | 
|---|
| 95 | {
 | 
|---|
| 96 |   ContinuousParameter<T> *instance = new ContinuousParameter<T>(Parameter::getName(), ContinuousValue<T>::getValidRange());
 | 
|---|
| 97 |   instance->setValue(ContinuousValue<T>::getValue());
 | 
|---|
| 98 |   return instance;
 | 
|---|
| 99 | }
 | 
|---|
| 100 | 
 | 
|---|
| 101 | 
 | 
|---|
| 102 | #endif /* CONTINUOUSPARAMETER_IMPL_HPP_ */
 | 
|---|