OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
python_interpreter_worker.hh
Go to the documentation of this file.
1 #ifndef PYTHON_INTERPRETER_WORKER_HH
2 #define PYTHON_INTERPRETER_WORKER_HH
3 
4 #include <csignal>
5 #include <utility>
6 // workaround for QTBUG-22829: https://bugreports.qt-project.org/browse/QTBUG-22829
7 #ifndef Q_MOC_RUN
8  #include <boost/python.hpp>
9  #include <boost/shared_ptr.hpp>
10 #endif
11 #include "output_redirector.hh"
12 #include <QObject>
13 #include <QQueue>
14 
15 namespace ost { namespace gui {
16 namespace bp = boost::python;
17 
18 class PythonInterpreterWorker: public QObject
19 {
20 Q_OBJECT
21 public:
24  unsigned int AddCommand(const QString& command);
25 
26 signals:
27  void Finished(unsigned int id, bool error_state);
28  void Output(unsigned int id,const QString& output);
29  void ErrorOutput(unsigned int id,const QString& output);
30 
31 public slots:
32  void Wake();
33 
34 protected slots:
35  void handle_redirector_output(const QString& output);
36  void handle_redirector_error(const QString& output);
37 
38 protected:
39  bool is_simple_expression(const QString& expr);
40  void run_command_(std::pair<unsigned int,QString> pair);
41  bool is_simple_expression_(const QString& expr);
42  QQueue<std::pair<unsigned int,QString> > exec_queue_;
43  unsigned int command_id_;
44  boost::shared_ptr<OutputRedirector> output_redirector_;
45  boost::shared_ptr<OutputRedirector> error_redirector_;
46 #ifndef _MSC_VER
47  struct sigaction sig_act_;
48 #endif
49  bp::object parse_expr_cmd_;
50  bp::object repr_;
51  bp::dict main_namespace_;
52  unsigned int current_id_;
53  bool awake_;
54 };
55 
56 }} //ns
57 
58 #endif // PYTHON_INTERPRETER_WORKER_HH