ImFusion SDK 4.3
PythonInterpreterInterface Class Referenceabstract

#include <ImFusion/Python/PythonInterpreter.h>

Interface for the embedded PythonInterpreter that prevents linking to an explicit Python version. More...

+ Inheritance diagram for PythonInterpreterInterface:

Detailed Description

Interface for the embedded PythonInterpreter that prevents linking to an explicit Python version.

Classes

class  GILScopeGuard
 

Public Types

using dict = std::unordered_map<std::string, std::shared_ptr<Data>>
 

Public Member Functions

virtual std::string version () const =0
 Returns the Python version of this interpreter (e.g. "3.6")
 
virtual const std::stringbridgeDirectory () const =0
 Returns the runtime directory from where interpreter bridge plugins can be loaded.
 
virtual std::unique_ptr< GILScopeGuardgil_scoped_acquire ()=0
 
virtual std::unique_ptr< GILScopeGuardgil_scoped_release ()=0
 
virtual std::vector< std::shared_ptr< Data > > eval (const std::string &expr, const dict &localData=dict())=0
 Evaluates a Python expression via pybind11::eval, passing it a set of local data, and returns a vector of Data returned by the expression.
 
virtual void eval_file (std::string filename)=0
 Calls pybind11::eval_file Raises an exception on error.
 
virtual void exec (std::string expr)=0
 Calls pybind11::exec Raises an exception on error.
 
virtual void createInteractiveConsole (MainWindowBase *main)=0
 Creates an interactive console widget in the MainWindow.
 

Protected Member Functions

 PythonInterpreterInterface (const std::string &)
 
virtual void start ()=0
 
virtual std::unique_ptr< ImFusionPlugincreateFactoriesPlugin ()=0
 
virtual void setApplicationController (ApplicationController &app)=0
 

Member Function Documentation

◆ version()

virtual std::string version ( ) const
pure virtual

Returns the Python version of this interpreter (e.g. "3.6")

Implemented in PythonInterpreter.

◆ bridgeDirectory()

virtual const std::string & bridgeDirectory ( ) const
pure virtual

Returns the runtime directory from where interpreter bridge plugins can be loaded.

Implemented in PythonInterpreter.

◆ eval()

virtual std::vector< std::shared_ptr< Data > > eval ( const std::string & expr,
const dict & localData = dict() )
pure virtual

Evaluates a Python expression via pybind11::eval, passing it a set of local data, and returns a vector of Data returned by the expression.

The Python expression is expected to return a Data or a list/tuple/dictionary of Data that are bound. Throws a C++ exception if the expression raises a Python exception.

Implemented in PythonInterpreter.

◆ eval_file()

virtual void eval_file ( std::string filename)
pure virtual

Calls pybind11::eval_file Raises an exception on error.

Implemented in PythonInterpreter.

◆ exec()

virtual void exec ( std::string expr)
pure virtual

Calls pybind11::exec Raises an exception on error.

Implemented in PythonInterpreter.

◆ createInteractiveConsole()

virtual void createInteractiveConsole ( MainWindowBase * main)
pure virtual

Creates an interactive console widget in the MainWindow.

The widget is added to a layout with the object name of "logViewerContainer". If no such widget exists in main, the console is launch in a separate window.

What kind of widget is created depends on the PythonSettings::consoleType setting value. With the default value of PythonSettings::NoConsole, no widget is created.

The created widget has an object name of "pythonConsoleWidget". Any existing "pythonConsoleWidget" is deleted when this method is called.

Implemented in PythonInterpreter.

◆ start()

virtual void start ( )
protectedpure virtual

Implemented in PythonInterpreter.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close