BALL  1.5.0
pyCAPIKernel.h
Go to the documentation of this file.
1 #ifndef BALL_PYTHON_PYCAPIKERNEL_H
2 #define BALL_PYTHON_PYCAPIKERNEL_H
3 
4 #include <BALL/PYTHON/pyKernel.h>
5 
6 #include <vector>
7 
8 namespace BALL
9 {
10  class PyCAPIKernel : public PyKernel
11  {
12  public:
14  ~PyCAPIKernel() override;
15 
16  bool isStarted() const override;
17  std::string getErrorMessage() const override { return last_err_; };
18 
19  std::pair<bool, std::string> run(std::string str) override;
20  BALL_DEPRECATED bool runFile(std::string filename) override;
21  bool execute(const std::string& module, const std::string& func, const KeyValArgs& args) override;
22 
23  private:
30  PyObject* loadModule(const std::string& name);
31 
38  bool errorOccurred();
39 
40  PyObject* main_module_ {nullptr};
41  PyObject* context_ {nullptr};
42  std::string last_err_ {};
43  std::vector<PyObject*> modules_ {};
44  };
45 }
46 
47 #endif // BALL_PYTHON_PYCAPIKERNEL_H
BALL::PyCAPIKernel::execute
bool execute(const std::string &module, const std::string &func, const KeyValArgs &args) override
BALL::PyCAPIKernel::~PyCAPIKernel
~PyCAPIKernel() override
BALL::PyCAPIKernel::getErrorMessage
std::string getErrorMessage() const override
Definition: pyCAPIKernel.h:17
pyKernel.h
BALL::PyCAPIKernel::isStarted
bool isStarted() const override
BALL::PyKernel::KeyValArgs
std::map< std::string, std::string > KeyValArgs
Definition: pyKernel.h:17
BALL
Definition: constants.h:13
BALL::PyCAPIKernel::PyCAPIKernel
PyCAPIKernel()
BALL::PyCAPIKernel::runFile
BALL_DEPRECATED bool runFile(std::string filename) override
BALL::PyCAPIKernel
Definition: pyCAPIKernel.h:11
BALL::PyKernel
Definition: pyKernel.h:15
BALL_DEPRECATED
#define BALL_DEPRECATED
Definition: COMMON/global.h:64
BALL::PyCAPIKernel::run
std::pair< bool, std::string > run(std::string str) override