| 1 | /*
 | 
|---|
| 2 |  * Parameter_impl.hpp
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  *  Created on: Apr 16, 2012
 | 
|---|
| 5 |  *      Author: ankele
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | #ifndef PARAMETER_IMPL_HPP_
 | 
|---|
| 9 | #define PARAMETER_IMPL_HPP_
 | 
|---|
| 10 | 
 | 
|---|
| 11 | // include config.h
 | 
|---|
| 12 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 13 | #include <config.h>
 | 
|---|
| 14 | #endif
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #include "Parameter.hpp"
 | 
|---|
| 17 | 
 | 
|---|
| 18 | /** Constructor for class Parameter.
 | 
|---|
| 19 |  *
 | 
|---|
| 20 |  */
 | 
|---|
| 21 | template<typename T>
 | 
|---|
| 22 | Parameter<T>::Parameter(const std::string &_name) :
 | 
|---|
| 23 |   ParameterInterface<T>(_name),
 | 
|---|
| 24 |   Value<T>()
 | 
|---|
| 25 | {};
 | 
|---|
| 26 | 
 | 
|---|
| 27 | /** Constructor for class Parameter.
 | 
|---|
| 28 |  *
 | 
|---|
| 29 |  * @param _name name of this parameter
 | 
|---|
| 30 |  * @param _value initial value to set
 | 
|---|
| 31 |  */
 | 
|---|
| 32 | template<typename T>
 | 
|---|
| 33 | Parameter<T>::Parameter(const std::string &_name, const T &_value) :
 | 
|---|
| 34 |   ParameterInterface<T>(_name),
 | 
|---|
| 35 |   Value<T>()
 | 
|---|
| 36 | {
 | 
|---|
| 37 |   Value<T>::set(_value);
 | 
|---|
| 38 | };
 | 
|---|
| 39 | 
 | 
|---|
| 40 | /** Constructor for class Parameter.
 | 
|---|
| 41 |  *
 | 
|---|
| 42 |  * @param _name name of this parameter
 | 
|---|
| 43 |  * @param _ValidRange valid range for this ContinuousValue
 | 
|---|
| 44 |  */
 | 
|---|
| 45 | template<typename T>
 | 
|---|
| 46 | Parameter<T>::Parameter(const std::string &_name, const Validator<T> &_Validator) :
 | 
|---|
| 47 |   ParameterInterface<T>(_name),
 | 
|---|
| 48 |   Value<T>(_Validator)
 | 
|---|
| 49 | {};
 | 
|---|
| 50 | 
 | 
|---|
| 51 | /** Constructor for class Parameter.
 | 
|---|
| 52 |  *
 | 
|---|
| 53 |  * @param _name name of this parameter
 | 
|---|
| 54 |  * @param _ValidRange valid range for this ContinuousValue
 | 
|---|
| 55 |  * @param _value initial value to set
 | 
|---|
| 56 |  */
 | 
|---|
| 57 | template<typename T>
 | 
|---|
| 58 | Parameter<T>::Parameter(const std::string &_name, const Validator<T> &_Validator, const T &_value) :
 | 
|---|
| 59 |   ParameterInterface<T>(_name),
 | 
|---|
| 60 |   Value<T>(_Validator)
 | 
|---|
| 61 | {
 | 
|---|
| 62 |   Value<T>::set(_value);
 | 
|---|
| 63 | };
 | 
|---|
| 64 | 
 | 
|---|
| 65 | /** Constructor for class Parameter.
 | 
|---|
| 66 |  *
 | 
|---|
| 67 |  * @param _name name of this parameter
 | 
|---|
| 68 |  * @param _ValidRange valid range for this ContinuousValue
 | 
|---|
| 69 |  */
 | 
|---|
| 70 | template<typename T>
 | 
|---|
| 71 | Parameter<T>::Parameter(const std::string &_name, const std::vector<T> &_ValidValues) :
 | 
|---|
| 72 |   ParameterInterface<T>(_name),
 | 
|---|
| 73 |   Value<T>(_ValidValues)
 | 
|---|
| 74 | {};
 | 
|---|
| 75 | 
 | 
|---|
| 76 | /** Constructor for class Parameter.
 | 
|---|
| 77 |  *
 | 
|---|
| 78 |  * @param _name name of this parameter
 | 
|---|
| 79 |  * @param _ValidRange valid range for this ContinuousValue
 | 
|---|
| 80 |  * @param _value initial value to set
 | 
|---|
| 81 |  */
 | 
|---|
| 82 | template<typename T>
 | 
|---|
| 83 | Parameter<T>::Parameter(const std::string &_name, const std::vector<T> &_ValidValues, const T &_value) :
 | 
|---|
| 84 |   ParameterInterface<T>(_name),
 | 
|---|
| 85 |   Value<T>(_ValidValues)
 | 
|---|
| 86 | {
 | 
|---|
| 87 |   Value<T>::set(_value);
 | 
|---|
| 88 | };
 | 
|---|
| 89 | 
 | 
|---|
| 90 | /** Constructor for class Parameter.
 | 
|---|
| 91 |  *
 | 
|---|
| 92 |  * @param _name name of this parameter
 | 
|---|
| 93 |  * @param _ValidRange valid range for this ContinuousValue
 | 
|---|
| 94 |  */
 | 
|---|
| 95 | template<typename T>
 | 
|---|
| 96 | Parameter<T>::Parameter(const std::string &_name, const range<T> &_ValidRange) :
 | 
|---|
| 97 |   ParameterInterface<T>(_name),
 | 
|---|
| 98 |   Value<T>(_ValidRange)
 | 
|---|
| 99 | {};
 | 
|---|
| 100 | 
 | 
|---|
| 101 | /** Constructor for class Parameter.
 | 
|---|
| 102 |  *
 | 
|---|
| 103 |  * @param _name name of this parameter
 | 
|---|
| 104 |  * @param _ValidRange valid range for this ContinuousValue
 | 
|---|
| 105 |  * @param _value initial value to set
 | 
|---|
| 106 |  */
 | 
|---|
| 107 | template<typename T>
 | 
|---|
| 108 | Parameter<T>::Parameter(const std::string &_name, const range<T> &_ValidRange, const T &_value) :
 | 
|---|
| 109 |   ParameterInterface<T>(_name),
 | 
|---|
| 110 |   Value<T>(_ValidRange)
 | 
|---|
| 111 | {
 | 
|---|
| 112 |   Value<T>::set(_value);
 | 
|---|
| 113 | };
 | 
|---|
| 114 | 
 | 
|---|
| 115 | /** Destructor for class Parameter.
 | 
|---|
| 116 |  *
 | 
|---|
| 117 |  */
 | 
|---|
| 118 | template<typename T>
 | 
|---|
| 119 | Parameter<T>::~Parameter()
 | 
|---|
| 120 | {};
 | 
|---|
| 121 | 
 | 
|---|
| 122 | /** Compares this continuous value against another \a _instance.
 | 
|---|
| 123 |  *
 | 
|---|
| 124 |  * @param _instance other value to compare to
 | 
|---|
| 125 |  * @return true - if contained ContinuousValue and name are the same, false - else
 | 
|---|
| 126 |  */
 | 
|---|
| 127 | template <class T>
 | 
|---|
| 128 | bool Parameter<T>::operator==(const Parameter<T> &_instance) const
 | 
|---|
| 129 | {
 | 
|---|
| 130 |   bool status = true;
 | 
|---|
| 131 |   status = status &&
 | 
|---|
| 132 |       (*dynamic_cast<const Value<T> *>(this) == dynamic_cast<const Value<T> &>(_instance));
 | 
|---|
| 133 |   status = status && (ParameterInterface<T>::getName() == _instance.ParameterInterface<T>::getName());
 | 
|---|
| 134 |   return status;
 | 
|---|
| 135 | }
 | 
|---|
| 136 | 
 | 
|---|
| 137 | /** Creates a clone of this Parameter instance.
 | 
|---|
| 138 |  *
 | 
|---|
| 139 |  * @return cloned instance
 | 
|---|
| 140 |  */
 | 
|---|
| 141 | template<typename T>
 | 
|---|
| 142 | ParameterInterface<T>* Parameter<T>::clone() const
 | 
|---|
| 143 | {
 | 
|---|
| 144 |   Parameter<T> *instance = new Parameter<T>(ParameterInterface<T>::getName(), Value<T>::getValidator());
 | 
|---|
| 145 |   instance->set(Value<T>::get());
 | 
|---|
| 146 |   return instance;
 | 
|---|
| 147 | }
 | 
|---|
| 148 | 
 | 
|---|
| 149 | 
 | 
|---|
| 150 | #endif /* Parameter_IMPL_HPP_ */
 | 
|---|