BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
PyImport.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Multilayer/PyImport.h
6 //! @brief Defines PyImport namespace
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_PYIO_PYIMPORT_H
16 #define BORNAGAIN_CORE_PYIO_PYIMPORT_H
17 
18 #ifdef BORNAGAIN_PYTHON
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 class MultiLayer;
25 
26 namespace PyImport
27 {
28 
29 ////! Returns directory name
30 // std::string bornagainPythonDir();
31 
32 //! Creates a multi layer by running python code in embedded interpreter.
33 //! @param script: Python script
34 //! @param functionName: A function name in this script which produces a MultiLayer
35 //! @param path: A path to import BornAgain library. If empty, relies on PYTHONPATH
36 std::unique_ptr<MultiLayer> createFromPython(const std::string& script,
37  const std::string& functionName,
38  const std::string& path = "");
39 
40 //! Returns list of functions defined in the script.
41 //! @param script: Python script
42 //! @param path: A path to import BornAgain library. If empty, relies on PYTHONPATH
43 std::vector<std::string> listOfFunctions(const std::string& script, const std::string& path = "");
44 } // namespace PyImport
45 
46 #endif // BORNAGAIN_PYTHON
47 
48 #endif // BORNAGAIN_CORE_PYIO_PYIMPORT_H
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:42
std::vector< std::string > listOfFunctions(const std::string &script, const std::string &path="")
Returns list of functions defined in the script.
Definition: PyImport.cpp:87
std::unique_ptr< MultiLayer > createFromPython(const std::string &script, const std::string &functionName, const std::string &path="")
Creates a multi layer by running python code in embedded interpreter.
Definition: PyImport.cpp:35