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