BALL 1.5.0
Loading...
Searching...
No Matches
pyInterpreter.h
Go to the documentation of this file.
1#ifndef BALL_PYTHON_PYINTERPRETER_H
2#define BALL_PYTHON_PYINTERPRETER_H
3
4// This has to be included before Python.h to prevent macro redefinition clashes in macOS Python...
5#include <BALL/SYSTEM/path.h>
6
9
10#include <memory>
11#include <vector>
12
13#include <QtCore/QList>
14#include <QtCore/QPair>
15#include <QtCore/QString>
16
17namespace BALL
18{
26 {
27 private:
28 // We don't want anybody to instantiate this!
29 PyInterpreter() = default;
30 ~PyInterpreter() = default;
31
32 public:
36 using PathStrings = std::vector<String>;
38
41
50 static void initialize();
51
56 static void finalize();
57
61 static bool isInitialized() { return kernel_ && kernel_->isStarted(); }
62
67 BALL_DEPRECATED static void setSysPath(const PathStrings& path_strings) { sys_path_ = path_strings; }
68
73 BALL_DEPRECATED static const PathStrings& getSysPath() { return sys_path_; }
74
76 BALL_DEPRECATED static bool isValid() { return isInitialized(); }
77
80
82
83
91 static std::pair<bool, std::string> run(const std::string& s);
92
94 BALL_DEPRECATED static String run(const String& s, bool& result);
95
101 BALL_DEPRECATED static String runFile(const String& filename);
102
111 static bool execute(const std::string& module, const std::string& func, const PyKernel::KeyValArgs& params);
112
118 static std::string getErrorMessage();
119
121 BALL_DEPRECATED static bool execute(const QString& module, const QString& func, const QList<QPair<QString, QString> >& params);
123
124
127
132 static void startServer();
133
137 static void stopServer();
138
144 static bool serverIsRunning() { return bool(server_); }
146
147 protected:
148 static std::unique_ptr<PyKernel> kernel_;
149 static std::unique_ptr<PyServer> server_;
151 };
152
153} // namespace BALL
154
155#endif // BALL_PYTHON_PYINTERPRETER_H
static void finalize()
std::vector< String > PathStrings
Used to encode the individual paths appended to sys.path for dynamic loading of modules.
static BALL_DEPRECATED String getStartupLog()
static BALL_DEPRECATED void setSysPath(const PathStrings &path_strings)
static BALL_DEPRECATED String runFile(const String &filename)
static BALL_DEPRECATED bool isValid()
static void startServer()
static bool serverIsRunning()
static bool isInitialized()
static std::pair< bool, std::string > run(const std::string &s)
static BALL_DEPRECATED String run(const String &s, bool &result)
static void initialize()
static bool execute(const std::string &module, const std::string &func, const PyKernel::KeyValArgs &params)
static BALL_DEPRECATED const PathStrings & getSysPath()
static PathStrings sys_path_
static std::unique_ptr< PyServer > server_
static BALL_DEPRECATED bool execute(const QString &module, const QString &func, const QList< QPair< QString, QString > > &params)
static std::string getErrorMessage()
static std::unique_ptr< PyKernel > kernel_
static void stopServer()
std::map< std::string, std::string > KeyValArgs
Definition pyKernel.h:17
#define BALL_DEPRECATED
#define BALL_EXPORT