| [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) :
 | 
|---|
| [dbb533] | 25 |   Parameter<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) :
 | 
|---|
| [dbb533] | 36 |   Parameter<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) :
 | 
|---|
| [dbb533] | 49 |   Parameter<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) :
 | 
|---|
| [dbb533] | 61 |   Parameter<T>(_name),
 | 
|---|
| [c68409] | 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));
 | 
|---|
| [dbb533] | 85 |   status = status && (Parameter<T>::getName() == _instance.Parameter<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>
 | 
|---|
 | 94 | Parameter<T>* ContinuousParameter<T>::clone() const
 | 
|---|
 | 95 | {
 | 
|---|
| [dbb533] | 96 |   ContinuousParameter<T> *instance = new ContinuousParameter<T>(Parameter<T>::getName(), ContinuousValue<T>::getValidRange());
 | 
|---|
| [c68409] | 97 |   instance->setValue(ContinuousValue<T>::getValue());
 | 
|---|
 | 98 |   return instance;
 | 
|---|
 | 99 | }
 | 
|---|
 | 100 | 
 | 
|---|
 | 101 | 
 | 
|---|
 | 102 | #endif /* CONTINUOUSPARAMETER_IMPL_HPP_ */
 | 
|---|