Files
rtabmap/corelib/include/rtabmap/core/PythonInterface.h
T

51 lines
1.2 KiB
C++
Raw Normal View History

2021-01-17 01:56:27 -05:00
/*
* PythonInterface.h
*
* Created on: Jan. 14, 2021
* Author: mathieu
*/
#ifndef CORELIB_SRC_PYTHON_PYTHONINTERFACE_H_
#define CORELIB_SRC_PYTHON_PYTHONINTERFACE_H_
#include "rtabmap/core/rtabmap_core_export.h" // DLL export/import defines
2021-01-17 01:56:27 -05:00
#include <string>
#include <rtabmap/utilite/UMutex.h>
namespace pybind11 {
class scoped_interpreter;
class gil_scoped_release;
}
2021-01-17 01:56:27 -05:00
namespace rtabmap {
/**
2026-08-06 13:32:20 -07:00
* Process-wide singleton owning the embedded Python interpreter.
* Call PythonInterface::instance() from the main thread (typically near
* the top of main()) before any Python-using class is constructed.
*/
class RTABMAP_CORE_EXPORT PythonInterface
2021-01-17 01:56:27 -05:00
{
public:
2026-08-06 13:32:20 -07:00
// Pass a caller tag (e.g. class name) so the main-thread assertion
// can report who triggered the first construction.
static PythonInterface & instance(const std::string & caller = "");
PythonInterface(const PythonInterface &) = delete;
PythonInterface & operator=(const PythonInterface &) = delete;
2021-01-17 01:56:27 -05:00
private:
2026-08-06 13:32:20 -07:00
explicit PythonInterface(const std::string & caller);
~PythonInterface();
pybind11::scoped_interpreter* guard_;
pybind11::gil_scoped_release* release_;
2021-01-17 01:56:27 -05:00
};
std::string RTABMAP_CORE_EXPORT getPythonTraceback();
2021-01-17 01:56:27 -05:00
}
#endif /* CORELIB_SRC_PYTHON_PYTHONINTERFACE_H_ */