PythonInit.h 498 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef PYTHON_PYTHON_INIT_H
  2. #define PYTHON_PYTHON_INIT_H
  3. #include <boost/noncopyable.hpp>
  4. #include <boost/python.hpp>
  5. namespace Egametang {
  6. class PythonInit: private boost::noncopyable
  7. {
  8. public:
  9. PythonInit()
  10. {
  11. Py_InitializeEx(0);
  12. }
  13. ~PythonInit()
  14. {
  15. Py_Finalize();
  16. }
  17. bool IsInitialized()
  18. {
  19. return Py_IsInitialized();
  20. }
  21. const char* Version()
  22. {
  23. return Py_GetVersion();
  24. }
  25. void PrintError()
  26. {
  27. PyErr_Print();
  28. }
  29. };
  30. } // namespace Egametang
  31. #endif // PYTHON_PYTHON_INIT_H