source: src/Parameters/Parameter.hpp@ 8819d2

Candidate_v1.6.1 ChemicalSpaceEvaluator Gui_displays_atomic_force_velocity PythonUI_with_named_parameters TremoloParser_IncreasedPrecision
Last change on this file since 8819d2 was 2eded3e, checked in by Frederik Heber <frederik.heber@…>, 8 years ago

Added specific Value and Parameter implemenations for Vector.

  • for the CommandLineParser the values are get parsed immediately (prior to executing any Action). Hence, names of geometry objects that first need to be created by an action cannot yet be present in the registry and thus the Action will fail.
  • we need to postpone the replacement of the geometry name by its stored vector components until the Parameter<>::get() call. This is possible as the value is validated only on get(), not on set(), i.e. giving illegal values is ok, only the Action will fail.
  • therefore, we override the specialize the template Value for Vector to allow storing of a string instead of a Vector and to allow putting the actual parsing of the string in front.
  • the Parameter overriding becomes necessary in order to override clone() and copy cstor(), there using string setters.
  • ContinuousValueTest now needs lib..Parameters, lib..Geometry.
  • static functions parseAsVector and setFromVector for convenience, e.g. QtUI needs to convert from string and to Vector.
  • TESTS: Marked dryrun store-session again as XFAIL, removed XFAIL from load- session python.
  • Property mode set to 100644
File size: 2.5 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 cloneable, 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 const std::string getAsStringUnvalidated() const throw(ParameterValueException);
51 void setAsString(const std::string &_value) throw(ParameterValueException);
52
53 // wrap the following functions from Value<T> to add exception information
54 bool isValid(const T &_value) const throw(ParameterValidatorException);
55 const T & get() const throw(ParameterValueException);
56 const T & getUnvalidated() const throw(ParameterValueException);
57 void set(const T & _value) throw(ParameterValueException);
58 bool isSet() const
59 { return value.isSet(); }
60
61 const Validator<T> & getValidator() const
62 { return value.getValidator(); }
63 Validator<T> & getValidator()
64 { return value.getValidator(); }
65
66 // comparator
67 bool operator==(const Parameter<T> &_instance) const throw(ParameterException);
68 bool operator!=(const Parameter<T> &_instance) const throw(ParameterException)
69 { return !((*this)==(_instance)); }
70
71 ParameterInterface* clone() const;
72
73//private: // TODO...
74 Parameter();
75
76private:
77 //!> contained value of this parameter
78 Value<T> value;
79};
80
81#include "Parameters/Specifics/Parameter_vector.hpp"
82
83#include "Parameter_impl.hpp"
84
85
86#endif /* PARAMETER_HPP_ */
Note: See TracBrowser for help on using the repository browser.