BornAgain  1.19.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 reflection and scattering
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_PARAM_BASE_REALPARAMETER_H
16 #define BORNAGAIN_PARAM_BASE_REALPARAMETER_H
17 
18 #include "Fit/Param/Attributes.h"
19 #include "Fit/Param/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 public:
33  RealParameter(const std::string& name, double* par, const std::string& parent_name = "",
34  const std::function<void()>& onChange = std::function<void()>(),
36  const Attributes& attr = Attributes::free());
37  virtual ~RealParameter() = default;
38 
39  RealParameter* clone(const std::string& new_name = "") const;
40 
41  //! Sets value of wrapped parameter and emit signal
42  void setValue(double value);
43 
44  //! Returns value of wrapped parameter
45  double value() const;
46 
48  RealLimits limits() const;
49 
50  RealParameter& setLimited(double lower, double upper);
53 
54  RealParameter& setUnit(const std::string& name);
55  std::string unit() const;
56 
57 protected:
61 };
62 
63 #endif // BORNAGAIN_PARAM_BASE_REALPARAMETER_H
Defines and implements class Attributes.
Defines and implements interface IParameter<T>.
Defines class RealLimits.
Defines class Unit.
Attributes for a fit parameter.
Definition: Attributes.h:26
static Attributes free()
Definition: Attributes.h:31
Abstract base class for parameter wrapper classes RealParameter, ComponentParameter.
Definition: IParameter.h:29
Container with parameters for IParametricComponent object.
Definition: ParameterPool.h:29
Limits for a real fit parameter.
Definition: RealLimits.h:24
static RealLimits limitless()
Creates an object withoud bounds (default)
Definition: RealLimits.cpp:130
Wraps a parameter of type double.
Definition: RealParameter.h:31
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:59
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:58
void setValue(double value)
Sets value of wrapped parameter and emit signal.
A physical unit.
Definition: Unit.h:27
QString const & name(EShape k)
Definition: particles.cpp:21