00001 /*************************************************************************** 00002 File : ScriptingEnv.h 00003 Project : QtiPlot 00004 -------------------------------------------------------------------- 00005 Copyright : (C) 2006 by Ion Vasilief, Knut Franke 00006 Email (use @ for *) : ion_vasilief*yahoo.fr 00007 Description : Scripting abstraction layer 00008 00009 ***************************************************************************/ 00010 00011 /*************************************************************************** 00012 * * 00013 * This program is free software; you can redistribute it and/or modify * 00014 * it under the terms of the GNU General Public License as published by * 00015 * the Free Software Foundation; either version 2 of the License, or * 00016 * (at your option) any later version. * 00017 * * 00018 * This program is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00021 * GNU General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU General Public License * 00024 * along with this program; if not, write to the Free Software * 00025 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 00026 * Boston, MA 02110-1301 USA * 00027 * * 00028 ***************************************************************************/ 00029 #ifndef SCRIPTINGENV_H 00030 #define SCRIPTINGENV_H 00031 00032 #include <QVariant> 00033 #include <QString> 00034 #include <QStringList> 00035 #include <QObject> 00036 #include <QStringList> 00037 #include <QEvent> 00038 00039 #include "customevents.h" 00040 00041 class ApplicationWindow; 00042 class Script; 00043 00045 00050 class ScriptingEnv : public QObject 00051 { 00052 Q_OBJECT 00053 00054 public: 00055 ScriptingEnv(ApplicationWindow *parent, const char *langName); 00057 virtual bool initialize() { return true; }; 00059 bool initialized() const { return d_initialized; } 00061 virtual bool isRunning() const { return false; } 00062 00064 virtual Script *newScript(const QString&, QObject*, const QString&) { return 0; } 00065 00067 virtual QString stackTraceString() { return QString::null; } 00068 00070 virtual const QStringList mathFunctions() const { return QStringList(); } 00072 virtual const QString mathFunctionDoc(const QString&) const { return QString::null; } 00074 virtual const QStringList fileExtensions() const { return QStringList(); }; 00076 const QString fileFilter() const; 00077 00078 ApplicationWindow *application(){return d_parent;}; 00079 00080 public slots: 00081 // global variables 00082 virtual bool setQObject(QObject*, const char*) { return false; } 00083 virtual bool setInt(int, const char*) { return false; } 00084 virtual bool setDouble(double, const char*) { return false; } 00085 00087 virtual void clear() {} 00089 virtual void stopExecution() {} 00091 virtual void startExecution() {} 00092 00094 void incref(); 00096 void decref(); 00097 00098 signals: 00100 void error(const QString & message, const QString & scriptName, int lineNumber); 00102 void print(const QString & output); 00103 00104 protected: 00106 bool d_initialized; 00108 ApplicationWindow *d_parent; 00109 00110 private: 00112 int d_refcount; 00113 }; 00114 00115 #endif