Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef PYTHONEXECUTER_H_
00009 #define PYTHONEXECUTER_H_
00010
00011 #include <iostream>
00012 #include <set>
00013 #include <boost/lexical_cast.hpp>
00014 #include <python2.7/Python.h>
00015
00016 using namespace std;
00017
00018 struct CompilationResult {
00019 bool success;
00020 string message;
00021
00022 CompilationResult() { message = ""; success = false; }
00023 };
00024
00025 class PythonExecuter
00026 {
00027
00028 public:
00029
00030 static void initialize();
00031
00032 static void initModule(string name, PyMethodDef* methodDef);
00033 static void execute(string code);
00034 static CompilationResult compile(string code);
00035
00036 static void finalize();
00037
00038 private:
00039
00040 static PyThreadState* _mainState;
00041 static set<string> _initializedModules;
00042
00043 PythonExecuter() { }
00044
00045 };
00046
00047 #endif