BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
RealParameter.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Param/Base/RealParameter.h
6 //! @brief Defines class RealParameter.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
15 #ifndef BORNAGAIN_CORE_PARAMETRIZATION_REALPARAMETER_H
16 #define BORNAGAIN_CORE_PARAMETRIZATION_REALPARAMETER_H
17 
18 #include "Fit/Tools/Attributes.h"
19 #include "Fit/Tools/RealLimits.h"
20 #include "Param/Base/IParameter.h"
21 #include "Param/Base/Unit.h"
22 #include <string>
23 
24 class ParameterPool;
25 
26 //! Wraps a parameter of type double.
27 //! In addition to name and on-change callback held by the parent class IParameter,
28 //! this class holds Limits, Attributes (currently only fixed or not), and a Unit.
29 //! @ingroup tools_internal
30 
31 class RealParameter : public IParameter<double>
32 {
33 public:
34  RealParameter(const std::string& name, double* par, const std::string& parent_name = "",
35  const std::function<void()>& onChange = std::function<void()>(),
37  const Attributes& attr = Attributes::free());
38  virtual ~RealParameter() = default;
39 
40  RealParameter* clone(const std::string& new_name = "") const;
41 
42  //! Sets value of wrapped parameter and emit signal
43  void setValue(double value);
44 
45  //! Returns value of wrapped parameter
46  double value() const;
47 
49  RealLimits limits() const;
50 
51  RealParameter& setLimited(double lower, double upper);
54 
55  RealParameter& setUnit(const std::string& name);
56  std::string unit() const;
57 
58 protected:
62 };
63 
64 #endif // BORNAGAIN_CORE_PARAMETRIZATION_REALPARAMETER_H
Defines and implements class Attributes.
Defines and implements pure virtual base class IParameter<T>.
Defines class RealLimits.
Defines class Unit.
Attributes for a fit parameter.
Definition: Attributes.h:24
static Attributes free()
Definition: Attributes.h:29
Pure virtual base class for parameter wrapper classes RealParameter, ComponentParameter.
Definition: IParameter.h:29
Container with parameters for IParameterized object.
Definition: ParameterPool.h:30
Limits for a real fit parameter.
Definition: RealLimits.h:25
static RealLimits limitless()
Creates an object withoud bounds (default)
Definition: RealLimits.cpp:128
Wraps a parameter of type double.
Definition: RealParameter.h:32
RealLimits limits() const
RealParameter & setLimits(const RealLimits &limits)
RealParameter * clone(const std::string &new_name="") const
RealParameter & setNonnegative()
virtual ~RealParameter()=default
Attributes m_attr
Definition: RealParameter.h:60
RealParameter & setLimited(double lower, double upper)
double value() const
Returns value of wrapped parameter.
RealParameter & setPositive()
std::string unit() const
RealParameter(const std::string &name, double *par, const std::string &parent_name="", const std::function< void()> &onChange=std::function< void()>(), const RealLimits &limits=RealLimits::limitless(), const Attributes &attr=Attributes::free())
RealParameter & setUnit(const std::string &name)
RealLimits m_limits
Definition: RealParameter.h:59
void setValue(double value)
Sets value of wrapped parameter and emit signal.
A physical unit.
Definition: Unit.h:23