00001 #ifndef PYTHON_INTERPRETER_WORKER_HH 00002 #define PYTHON_INTERPRETER_WORKER_HH 00003 00004 #include <csignal> 00005 #include <utility> 00006 #include <QObject> 00007 #include <QQueue> 00008 #include <boost/python.hpp> 00009 #include <boost/shared_ptr.hpp> 00010 #include "output_redirector.hh" 00011 00012 namespace ost { namespace gui { 00013 namespace bp = boost::python; 00014 00015 class PythonInterpreterWorker: public QObject 00016 { 00017 Q_OBJECT 00018 public: 00019 PythonInterpreterWorker(); 00020 unsigned int AddCommand(const QString& command); 00021 00022 signals: 00023 void Finished(unsigned int id, bool error_state); 00024 void Output(unsigned int id,const QString& output); 00025 void ErrorOutput(unsigned int id,const QString& output); 00026 00027 public slots: 00028 void Wake(); 00029 00030 protected slots: 00031 void handle_redirector_output(const QString& output); 00032 void handle_redirector_error(const QString& output); 00033 00034 protected: 00035 bool is_simple_expression(const QString& expr); 00036 void run_command_(std::pair<unsigned int,QString> pair); 00037 bool is_simple_expression_(const QString& expr); 00038 QQueue<std::pair<unsigned int,QString> > exec_queue_; 00039 unsigned int command_id_; 00040 boost::shared_ptr<OutputRedirector> output_redirector_; 00041 boost::shared_ptr<OutputRedirector> error_redirector_; 00042 #ifndef _MSC_VER 00043 struct sigaction sig_act_; 00044 #endif 00045 bp::object parse_expr_cmd_; 00046 bp::object repr_; 00047 bp::dict main_namespace_; 00048 unsigned int current_id_; 00049 }; 00050 00051 }} //ns 00052 00053 #endif // PYTHON_INTERPRETER_WORKER_HH
1.5.8