Choreonoid  1.8
PythonExecutor.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_PYTHON_PLUGIN_PYTHON_EXECUTOR_H
6 #define CNOID_PYTHON_PLUGIN_PYTHON_EXECUTOR_H
7 
8 #include <cnoid/PyUtil>
9 #include <cnoid/Signal>
10 #include "exportdecl.h"
11 
12 namespace cnoid {
13 
18 class CNOID_EXPORT PythonExecutor
19 {
20 public:
21  static void setModuleRefreshEnabled(bool on);
22 
24  PythonExecutor(const PythonExecutor& org);
25  ~PythonExecutor();
26 
27  void setBackgroundMode(bool on);
28  bool isBackgroundMode() const;
29 
30  enum State { NOT_RUNNING, RUNNING_FOREGROUND, RUNNING_BACKGROUND };
31 
32  State state() const;
33 
34  bool eval(const std::string& code);
35 
37  python::object returnValue();
38 
40  python::object resultObject() { return returnValue(); }
41 
42  bool execCode(const std::string& code);
43  bool execFile(const std::string& filename);
44  bool waitToFinish(double timeout);
45 
46  SignalProxy<void()> sigFinished();
47 
48  bool hasException() const;
49  const std::string exceptionTypeName() const;
50  const std::string exceptionText() const;
51  python::object exceptionType() const;
52  python::object exceptionValue() const;
53 
55  const std::string resultString() const { return exceptionText(); }
56 
57  bool isTerminated() const;
58 
59  bool terminate();
60 
61 private:
62  class Impl;
63  Impl* impl;
64 };
65 
66 }
67 
68 #endif
cnoid::PythonExecutor::resultObject
python::object resultObject()
Definition: PythonExecutor.h:40
cnoid::PythonExecutor::resultString
const std::string resultString() const
Definition: PythonExecutor.h:55
cnoid::PythonExecutor
Definition: PythonExecutor.h:18
cnoid::PythonExecutor::State
State
Definition: PythonExecutor.h:30
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::SignalProxy
Definition: Signal.h:470