BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
PyCallback.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Fit/Kernel/PyCallback.h
6 //! @brief Defines class PyCallback.
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_FIT_KERNEL_PYCALLBACK_H
16 #define BORNAGAIN_FIT_KERNEL_PYCALLBACK_H
17 
18 #include "Fit/Kernel/Parameters.h"
19 #include <vector>
20 
21 //! Base class to wrap Python callable and pass it to C++. Used in swig interface file,
22 //! intended to be overloaded from Python.
23 
25 {
26 public:
28 
30  virtual ~PyCallback();
31 
33 
34  //! Call Python callable and returns its result. Intended to be overloaded in Python.
35  //! @param pars: Fit parameters object (intentionally passed by value).
36  //! @return value of objective function.
37  virtual double call_scalar(Fit::Parameters pars);
38 
39  //! Call Python callable and returns its result. Intended to be overloaded in Python.
40  //! @param pars: Fit parameters object (intentionally passed by value).
41  //! @return vector of residuals
42  virtual std::vector<double> call_residuals(Fit::Parameters pars);
43 
44 private:
46 };
47 
48 #endif // BORNAGAIN_FIT_KERNEL_PYCALLBACK_H
Defines class Parameters.
A collection of fit parameters.
Definition: Parameters.h:28
Base class to wrap Python callable and pass it to C++.
Definition: PyCallback.h:25
virtual std::vector< double > call_residuals(Fit::Parameters pars)
Call Python callable and returns its result.
Definition: PyCallback.cpp:31
CallbackType m_callback_type
Definition: PyCallback.h:45
PyCallback(CallbackType callback_type=SCALAR)
Definition: PyCallback.cpp:17
virtual double call_scalar(Fit::Parameters pars)
Call Python callable and returns its result.
Definition: PyCallback.cpp:26
virtual ~PyCallback()
CallbackType callback_type() const
Definition: PyCallback.cpp:19