|
QGIS API Documentation
master-6164ace
|
00001 /*************************************************************************** 00002 qgspythonrunner.cpp 00003 --------------------- 00004 begin : May 2011 00005 copyright : (C) 2011 by Martin Dobias 00006 email : wonder dot sk at gmail dot com 00007 *************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 #include "qgspythonrunner.h" 00016 #include "qgslogger.h" 00017 00018 QgsPythonRunner* QgsPythonRunner::mInstance = NULL; 00019 00021 // static methods 00022 00023 bool QgsPythonRunner::isValid() 00024 { 00025 return mInstance != NULL; 00026 } 00027 00028 bool QgsPythonRunner::run( QString command, QString messageOnError ) 00029 { 00030 if ( mInstance ) 00031 { 00032 return mInstance->runCommand( command, messageOnError ); 00033 } 00034 else 00035 { 00036 QgsDebugMsg( "Unable to run Python command: runner not available!" ); 00037 return false; 00038 } 00039 } 00040 00041 bool QgsPythonRunner::eval( QString command, QString& result ) 00042 { 00043 if ( mInstance ) 00044 { 00045 return mInstance->evalCommand( command, result ); 00046 } 00047 else 00048 { 00049 QgsDebugMsg( "Unable to run Python command: runner not available!" ); 00050 return false; 00051 } 00052 } 00053 00054 void QgsPythonRunner::setInstance( QgsPythonRunner* runner ) 00055 { 00056 delete mInstance; 00057 mInstance = runner; 00058 } 00059 00061 // non-static methods 00062 00063 QgsPythonRunner::QgsPythonRunner() 00064 { 00065 } 00066 00067 QgsPythonRunner::~QgsPythonRunner() 00068 { 00069 00070 }