forked from diffpy/libdiffpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonInterface.hpp
More file actions
46 lines (36 loc) · 1.41 KB
/
PythonInterface.hpp
File metadata and controls
46 lines (36 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*****************************************************************************
*
* diffpy.srreal by DANSE Diffraction group
* Simon J. L. Billinge
* (c) 2009 Trustees of the Columbia University
* in the City of New York. All rights reserved.
*
* File coded by: Pavol Juhas
*
* See AUTHORS.txt for a list of people who contributed.
* See LICENSE.txt for license information.
*
******************************************************************************
*
* Common functions for interfacing with Python interpreter.
*
*****************************************************************************/
#ifndef PYTHONINTERFACE_HPP_INCLUDED
#define PYTHONINTERFACE_HPP_INCLUDED
#include <boost/python.hpp>
#include <string>
namespace diffpy {
// routines
void initializePython(int py_argc=0, char* py_argv[]=NULL);
std::string getPythonErrorString();
/// Obtain object from specified Python module.
/// Throw error_already_set on import error.
boost::python::object
importFromPyModule(const std::string& modname, const std::string& item);
/// Obtain object from specified Python module. When there are any errors,
/// ignore them and return the fallback object.
boost::python::object
importFromPyModule(const std::string& modname, const std::string& item,
boost::python::object fallback);
} // namespace diffpy
#endif // PYTHONINTERFACE_HPP_INCLUDED