WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
ZScriptWorker.h
Go to the documentation of this file.
1 /*
2 * Zuble - A run-time system for QML/Javascript applications
3 * Copyright (C) 2013, 2014 Bob Dinitto
4 *
5 * Filename: ZScriptWorker.h
6 * Created on: 11/9/2014
7 * Author: Bob Dinitto
8 *
9 * Zuble is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 */
24 
25 #ifndef ZSCRIPTWORKER_H
26 #define ZSCRIPTWORKER_H
27 
28 #include <QObject>
29 #include <QJSEngine>
30 #include <QVariant>
31 #include <QRunnable>
32 #include "zblcore_global.h"
33 
34 namespace Zbl
35 {
36 
37 class ZblApp;
38 class ZblJsonHelper;
39 class ZScriptThread;
40 
51 class ZBLCORESHARED_EXPORT ZScriptWorker : public QObject
52 {
53  friend class ZScriptThread;
54 
55 
56  Q_OBJECT
57 public:
58  explicit ZScriptWorker(ZScriptThread* container = nullptr, QObject* parent = nullptr);
59 
60  virtual ~ZScriptWorker();
61 
62 signals:
63 
90  void execComplete(qulonglong requestID, QString result, QString userData);
91 
92 
93 public slots:
94 
104  void execScript(qulonglong requestID, const QString& script, QString userData = QString());
105 
109  void onStarted();
110 
111 protected:
112 
113  void initGlobalSpace();
114 
119  QJSEngine* m_engine;
120 
125  QString m_script;
126 
127 
132  QJSValue m_result;
133 
141  QJSValue m_error;
142 
148 
155 
156 };
157 
158 } // Zbl
159 
160 #endif // ZSCRIPTWORKER_H
#define ZBLCORESHARED_EXPORT
ZblApp * m_app
An object to represent the running Zuble application.
ZblJsonHelper * m_json
An object to perform QJSValue/JSON data conversions on the fly.
QJSValue m_error
A template javascript Error object.
QString m_script
The most recent script that was executed.
A thread class to support Zuble&#39;s background Javascript processing.
Definition: ZScriptThread.h:62
A class for executing javascript programs in a background worker thread.
Definition: ZScriptWorker.h:51
QJSValue m_result
Result returned by the most recent script execution.
Definition: ZAndGate.cpp:6
Converts objects between JSON and QJSValue domains for a specific QJSEngine instance.
Definition: ZblJsonHelper.h:17
The primary QML API to the Zuble plugin library. Zuble applications access this object through the ja...
Definition: ZblApp.h:81
QJSEngine * m_engine
The javascript engine for background processing.