PythonInit.h 455 B

1234567891011121314151617181920212223242526272829303132333435
  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. };
  26. } // namespace Egametang
  27. #endif // PYTHON_PYTHON_INIT_H