ScriptingEnv.h
Go to the documentation of this file.
/***************************************************************************
File : ScriptingEnv.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2006 by Ion Vasilief, Knut Franke
Email (use @ for *) : ion_vasilief*yahoo.fr
Description : Scripting abstraction layer
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef SCRIPTINGENV_H
#define SCRIPTINGENV_H
#include <QVariant>
#include <QString>
#include <QStringList>
#include <QObject>
#include <QStringList>
#include <QEvent>
#include "customevents.h"
class ApplicationWindow;
class Script;
class ScriptingEnv : public QObject
{
Q_OBJECT
public:
ScriptingEnv(ApplicationWindow *parent, const char *langName);
virtual bool initialize() { return true; };
bool initialized() const { return d_initialized; }
virtual bool isRunning() const { return false; }
virtual Script *newScript(const QString&, QObject*, const QString&) { return 0; }
virtual QString stackTraceString() { return QString::null; }
virtual const QStringList mathFunctions() const { return QStringList(); }
virtual const QString mathFunctionDoc(const QString&) const { return QString::null; }
virtual const QStringList fileExtensions() const { return QStringList(); };
const QString fileFilter() const;
ApplicationWindow *application(){return d_parent;};
public slots:
// global variables
virtual bool setQObject(QObject*, const char*) { return false; }
virtual bool setInt(int, const char*) { return false; }
virtual bool setDouble(double, const char*) { return false; }
virtual void clear() {}
virtual void stopExecution() {}
virtual void startExecution() {}
void incref();
void decref();
signals:
void error(const QString & message, const QString & scriptName, int lineNumber);
void print(const QString & output);
protected:
bool d_initialized;
ApplicationWindow *d_parent;
private:
int d_refcount;
};
#endif
ScriptingEnv::application
ApplicationWindow * application()
Definition: ScriptingEnv.h:78
ScriptingEnv::incref
void incref()
Increase the reference count. This should only be called by scripted and Script to avoid memory leaks...
Definition: ScriptingEnv.cpp:59
ScriptingEnv::error
void error(const QString &message, const QString &scriptName, int lineNumber)
signal an error condition / exception
ScriptingEnv::clear
virtual void clear()
Clear the global environment. What exactly happens depends on the implementation. ...
Definition: ScriptingEnv.h:87
ScriptingEnv::fileExtensions
virtual const QStringList fileExtensions() const
Return a list of file extensions commonly used for this language.
Definition: ScriptingEnv.h:74
ScriptingEnv::setDouble
virtual bool setDouble(double, const char *)
Definition: ScriptingEnv.h:84
ScriptingEnv::mathFunctions
virtual const QStringList mathFunctions() const
Return a list of supported mathematical functions. These should be imported into the global namespace...
Definition: ScriptingEnv.h:70
customevents.h
ScriptingEnv
An interpreter for evaluating scripting code. Abstract.
Definition: ScriptingEnv.h:50
ScriptingEnv::setInt
virtual bool setInt(int, const char *)
Definition: ScriptingEnv.h:83
ScriptingEnv::d_parent
ApplicationWindow * d_parent
the context in which we are running
Definition: ScriptingEnv.h:108
ScriptingEnv::stackTraceString
virtual QString stackTraceString()
If an exception / error occured, return a nicely formated stack backtrace.
Definition: ScriptingEnv.h:67
ScriptingEnv::isRunning
virtual bool isRunning() const
whether asynchronuous execution is enabled (if supported by the implementation)
Definition: ScriptingEnv.h:61
ScriptingEnv::fileFilter
const QString fileFilter() const
Construct a filter expression from fileExtension(), suitable for QFileDialog.
Definition: ScriptingEnv.cpp:50
ScriptingEnv::d_refcount
int d_refcount
the reference counter
Definition: ScriptingEnv.h:112
Script
A chunk of scripting code. Abstract.
Definition: Script.h:50
ApplicationWindow
QtiPlot&#39;s main window.
Definition: ApplicationWindow.h:133
ScriptingEnv::ScriptingEnv
ScriptingEnv(ApplicationWindow *parent, const char *langName)
Definition: ScriptingEnv.cpp:43
ScriptingEnv::d_initialized
bool d_initialized
whether the interpreter has been successfully initialized
Definition: ScriptingEnv.h:106
ScriptingEnv::decref
void decref()
Decrease the reference count. This should only be called by scripted and Script to avoid segfaults...
Definition: ScriptingEnv.cpp:64
ScriptingEnv::print
void print(const QString &output)
output that is not handled by a Script
ScriptingEnv::newScript
virtual Script * newScript(const QString &, QObject *, const QString &)
Instantiate the Script subclass matching the ScriptEnv subclass.
Definition: ScriptingEnv.h:64
ScriptingEnv::initialize
virtual bool initialize()
Part of the initialization is deferred from the constructor until after the signals have been connect...
Definition: ScriptingEnv.h:57
ScriptingEnv::setQObject
virtual bool setQObject(QObject *, const char *)
Definition: ScriptingEnv.h:82
ScriptingEnv::mathFunctionDoc
virtual const QString mathFunctionDoc(const QString &) const
Return a documentation string for the given mathematical function.
Definition: ScriptingEnv.h:72
ScriptingEnv::startExecution
virtual void startExecution()
If the implementation supports asynchronuos execution, activate it.
Definition: ScriptingEnv.h:91
ScriptingEnv::initialized
bool initialized() const
initialization of the interpreter may fail; or there could be other errors setting up the environment...
Definition: ScriptingEnv.h:59
ScriptingEnv::stopExecution
virtual void stopExecution()
If the implementation supports asynchronuos execution, deactivate it.
Definition: ScriptingEnv.h:89