BornAgain  1.19.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 reflection and scattering
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 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_SAMPLE_MULTILAYER_PYIMPORT_H
21 #define BORNAGAIN_SAMPLE_MULTILAYER_PYIMPORT_H
22 
23 #ifdef BORNAGAIN_PYTHON
24 
25 #include <memory>
26 #include <string>
27 #include <vector>
28 
29 class MultiLayer;
30 
31 namespace PyImport {
32 
33 ////! Returns directory name
34 // std::string bornagainPythonDir();
35 
36 //! Creates a multi layer by running python code in embedded interpreter.
37 //! @param script: Python script
38 //! @param functionName: A function name in this script which produces a MultiLayer
39 //! @param path: A path to import BornAgain library. If empty, relies on PYTHONPATH
40 std::unique_ptr<MultiLayer> createFromPython(const std::string& script,
41  const std::string& functionName,
42  const std::string& path = "");
43 
44 //! Returns list of functions defined in the script.
45 //! @param script: Python script
46 //! @param path: A path to import BornAgain library. If empty, relies on PYTHONPATH
47 std::vector<std::string> listOfFunctions(const std::string& script, const std::string& path = "");
48 } // namespace PyImport
49 
50 #endif // BORNAGAIN_PYTHON
51 
52 #endif // BORNAGAIN_SAMPLE_MULTILAYER_PYIMPORT_H
53 #endif // USER_API
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:41
std::vector< std::string > listOfFunctions(const std::string &script, const std::string &path="")
Returns list of functions defined in the script.
Definition: PyImport.cpp:86
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:34