omegalib  13.1
omega::PythonInterpreter Class Reference

#include <PythonInterpreter.h>

Classes

struct  QueuedCommand
 

Public Types

enum  CallbackType { CallbackUpdate, CallbackEvent, CallbackDraw }
 
enum  RunFlags { NoRunFlags = 0, SetCwdToScriptPath = 1 << 1, AddScriptPathToModuleSearchPath = 1 << 2, DefaultRunFlags = SetCwdToScriptPath }
 The flags that can be applied to the runFile method. More...
 

Public Member Functions

 PythonInterpreter ()
 
virtual ~PythonInterpreter ()
 
void setup (const Setting &setting)
 
void initialize (const char *programName)
 
void addModule (const char *name, PyMethodDef *methods)
 
void addModule (const char *name, PyMethodDef *methods, const Dictionary< String, int > intConstants, const Dictionary< String, String > stringConstants)
 
void eval (const String &script, const char *format=NULL,...)
 Immediately executes a script statement on the local node. More...
 
void runFile (const String &filename, uint flags=DefaultRunFlags)
 The script path accepts two macros: OMEGA_DATA_ROOT will be substituted with the default data directory for the omegalib installation OMEGA_APP_ROOT will be substituted with the application directory for the installation (set throguh CMake at build configuration time) More...
 
void clean ()
 Cleans the application state. More...
 
void cleanRun (const String &filename)
 Cleans the application state and runs a new script. More...
 
void evalEventCommand (const String &command, const Event &evt)
 Executes an event command statement. More...
 
void queueCommand (const String &command, bool local=false)
 Queues a command for execution. More...
 
void registerCallback (void *callback, CallbackType type)
 
void unregisterAllCallbacks ()
 
void addPythonPath (const char *)
 
bool isEnabled ()
 
bool isShellEnabled ()
 
void update (const UpdateContext &context)
 
void handleEvent (const Event &evt)
 
void draw (const DrawContext &context, Camera *cam)
 
virtual void commitSharedData (SharedOStream &out)
 
virtual void updateSharedData (SharedIStream &in)
 
void lockInterpreter ()
 
void unlockInterpreter ()
 
- Public Member Functions inherited from omicron::ReferenceType
 ReferenceType ()
 
virtual ~ReferenceType ()
 
void ref ()
 
void unref ()
 
long refCount ()
 

Static Public Member Functions

static const EventgetLastEvent ()
 
- Static Public Member Functions inherited from omicron::ReferenceType
static void printObjCounts ()
 

Protected Attributes

bool myEnabled
 
bool myShellEnabled
 
bool myDebugShell
 
String myInitCommand
 
String myInitScript
 
PythonInteractiveThread * myInteractiveThread
 
Lock myInteractiveCommandLock
 
List< QueuedCommand * > myCommandQueue
 
List< void * > myUpdateCallbacks
 
List< void * > myEventCallbacks
 
List< void * > myDrawCallbacks
 
Lock myLock
 
Ref< StatmyUpdateTimeStat
 

Additional Inherited Members

- Static Protected Attributes inherited from omicron::ReferenceType
static List< ReferenceType * > mysObjList
 
+ Inheritance diagram for omega::PythonInterpreter:

Member Enumeration Documentation

Enumerator
CallbackUpdate 
CallbackEvent 
CallbackDraw 

The flags that can be applied to the runFile method.

Enumerator
NoRunFlags 
SetCwdToScriptPath 

Set the current working directory to the script path.

AddScriptPathToModuleSearchPath 

Adds the script path to the search path for python modules (loaded using the import command)

DefaultRunFlags 

Constructor & Destructor Documentation

omega::PythonInterpreter::PythonInterpreter ( )
virtual omega::PythonInterpreter::~PythonInterpreter ( )
virtual

Member Function Documentation

void omega::PythonInterpreter::addModule ( const char *  name,
PyMethodDef *  methods 
)
void omega::PythonInterpreter::addModule ( const char *  name,
PyMethodDef *  methods,
const Dictionary< String, int >  intConstants,
const Dictionary< String, String stringConstants 
)
void omega::PythonInterpreter::addPythonPath ( const char *  )
void omega::PythonInterpreter::clean ( )

Cleans the application state.

void omega::PythonInterpreter::cleanRun ( const String filename)

Cleans the application state and runs a new script.

virtual void omega::PythonInterpreter::commitSharedData ( SharedOStream out)
virtual

Reimplemented from omega::SharedObject.

void omega::PythonInterpreter::draw ( const DrawContext context,
Camera cam 
)
void omega::PythonInterpreter::eval ( const String script,
const char *  format = NULL,
  ... 
)

Immediately executes a script statement on the local node.

void omega::PythonInterpreter::evalEventCommand ( const String command,
const Event evt 
)

Executes an event command statement.

Remarks
Event command statements are commonly used as event handlers. The event passed to this call can be accessed from the script side using the getEvent() global function
static const Event* omega::PythonInterpreter::getLastEvent ( )
inlinestatic

returns the last event received by the interpreter. Used for script interoperability

void omega::PythonInterpreter::handleEvent ( const Event evt)
void omega::PythonInterpreter::initialize ( const char *  programName)
bool omega::PythonInterpreter::isEnabled ( )
bool omega::PythonInterpreter::isShellEnabled ( )
inline
void omega::PythonInterpreter::lockInterpreter ( )
void omega::PythonInterpreter::queueCommand ( const String command,
bool  local = false 
)

Queues a command for execution.

If the local flag is set, the command will be executed only on the local node.

void omega::PythonInterpreter::registerCallback ( void *  callback,
CallbackType  type 
)
void omega::PythonInterpreter::runFile ( const String filename,
uint  flags = DefaultRunFlags 
)

The script path accepts two macros: OMEGA_DATA_ROOT will be substituted with the default data directory for the omegalib installation OMEGA_APP_ROOT will be substituted with the application directory for the installation (set throguh CMake at build configuration time)

void omega::PythonInterpreter::setup ( const Setting setting)
void omega::PythonInterpreter::unlockInterpreter ( )
void omega::PythonInterpreter::unregisterAllCallbacks ( )
void omega::PythonInterpreter::update ( const UpdateContext context)
virtual void omega::PythonInterpreter::updateSharedData ( SharedIStream in)
virtual

Reimplemented from omega::SharedObject.

Member Data Documentation

List<QueuedCommand*> omega::PythonInterpreter::myCommandQueue
protected
bool omega::PythonInterpreter::myDebugShell
protected
List<void*> omega::PythonInterpreter::myDrawCallbacks
protected
bool omega::PythonInterpreter::myEnabled
protected
List<void*> omega::PythonInterpreter::myEventCallbacks
protected
String omega::PythonInterpreter::myInitCommand
protected
String omega::PythonInterpreter::myInitScript
protected
Lock omega::PythonInterpreter::myInteractiveCommandLock
protected
PythonInteractiveThread* omega::PythonInterpreter::myInteractiveThread
protected
Lock omega::PythonInterpreter::myLock
protected
bool omega::PythonInterpreter::myShellEnabled
protected
List<void*> omega::PythonInterpreter::myUpdateCallbacks
protected
Ref<Stat> omega::PythonInterpreter::myUpdateTimeStat
protected

The documentation for this class was generated from the following file: