BALL 1.5.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | List of all members
BALL::PyKernel Class Referenceabstract

#include <BALL/PYTHON/pyKernel.h>

Inheritance diagram for BALL::PyKernel:
BALL::PyCAPIKernel

Public Types

using KeyValArgs = std::map< std::string, std::string >
 

Public Member Functions

 PyKernel ()=default
 
virtual ~PyKernel ()=default
 
virtual bool isStarted () const =0
 
virtual std::string getErrorMessage () const =0
 
virtual std::pair< bool, std::string > run (std::string str)=0
 
virtual BALL_DEPRECATED bool runFile (std::string filename)=0
 
virtual bool execute (const std::string &module, const std::string &func, const KeyValArgs &args)=0
 

Protected Member Functions

virtual void loadScriptDir ()
 

Detailed Description

Definition at line 14 of file pyKernel.h.

Member Typedef Documentation

◆ KeyValArgs

using BALL::PyKernel::KeyValArgs = std::map<std::string, std::string>

Definition at line 17 of file pyKernel.h.

Constructor & Destructor Documentation

◆ PyKernel()

BALL::PyKernel::PyKernel ( )
default

◆ ~PyKernel()

virtual BALL::PyKernel::~PyKernel ( )
virtualdefault

Member Function Documentation

◆ execute()

virtual bool BALL::PyKernel::execute ( const std::string &  module,
const std::string &  func,
const KeyValArgs args 
)
pure virtual

Calls a single function from a given module.

Parameters
modulea Python module
funca function from the given module
argsfunction arguments as key-value pairs
Returns
true if the execution succeeded

Implemented in BALL::PyCAPIKernel.

◆ getErrorMessage()

virtual std::string BALL::PyKernel::getErrorMessage ( ) const
pure virtual

Returns the most recent error message emitted by the Python interpreter.

Returns
most recent error message

Implemented in BALL::PyCAPIKernel.

◆ isStarted()

virtual bool BALL::PyKernel::isStarted ( ) const
pure virtual

Checks whether the kernel is started.

Returns
true if kernel is started, else otherwise

Implemented in BALL::PyCAPIKernel.

◆ loadScriptDir()

virtual void BALL::PyKernel::loadScriptDir ( )
protectedvirtual

Appends the 'python' directory in the BALL data path to sys.path. This is where additional BALL-specific Python scripts would be located.

This function should be called by every kernel implementation on initialization!

◆ run()

virtual std::pair< bool, std::string > BALL::PyKernel::run ( std::string  str)
pure virtual

Executes a single Python string.

Parameters
strcorrectly indented Python string
Returns
The first value indicated whether the execution succeeded. The second value is the output generated by the execution, if any.

Implemented in BALL::PyCAPIKernel.

◆ runFile()

virtual BALL_DEPRECATED bool BALL::PyKernel::runFile ( std::string  filename)
pure virtual

Executes a single Python file.

Parameters
filenamePython file name
Returns
true if the execution succeeded
Deprecated:
Use Jupyter notebook plugin instead

Implemented in BALL::PyCAPIKernel.