Loading...
Searching...
No Matches
pyInterpreter.h
Go to the documentation of this file.
#ifndef BALL_PYTHON_PYINTERPRETER_H
#define BALL_PYTHON_PYINTERPRETER_H
// This has to be included before Python.h to prevent macro redefinition clashes in macOS Python...
#include <BALL/SYSTEM/path.h>
#include <BALL/PYTHON/pyKernel.h>
#include <BALL/PYTHON/pyServer.h>
#include <memory>
#include <vector>
#include <QtCore/QList>
#include <QtCore/QPair>
#include <QtCore/QString>
namespace BALL
{
class BALL_EXPORT PyInterpreter final
{
private:
// We don't want anybody to instantiate this!
PyInterpreter() = default;
~PyInterpreter() = default;
public:
using PathStrings = std::vector<String>;
static void initialize();
static void finalize();
static bool isInitialized() { return kernel_ && kernel_->isStarted(); }
BALL_DEPRECATED static void setSysPath(const PathStrings& path_strings) { sys_path_ = path_strings; }
BALL_DEPRECATED static const PathStrings& getSysPath() { return sys_path_; }
BALL_DEPRECATED static bool isValid() { return isInitialized(); }
BALL_DEPRECATED static String getStartupLog() { return String(); }
static std::pair<bool, std::string> run(const std::string& s);
BALL_DEPRECATED static String run(const String& s, bool& result);
BALL_DEPRECATED static String runFile(const String& filename);
static bool execute(const std::string& module, const std::string& func, const PyKernel::KeyValArgs& params);
static std::string getErrorMessage();
BALL_DEPRECATED static bool execute(const QString& module, const QString& func, const QList<QPair<QString, QString> >& params);
static void startServer();
static void stopServer();
static bool serverIsRunning() { return bool(server_); }
protected:
static std::unique_ptr<PyKernel> kernel_;
static std::unique_ptr<PyServer> server_;
static PathStrings sys_path_;
};
} // namespace BALL
#endif // BALL_PYTHON_PYINTERPRETER_H
BALL_DEPRECATED
#define BALL_DEPRECATED
Definition COMMON/global.h:64
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::PyInterpreter::finalize
static void finalize()
BALL::PyInterpreter::PathStrings
std::vector< String > PathStrings
Used to encode the individual paths appended to sys.path for dynamic loading of modules.
Definition pyInterpreter.h:36
BALL::PyInterpreter::getStartupLog
static BALL_DEPRECATED String getStartupLog()
Definition pyInterpreter.h:79
BALL::PyInterpreter::setSysPath
static BALL_DEPRECATED void setSysPath(const PathStrings &path_strings)
Definition pyInterpreter.h:67
BALL::PyInterpreter::runFile
static BALL_DEPRECATED String runFile(const String &filename)
BALL::PyInterpreter::isValid
static BALL_DEPRECATED bool isValid()
Definition pyInterpreter.h:76
BALL::PyInterpreter::startServer
static void startServer()
BALL::PyInterpreter::serverIsRunning
static bool serverIsRunning()
Definition pyInterpreter.h:144
BALL::PyInterpreter::isInitialized
static bool isInitialized()
Definition pyInterpreter.h:61
BALL::PyInterpreter::run
static std::pair< bool, std::string > run(const std::string &s)
BALL::PyInterpreter::run
static BALL_DEPRECATED String run(const String &s, bool &result)
BALL::PyInterpreter::initialize
static void initialize()
BALL::PyInterpreter::execute
static bool execute(const std::string &module, const std::string &func, const PyKernel::KeyValArgs &params)
BALL::PyInterpreter::getSysPath
static BALL_DEPRECATED const PathStrings & getSysPath()
Definition pyInterpreter.h:73
BALL::PyInterpreter::sys_path_
static PathStrings sys_path_
Definition pyInterpreter.h:150
BALL::PyInterpreter::server_
static std::unique_ptr< PyServer > server_
Definition pyInterpreter.h:149
BALL::PyInterpreter::execute
static BALL_DEPRECATED bool execute(const QString &module, const QString &func, const QList< QPair< QString, QString > > &params)
BALL::PyInterpreter::getErrorMessage
static std::string getErrorMessage()
BALL::PyInterpreter::kernel_
static std::unique_ptr< PyKernel > kernel_
Definition pyInterpreter.h:148
BALL::PyInterpreter::stopServer
static void stopServer()
BALL::PyKernel::KeyValArgs
std::map< std::string, std::string > KeyValArgs
Definition pyKernel.h:17
BALL::String
Definition string.h:57
bool
BALL
Definition constants.h:13
path.h
pyKernel.h
pyServer.h