[c68409] | 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>
|
---|
| 24 | DiscreteParameter<T>::DiscreteParameter(const std::string &_name) :
|
---|
[9cd0d0] | 25 | ParameterInterface<T>(_name)
|
---|
[c68409] | 26 | {};
|
---|
| 27 |
|
---|
| 28 | /** Constructor for class DiscreteParameter.
|
---|
| 29 | *
|
---|
| 30 | * @param _name name of this parameter
|
---|
| 31 | * @param _ValidValues valid values for this DiscreteValue
|
---|
| 32 | */
|
---|
| 33 | template<typename T>
|
---|
| 34 | DiscreteParameter<T>::DiscreteParameter(const std::string &_name, const std::vector<T> &_ValidValues) :
|
---|
[9cd0d0] | 35 | ParameterInterface<T>(_name),
|
---|
[c68409] | 36 | DiscreteValue<T>(_ValidValues)
|
---|
| 37 | {};
|
---|
| 38 |
|
---|
| 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) :
|
---|
[9cd0d0] | 47 | ParameterInterface<T>(_name),
|
---|
[c68409] | 48 | DiscreteValue<T>(_ValidValues)
|
---|
| 49 | {
|
---|
| 50 | setValue(_value);
|
---|
| 51 | };
|
---|
| 52 |
|
---|
| 53 | /** Destructor for class DiscreteParameter.
|
---|
| 54 | *
|
---|
| 55 | */
|
---|
| 56 | template<typename T>
|
---|
| 57 | DiscreteParameter<T>::~DiscreteParameter()
|
---|
| 58 | {};
|
---|
| 59 |
|
---|
| 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));
|
---|
[9cd0d0] | 71 | status = status && (ParameterInterface<T>::getName() == _instance.ParameterInterface<T>::getName());
|
---|
[c68409] | 72 | return status;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | /** Creates a clone of this Parameter instance.
|
---|
| 76 | *
|
---|
| 77 | * @return cloned instance
|
---|
| 78 | */
|
---|
| 79 | template<typename T>
|
---|
[9cd0d0] | 80 | ParameterInterface<T>* DiscreteParameter<T>::clone() const
|
---|
[c68409] | 81 | {
|
---|
[9cd0d0] | 82 | DiscreteParameter<T> *instance = new DiscreteParameter<T>(ParameterInterface<T>::getName(), DiscreteValue<T>::getValidValues());
|
---|
[c68409] | 83 | instance->setValue(DiscreteValue<T>::getValue());
|
---|
| 84 | return instance;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 |
|
---|
| 88 | #endif /* DISCRETEPARAMETER_IMPL_HPP_ */
|
---|