| [adcfc6] | 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"
 | 
|---|
| [cf1d82] | 21 | #include "ValueInterface.hpp"
 | 
|---|
| [adcfc6] | 22 | #include "ParameterInterface.hpp"
 | 
|---|
 | 23 | 
 | 
|---|
| [e45c1d] | 24 | class ParameterException;
 | 
|---|
 | 25 | class ParameterValueException;
 | 
|---|
 | 26 | 
 | 
|---|
| [adcfc6] | 27 | /** This class encapsulates a clonable, continuous value.
 | 
|---|
 | 28 |  *
 | 
|---|
 | 29 |  */
 | 
|---|
 | 30 | template <typename T>
 | 
|---|
| [6440c6] | 31 | class Parameter :
 | 
|---|
| [cf1d82] | 32 |   public ParameterInterface,
 | 
|---|
 | 33 |   public ValueInterface<T>
 | 
|---|
| [adcfc6] | 34 | {
 | 
|---|
 | 35 | public:
 | 
|---|
| [f10b0c] | 36 |   Parameter(const Parameter<T> &instance);
 | 
|---|
| [adcfc6] | 37 |   Parameter(const std::string &_name);
 | 
|---|
 | 38 |   Parameter(const std::string &_name, const T &_value);
 | 
|---|
 | 39 |   Parameter(const std::string &_name, const Validator<T> &_Validator);
 | 
|---|
 | 40 |   Parameter(const std::string &_name, const Validator<T> &_Validator, const T &_value);
 | 
|---|
 | 41 |   Parameter(const std::string &_name, const std::vector<T> &_ValidValues);
 | 
|---|
 | 42 |   Parameter(const std::string &_name, const std::vector<T> &_ValidValues, const T &_value);
 | 
|---|
 | 43 |   Parameter(const std::string &_name, const range<T> &_ValidRange);
 | 
|---|
 | 44 |   Parameter(const std::string &_name, const range<T> &_ValidRange, const T &_value);
 | 
|---|
 | 45 |   virtual ~Parameter();
 | 
|---|
 | 46 | 
 | 
|---|
| [cf1d82] | 47 |   // wrap the following functions from ValueAsString to add exception information
 | 
|---|
 | 48 |   bool isValidAsString(const std::string &_value) const throw(ParameterValidatorException);
 | 
|---|
| [e45c1d] | 49 |   const std::string getAsString() const throw(ParameterValueException);
 | 
|---|
| [cf1d82] | 50 |   void setAsString(const std::string &_value) throw(ParameterValueException);
 | 
|---|
 | 51 | 
 | 
|---|
 | 52 |   // wrap the following functions from Value<T> to add exception information
 | 
|---|
 | 53 |   bool isValid(const T &_value) const throw(ParameterValidatorException);
 | 
|---|
| [e45c1d] | 54 |   const T & get() const throw(ParameterValueException);
 | 
|---|
| [b56114] | 55 |   const T & getUnvalidated() const throw(ParameterValueException);
 | 
|---|
| [e45c1d] | 56 |   void set(const T & _value) throw(ParameterValueException);
 | 
|---|
| [cf1d82] | 57 |   bool isSet() const
 | 
|---|
 | 58 |   { return value.isSet(); }
 | 
|---|
 | 59 | 
 | 
|---|
 | 60 |   const Validator<T> & getValidator() const
 | 
|---|
 | 61 |   { return value.getValidator(); }
 | 
|---|
 | 62 |   Validator<T> & getValidator()
 | 
|---|
 | 63 |   { return value.getValidator(); }
 | 
|---|
| [e45c1d] | 64 | 
 | 
|---|
| [adcfc6] | 65 |   // comparator
 | 
|---|
| [e45c1d] | 66 |   bool operator==(const Parameter<T> &_instance) const throw(ParameterException);
 | 
|---|
 | 67 |   bool operator!=(const Parameter<T> &_instance) const throw(ParameterException)
 | 
|---|
| [adcfc6] | 68 |       { return !((*this)==(_instance)); }
 | 
|---|
 | 69 | 
 | 
|---|
| [6440c6] | 70 |   ParameterInterface* clone() const;
 | 
|---|
| [adcfc6] | 71 | 
 | 
|---|
| [f10b0c] | 72 | //private: // TODO...
 | 
|---|
| [adcfc6] | 73 |   Parameter();
 | 
|---|
| [cf1d82] | 74 | 
 | 
|---|
 | 75 | private:
 | 
|---|
 | 76 |   //!> contained value of this parameter
 | 
|---|
 | 77 |   Value<T> value;
 | 
|---|
| [adcfc6] | 78 | };
 | 
|---|
 | 79 | 
 | 
|---|
 | 80 | #include "Parameter_impl.hpp"
 | 
|---|
 | 81 | 
 | 
|---|
 | 82 | 
 | 
|---|
 | 83 | #endif /* PARAMETER_HPP_ */
 | 
|---|