#include <BALL/PYTHON/pyInterpreter.h>
Public Types | |
Type definitions | |
typedef std::vector< String > | PathStrings |
Used to encode the individual paths appended to sys.path for dynamic loading of modules. | |
Static Public Member Functions | |
Initialization | |
static void | initialize () |
static void | finalize () |
static bool | isInitialized () |
static void | setSysPath (const PathStrings &path_strings) |
Append additional search paths to sys.path upon initialization. | |
static const PathStrings & | getSysPath () |
Get the current paths added to sys.path. | |
static bool | isValid () |
static String | getStartupLog () |
Execution | |
static String | run (const String &s, bool &result) |
static String | runFile (const String &filename) throw (Exception::FileNotFound) |
static bool | importModule (const String &module_name) |
Static Protected Attributes | |
static PathStrings | sys_path_ |
static bool | valid_ |
static String | start_log_ |
Private Member Functions | |
PyInterpreter () | |
~PyInterpreter () |
Embedded Python interpreter. There's just one global instance of the interpreter, so all methods are static. The use of subinterpreters is not yet supported.
typedef std::vector<String> BALL::PyInterpreter::PathStrings |
Used to encode the individual paths appended to sys.path for dynamic loading of modules.
BALL::PyInterpreter::PyInterpreter | ( | ) | [private] |
BALL::PyInterpreter::~PyInterpreter | ( | ) | [inline, private] |
static void BALL::PyInterpreter::finalize | ( | ) | [static] |
Stop the interpreter. Deallocate all memory occupied by the interpreter (by calling PY_Finalize
.
static String BALL::PyInterpreter::getStartupLog | ( | ) | [inline, static] |
static const PathStrings& BALL::PyInterpreter::getSysPath | ( | ) | [static] |
Get the current paths added to sys.path.
Import a module. The module with name module_name
is imported using PyImport_ImportModule
and initialized. When called
static void BALL::PyInterpreter::initialize | ( | ) | [static] |
Initialize the interpreter. Initialize the interpreter (by calling Py_Initialize
) and load the modules sys
, site
, and BALL
. A second call to initialize
may be used to restart the intepreter. Upon start, the paths defined by setSysPath are added to sys.path. If your interpreter cannot load specific modules, add the location of your modules here.
static bool BALL::PyInterpreter::isInitialized | ( | ) | [static] |
Determine the interpreter state.
static bool BALL::PyInterpreter::isValid | ( | ) | [inline, static] |
Execute a string.
s | the string to run (may contain multiple lines with correct indentation) | |
result | bool reference which contains the result after call of function |
static String BALL::PyInterpreter::runFile | ( | const String & | filename | ) | throw (Exception::FileNotFound) [static] |
Run a Python program from a file.
file_name | the name of the program file |
static void BALL::PyInterpreter::setSysPath | ( | const PathStrings & | path_strings | ) | [static] |
Append additional search paths to sys.path upon initialization.
String BALL::PyInterpreter::start_log_ [static, protected] |
PathStrings BALL::PyInterpreter::sys_path_ [static, protected] |
bool BALL::PyInterpreter::valid_ [static, protected] |