#pragma once #include "Python.h" #include #include using namespace boost::python; /* * PythonException: Exception object thrown by Python interface (usually * caused by an exception in Python interpreter) */ class python_exception : public std::runtime_error { public: python_exception(const std::string& errmsg) : std::runtime_error( errmsg ) {}; }; class CPythonDLL { public: CPythonDLL(void); ~CPythonDLL(void); void init(std::string& scriptName); void finalize(); const char* getVersion(void); const char* getCopyright(void); void eval(const char* code); void eval(std::string& code); void callfunc(const std::string fname, object& obj); protected: handle<> importModule(std::string module_name); python_exception getExceptionDetail(); object getFunction(const char* fname); handle<> module; handle<> func; };