scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ScriptingEnv.h
Go to the documentation of this file.
1 
13 
31 #ifndef SCRIPTINGENV_H
32 #define SCRIPTINGENV_H
33 
34 #include <QVariant>
35 #include <QString>
36 #include <QStringList>
37 #include <QObject>
38 #include <QStringList>
39 #include <QEvent>
40 
41 #include "customevents.h"
42 
43 class ApplicationWindow;
44 class Script;
45 
47 
52 class ScriptingEnv : public QObject
53 {
54  Q_OBJECT
55 
56  public:
57  ScriptingEnv(ApplicationWindow *parent, const char *langName);
59  virtual bool initialize() { return true; };
61  bool initialized() const { return d_initialized; }
63  virtual bool isRunning() const { return false; }
64 
66  virtual Script *newScript(const QString&, QObject*, const QString&)=0;
67 
69  virtual QString stackTraceString() { return {}; }
70 
72  virtual const QStringList mathFunctions() const { return QStringList(); }
74  virtual const QString mathFunctionDoc(const QString&) const { return {}; }
76  virtual const QStringList fileExtensions() const { return QStringList(); };
78  const QString fileFilter() const;
79 
80  virtual void redirectStdIO() {}
81 
82 // virtual QSyntaxHighlighter syntaxHighlighter(QTextEdit *textEdit) const;
83 
84  public slots:
85  // global variables
86  virtual bool setQObject(QObject*, const char*) { return false; }
87  virtual bool setInt(int, const char*) { return false; }
88  virtual bool setDouble(double, const char*) { return false; }
89 
91  virtual void clear() {}
93  virtual void stopExecution() {}
95  virtual void startExecution() {}
96 
98  void incref();
100  void decref();
101 
102  signals:
104  void error(const QString & message, const QString & scriptName, int lineNumber);
106  void print(const QString & output);
107 
108  protected:
113 
114  private:
117 };
118 
119 #endif
ScriptingEnv::setQObject
virtual bool setQObject(QObject *, const char *)
Definition: ScriptingEnv.h:86
ScriptingEnv::newScript
virtual Script * newScript(const QString &, QObject *, const QString &)=0
Instantiate the Script subclass matching the ScriptEnv subclass.
ScriptingEnv::incref
void incref()
Increase the reference count. This should only be called by scripted and Script to avoid memory leaks...
Definition: ScriptingEnv.cpp:60
ScriptingEnv::initialize
virtual bool initialize()
Part of the initialization is deferred from the constructor until after the signals have been connect...
Definition: ScriptingEnv.h:59
ScriptingEnv::fileExtensions
virtual const QStringList fileExtensions() const
Return a list of file extensions commonly used for this language.
Definition: ScriptingEnv.h:76
ScriptingEnv::decref
void decref()
Decrease the reference count. This should only be called by scripted and Script to avoid segfaults.
Definition: ScriptingEnv.cpp:65
ScriptingEnv::stopExecution
virtual void stopExecution()
If the implementation supports asynchronuos execution, deactivate it.
Definition: ScriptingEnv.h:93
ScriptingEnv::fileFilter
const QString fileFilter() const
Construct a filter expression from fileExtension(), suitable for QFileDialog.
Definition: ScriptingEnv.cpp:51
ScriptingEnv::stackTraceString
virtual QString stackTraceString()
If an exception / error occured, return a nicely formated stack backtrace.
Definition: ScriptingEnv.h:69
ScriptingEnv::isRunning
virtual bool isRunning() const
whether asynchronuous execution is enabled (if supported by the implementation)
Definition: ScriptingEnv.h:63
ScriptingEnv::d_parent
ApplicationWindow * d_parent
the context in which we are running
Definition: ScriptingEnv.h:112
ScriptingEnv::initialized
bool initialized() const
initialization of the interpreter may fail; or there could be other errors setting up the environment
Definition: ScriptingEnv.h:61
ScriptingEnv::setDouble
virtual bool setDouble(double, const char *)
Definition: ScriptingEnv.h:88
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:91
ScriptingEnv::d_initialized
bool d_initialized
whether the interpreter has been successfully initialized
Definition: ScriptingEnv.h:110
ScriptingEnv::redirectStdIO
virtual void redirectStdIO()
Definition: ScriptingEnv.h:80
customevents.h
ScriptingEnv
An interpreter for evaluating scripting code. Abstract.
Definition: ScriptingEnv.h:53
ScriptingEnv::d_refcount
int d_refcount
the reference counter
Definition: ScriptingEnv.h:116
ApplicationWindow
SciDAVis's main window.
Definition: ApplicationWindow.h:122
Script
A chunk of scripting code. Abstract.
Definition: Script.h:53
ScriptingEnv::print
void print(const QString &output)
output that is not handled by a Script
ScriptingEnv::ScriptingEnv
ScriptingEnv(ApplicationWindow *parent, const char *langName)
Definition: ScriptingEnv.cpp:43
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:72
ScriptingEnv::mathFunctionDoc
virtual const QString mathFunctionDoc(const QString &) const
Return a documentation string for the given mathematical function.
Definition: ScriptingEnv.h:74
ScriptingEnv::setInt
virtual bool setInt(int, const char *)
Definition: ScriptingEnv.h:87
ScriptingEnv::startExecution
virtual void startExecution()
If the implementation supports asynchronuos execution, activate it.
Definition: ScriptingEnv.h:95