Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

PyInterpreter Class Reference
[Python extensions]

Embedded Python interpreter. More...

#include <pyInterpreter.h>

List of all members.

Public Types

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

Static Public Member Functions

Initialization
void initialize ()
 Initialize the interpreter.
void finalize ()
 Stop the interpreter.
bool isInitialized ()
 Determine the interpreter state.
void setSysPath (const PathStrings &path_strings)
 Append additional search paths to sys.path upon initialization.
const PathStringsgetSysPath ()
 Get the current paths added to sys.path.
bool isValid ()
String getStartupLog ()
Execution
String run (const String &s, bool &result)
 Execute a string.
String runFile (const String &filename) throw (Exception::FileNotFound)
 Run a Python program from a file.
bool importModule (const String &module_name)
 Import a module.

Static Protected Attributes

PathStrings sys_path_
bool valid_
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.


Member Function Documentation

void PyInterpreter::finalize  )  [static]
 

Stop the interpreter.

Deallocate all memory occupied by the interpreter (by calling PY_Finalize.

bool 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

void 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 are added to sys.path. If your interpreter cannot load specific modules, add the location of your modules here.

bool PyInterpreter::isInitialized  )  [static]
 

Determine the interpreter state.

Returns:
true if the interpreter is correctly initialized

String PyInterpreter::run const String s,
bool &  result
[static]
 

Execute a string.

Parameters:
s the string to run (may contain multiple lines with correct indentation)
result bool reference which contains the result after call of function
Returns:
the output of the interpreter (may also contain error messages)

String PyInterpreter::runFile const String filename  )  throw (Exception::FileNotFound) [static]
 

Run a Python program from a file.

Parameters:
file_name the name of the program file