source: src/Parameters/Parameter.hpp@ b5b114

Last change on this file since b5b114 was cf1d82, checked in by Frederik Heber <heber@…>, 12 years ago

Parameter now contains Value, not inherits.

  • added several function to fully wrap all Value member functions.
  • this should prevent any vtable clashes between Parameter and Value that both inherit ValueAsString.
  • MpqcParser_Parameters.hpp does not contain any reference to the templated parts of Parameter or Value. These are only contained in the .cpp module.
  • Property mode set to 100644
File size: 2.3 KB
Line 
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 "ValueInterface.hpp"
22#include "ParameterInterface.hpp"
23
24class ParameterException;
25class ParameterValueException;
26
27/** This class encapsulates a clonable, continuous value.
28 *
29 */
30template <typename T>
31class Parameter :
32 public ParameterInterface,
33 public ValueInterface<T>
34{
35public:
36 Parameter(const Parameter<T> &instance);
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
47 // wrap the following functions from ValueAsString to add exception information
48 bool isValidAsString(const std::string &_value) const throw(ParameterValidatorException);
49 const std::string getAsString() const throw(ParameterValueException);
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);
54 const T & get() const throw(ParameterValueException);
55 void set(const T & _value) throw(ParameterValueException);
56 bool isSet() const
57 { return value.isSet(); }
58
59 const Validator<T> & getValidator() const
60 { return value.getValidator(); }
61 Validator<T> & getValidator()
62 { return value.getValidator(); }
63
64 // comparator
65 bool operator==(const Parameter<T> &_instance) const throw(ParameterException);
66 bool operator!=(const Parameter<T> &_instance) const throw(ParameterException)
67 { return !((*this)==(_instance)); }
68
69 ParameterInterface* clone() const;
70
71//private: // TODO...
72 Parameter();
73
74private:
75 //!> contained value of this parameter
76 Value<T> value;
77};
78
79#include "Parameter_impl.hpp"
80
81
82#endif /* PARAMETER_HPP_ */
Note: See TracBrowser for help on using the repository browser.