BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IParameterized.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Param/Base/IParameterized.h
6 //! @brief Defines class IParameterized.
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_IPARAMETERIZED_H
16 #define BORNAGAIN_CORE_PARAMETRIZATION_IPARAMETERIZED_H
17 
18 #include "Base/Vector/Vectors3D.h"
19 #include <memory>
20 
21 class RealLimits;
22 class ParameterPool;
23 class RealParameter;
24 
25 //! Manages a local parameter pool, and a tree of child pools.
26 //! @ingroup tools_internal
27 
29 {
30 public:
31  IParameterized(const std::string& name = "");
32  IParameterized(const IParameterized& other);
33  virtual ~IParameterized();
34 
35  IParameterized& operator=(const IParameterized& other) = delete;
36 
37  //! Returns pointer to the parameter pool.
38  ParameterPool* parameterPool() const { return m_pool.get(); } // has non-const usages!
39 
40  //! Creates new parameter pool, with all local parameters and those of its children.
41  virtual ParameterPool* createParameterTree() const;
42 
43  //! Returns multiline string representing available parameters.
44  std::string parametersToString() const;
45 
46  RealParameter& registerParameter(const std::string& name, double* parpointer);
47 
48  void registerVector(const std::string& base_name, kvector_t* p_vec,
49  const std::string& units = "nm");
50 
51  void setParameterValue(const std::string& name, double value);
52 
53  void setVectorValue(const std::string& base_name, kvector_t value);
54 
55  RealParameter* parameter(const std::string& name) const;
56 
57  //! Action to be taken in inherited class when a parameter has changed.
58  virtual void onChange() {}
59 
60  void removeParameter(const std::string& name);
61 
62  void removeVector(const std::string& base_name);
63 
64  static std::string XComponentName(const std::string& base_name);
65  static std::string YComponentName(const std::string& base_name);
66  static std::string ZComponentName(const std::string& base_name);
67 
68  void setName(const std::string& name) { m_name = name; }
69  const std::string& getName() const { return m_name; }
70 
71 private:
72  std::string m_name;
73  std::unique_ptr<ParameterPool> m_pool; //!< parameter pool (kind of pointer-to-implementation)
74 };
75 
76 #endif // BORNAGAIN_CORE_PARAMETRIZATION_IPARAMETERIZED_H
Defines basic vectors in R^3 and C^3.
Manages a local parameter pool, and a tree of child pools.
RealParameter & registerParameter(const std::string &name, double *parpointer)
IParameterized(const std::string &name="")
std::string parametersToString() const
Returns multiline string representing available parameters.
RealParameter * parameter(const std::string &name) const
Returns parameter with given 'name'.
static std::string XComponentName(const std::string &base_name)
void removeParameter(const std::string &name)
const std::string & getName() const
void removeVector(const std::string &base_name)
IParameterized & operator=(const IParameterized &other)=delete
std::string m_name
void setVectorValue(const std::string &base_name, kvector_t value)
virtual void onChange()
Action to be taken in inherited class when a parameter has changed.
void setName(const std::string &name)
std::unique_ptr< ParameterPool > m_pool
parameter pool (kind of pointer-to-implementation)
ParameterPool * parameterPool() const
Returns pointer to the parameter pool.
void registerVector(const std::string &base_name, kvector_t *p_vec, const std::string &units="nm")
virtual ParameterPool * createParameterTree() const
Creates new parameter pool, with all local parameters and those of its children.
static std::string YComponentName(const std::string &base_name)
virtual ~IParameterized()
void setParameterValue(const std::string &name, double value)
static std::string ZComponentName(const std::string &base_name)
Container with parameters for IParameterized object.
Definition: ParameterPool.h:30
Limits for a real fit parameter.
Definition: RealLimits.h:25
Wraps a parameter of type double.
Definition: RealParameter.h:32