BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Static Public Member Functions | Static Protected Attributes | List of all members
BALL::PyInterpreter Class Reference

#include <BALL/PYTHON/pyInterpreter.h>

Public Types

Type definitions
typedef std::vector< StringPathStrings
 Used to encode the individual paths appended to sys.path for dynamic loading of modules. More...
 

Static Public Member Functions

static bool execute (const QString &module, const QString &func, const QList< QPair< QString, QString > > &params)
 
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. More...
 
static const PathStringsgetSysPath ()
 Get the current paths added to sys.path. More...
 
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_
 

Detailed Description

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.

Definition at line 36 of file pyInterpreter.h.

Member Typedef Documentation

Used to encode the individual paths appended to sys.path for dynamic loading of modules.

Definition at line 47 of file pyInterpreter.h.

Member Function Documentation

static bool BALL::PyInterpreter::execute ( const QString &  module,
const QString &  func,
const QList< QPair< QString, QString > > &  params 
)
static
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 ( )
inlinestatic

Definition at line 84 of file pyInterpreter.h.

static const PathStrings& BALL::PyInterpreter::getSysPath ( )
static

Get the current paths added to sys.path.

static bool BALL::PyInterpreter::importModule ( const String module_name)
static

Import a module. The module with name module_name is imported using PyImport_ImportModule and initialized. When called

Returns
true if the modules was found an initialized correctly
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.

Returns
true if the interpreter is correctly initialized
static bool BALL::PyInterpreter::isValid ( )
inlinestatic

Definition at line 81 of file pyInterpreter.h.

static String BALL::PyInterpreter::run ( const String s,
bool result 
)
static

Execute a string.

Parameters
sthe string to run (may contain multiple lines with correct indentation)
resultbool reference which contains the result after call of function
Returns
the output of the interpreter (may also contain error messages)
static String BALL::PyInterpreter::runFile ( const String filename)
throw (Exception::FileNotFound
)
static

Run a Python program from a file.

Parameters
file_namethe name of the program file
static void BALL::PyInterpreter::setSysPath ( const PathStrings path_strings)
static

Append additional search paths to sys.path upon initialization.

Member Data Documentation

String BALL::PyInterpreter::start_log_
staticprotected

Definition at line 118 of file pyInterpreter.h.

PathStrings BALL::PyInterpreter::sys_path_
staticprotected

Definition at line 116 of file pyInterpreter.h.

bool BALL::PyInterpreter::valid_
staticprotected

Definition at line 117 of file pyInterpreter.h.