| 1 | /* | 
|---|
| 2 | * Parameter.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Apr 16, 2012 | 
|---|
| 5 | *      Author: ankele | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef PARAMETER_HPP_ | 
|---|
| 9 | #define PARAMETER_HPP_ | 
|---|
| 10 |  | 
|---|
| 11 |  | 
|---|
| 12 |  | 
|---|
| 13 | // include config.h | 
|---|
| 14 | #ifdef HAVE_CONFIG_H | 
|---|
| 15 | #include <config.h> | 
|---|
| 16 | #endif | 
|---|
| 17 |  | 
|---|
| 18 | #include <string> | 
|---|
| 19 |  | 
|---|
| 20 | #include "Value.hpp" | 
|---|
| 21 | #include "ParameterInterface.hpp" | 
|---|
| 22 |  | 
|---|
| 23 | class ParameterException; | 
|---|
| 24 | class ParameterValueException; | 
|---|
| 25 |  | 
|---|
| 26 | /** This class encapsulates a clonable, continuous value. | 
|---|
| 27 | * | 
|---|
| 28 | */ | 
|---|
| 29 | template <typename T> | 
|---|
| 30 | class Parameter : public ParameterInterface<T>, public Value<T> | 
|---|
| 31 | { | 
|---|
| 32 | public: | 
|---|
| 33 | Parameter(const Parameter<T> &instance); | 
|---|
| 34 | Parameter(const std::string &_name); | 
|---|
| 35 | Parameter(const std::string &_name, const T &_value); | 
|---|
| 36 | Parameter(const std::string &_name, const Validator<T> &_Validator); | 
|---|
| 37 | Parameter(const std::string &_name, const Validator<T> &_Validator, const T &_value); | 
|---|
| 38 | Parameter(const std::string &_name, const std::vector<T> &_ValidValues); | 
|---|
| 39 | Parameter(const std::string &_name, const std::vector<T> &_ValidValues, const T &_value); | 
|---|
| 40 | Parameter(const std::string &_name, const range<T> &_ValidRange); | 
|---|
| 41 | Parameter(const std::string &_name, const range<T> &_ValidRange, const T &_value); | 
|---|
| 42 | virtual ~Parameter(); | 
|---|
| 43 |  | 
|---|
| 44 | // catch the following functions from Value<T> to add exception information | 
|---|
| 45 | const std::string getAsString() const throw(ParameterValueException); | 
|---|
| 46 | const T & get() const throw(ParameterValueException); | 
|---|
| 47 | void set(const T & _value) throw(ParameterValueException); | 
|---|
| 48 | void setAsString(const std::string _value) throw(ParameterValueException); | 
|---|
| 49 |  | 
|---|
| 50 | // comparator | 
|---|
| 51 | bool operator==(const Parameter<T> &_instance) const throw(ParameterException); | 
|---|
| 52 | bool operator!=(const Parameter<T> &_instance) const throw(ParameterException) | 
|---|
| 53 | { return !((*this)==(_instance)); } | 
|---|
| 54 |  | 
|---|
| 55 | ParameterAsString* clone() const; | 
|---|
| 56 |  | 
|---|
| 57 | //private: // TODO... | 
|---|
| 58 | Parameter(); | 
|---|
| 59 | }; | 
|---|
| 60 |  | 
|---|
| 61 | #include "Parameter_impl.hpp" | 
|---|
| 62 |  | 
|---|
| 63 |  | 
|---|
| 64 | #endif /* PARAMETER_HPP_ */ | 
|---|