Belle II Software development
BoostPythonModuleProxy Class Reference

Proxy class to register python modules (the things you can 'import'). More...

#include <RegisterPythonModule.h>

Public Member Functions

 BoostPythonModuleProxy (const char *name, PyObject *(*initFunc)(), bool auto_import=false)
 Don't construct this object yourself, use the REGISTER_PYTHON_MODULE macro instead.
 

Detailed Description

Proxy class to register python modules (the things you can 'import').

See also
REGISTER_PYTHON_MODULE
REGISTER_PYTHON_MODULE_AUTOIMPORT

Definition at line 21 of file RegisterPythonModule.h.

Constructor & Destructor Documentation

◆ BoostPythonModuleProxy()

BoostPythonModuleProxy ( const char *  name,
PyObject *(*)()  initFunc,
bool  auto_import = false 
)

Don't construct this object yourself, use the REGISTER_PYTHON_MODULE macro instead.

Definition at line 18 of file RegisterPythonModule.cc.

19{
20 if (PyImport_AppendInittab(const_cast<char*>(name), initFunc) == -1) {
21 B2FATAL("REGISTER_PYTHON_MODULE(" << name << ") failed.");
22 }
23
24 if (auto_import) {
25 if (!Py_IsInitialized()) {
26 B2FATAL("REGISTER_PYTHON_MODULE_AUTOIMPORT(" << name << "): Python is not initialized!");
27 }
28
29 std::string importString = "import ";
30 importString += name;
31 if (PyRun_SimpleString(importString.c_str()) == -1) {
32 B2FATAL("'import " << name << "' failed.");
33 }
34 }
35}

The documentation for this class was generated from the following files: