QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Static Public Member Functions | Protected Member Functions | Static Protected Attributes | List of all members
QgsPythonRunner Class Reference

Utility class for running python commands from various parts of QGIS. More...

#include <qgspythonrunner.h>

Collaboration diagram for QgsPythonRunner:
Collaboration graph
[legend]

Static Public Member Functions

static bool isValid ()
 returns true if the runner has an instance (and thus is able to run commands)
static bool run (QString command, QString messageOnError=QString())
 execute a python statement
static bool eval (QString command, QString &result)
 Eval a python statement.
static void setInstance (QgsPythonRunner *runner)
 assign an instance of python runner so that run() can be used.

Protected Member Functions

 QgsPythonRunner ()
 protected constructor: can be instantiated only from children
virtual ~QgsPythonRunner ()
virtual bool runCommand (QString command, QString messageOnError=QString())=0
virtual bool evalCommand (QString command, QString &result)=0

Static Protected Attributes

static QgsPythonRunnermInstance = NULL

Detailed Description

Utility class for running python commands from various parts of QGIS.

There is no direct python support in the core library, so it is expected that application with python support creates a subclass that implements pure virtual function(s) during the initialization. The static methods will then work as expected.

Added in QGIS v?

Definition at line 29 of file qgspythonrunner.h.

Constructor & Destructor Documentation

QgsPythonRunner::QgsPythonRunner ( )
protected

protected constructor: can be instantiated only from children

Definition at line 64 of file qgspythonrunner.cpp.

QgsPythonRunner::~QgsPythonRunner ( )
protectedvirtual

Definition at line 68 of file qgspythonrunner.cpp.

Member Function Documentation

bool QgsPythonRunner::eval ( QString  command,
QString &  result 
)
static

Eval a python statement.

Definition at line 42 of file qgspythonrunner.cpp.

References evalCommand(), mInstance, and QgsDebugMsg.

virtual bool QgsPythonRunner::evalCommand ( QString  command,
QString &  result 
)
protectedpure virtual

Referenced by eval().

bool QgsPythonRunner::isValid ( )
static

returns true if the runner has an instance (and thus is able to run commands)

Definition at line 23 of file qgspythonrunner.cpp.

References mInstance.

bool QgsPythonRunner::run ( QString  command,
QString  messageOnError = QString() 
)
static
virtual bool QgsPythonRunner::runCommand ( QString  command,
QString  messageOnError = QString() 
)
protectedpure virtual

Referenced by run().

void QgsPythonRunner::setInstance ( QgsPythonRunner runner)
static

assign an instance of python runner so that run() can be used.

This method should be called during app initialization. Takes ownership of the object, deletes previous instance.

Definition at line 55 of file qgspythonrunner.cpp.

References mInstance.

Member Data Documentation

QgsPythonRunner * QgsPythonRunner::mInstance = NULL
staticprotected

Definition at line 57 of file qgspythonrunner.h.

Referenced by eval(), isValid(), run(), and setInstance().


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