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