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
ZMailslot.h
Go to the documentation of this file.
1 /*
2  * Zuble - A run-time system for QML/Javascript applications
3  * Copyright (C) 2016 Bob Dinitto
4  *
5  * Filename: ZMailslot.h
6  * Created on: 1/3/2016
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 ZMAILSLOT_H
26 #define ZMAILSLOT_H
27 
28 #include <QObject>
29 #include <QVariant>
30 //#include <QJSValue>
31 #include "zglobal.h"
32 #include "ZMessageQueue.h"
33 #include "ZMap.h"
34 
35 namespace Zbl {
36 
50 class ZMailslot : public QObject
51 {
52  Q_OBJECT
53 public:
54  explicit ZMailslot(QObject *parent = 0);
55 
56  static void registerType();
57 
58 
63  Q_INVOKABLE void setSlotName(const QString& name);
64 
69  Q_INVOKABLE const QString getSlotName();
70 
79  Q_INVOKABLE void sendMessage(QVariant message);
80 
90  Q_INVOKABLE void postMessage(QVariant message);
91 
95  Q_INVOKABLE int messageCount();
96 
102  Q_INVOKABLE QVariant getMessage();
103 
110  Q_INVOKABLE QVariant peekMessage();
111 
116  Q_INVOKABLE void sendResponse(QVariant response);
117 
123  Q_INVOKABLE void postResponse(QVariant response);
124 
128  Q_INVOKABLE int responseCount();
129 
130 
136  Q_INVOKABLE QVariant getResponse();
137 
144  Q_INVOKABLE QVariant peekResponse();
145 
151  Q_INVOKABLE QObject* data();
152 
153 
154 signals:
155 
161  void messageAvailable(QString slotName);
162 
167  void responseAvailable(QString slotName);
168 
169 public slots:
170 
171 private slots:
172 
174 
176 
177 
178 protected:
179 
181 
185  QString m_slotName;
186 
191 
192 
197 
205 
206 };
207 
208 
209 } // Zbl
210 
211 #endif // ZMAILSLOT_H
ZBL_DECLARE_LOGGED_OBJECT QString m_slotName
Name of the mail slot.
Definition: ZMailslot.h:185
ZMap * m_data
Mailslot owner&#39;s user-defined data dictionary.
Definition: ZMailslot.h:204
Q_INVOKABLE int messageCount()
Returns the number of messages in the message queue.
Definition: ZMailslot.cpp:98
Q_INVOKABLE QVariant peekMessage()
Returns the next message from message queue without removing it from the queue.
Definition: ZMailslot.cpp:110
Q_INVOKABLE void postResponse(QVariant response)
Enqueues response immediately, then queues a defered responseAvailable signal to be sent later...
Definition: ZMailslot.cpp:124
void responseAvailable(QString slotName)
Sent when a response has been received from an endpoint.
Q_INVOKABLE void postMessage(QVariant message)
Enqueues message immediately, then posts a defered messageAvailable signal to the event queue to be s...
Definition: ZMailslot.cpp:72
Q_INVOKABLE int responseCount()
Returns the number of responses in the response queue.
Definition: ZMailslot.cpp:79
A Javascript dictionary object.
Definition: ZMap.h:40
void messageAvailable(QString slotName)
Sent when a message has been placed into an endpoint&#39;s message queue.
#define ZBL_DECLARE_LOGGED_OBJECT
Definition: zglobal.h:94
ZMailslot(QObject *parent=0)
Definition: ZMailslot.cpp:33
static void registerType()
Definition: ZMailslot.cpp:45
A message queue that decouples sending and processing of messages.
Definition: ZMessageQueue.h:54
Q_INVOKABLE QObject * data()
returns a ZMap dictionary object that can be used by mailslot client to store parameters. Use of the dictionary is user defined.
Definition: ZMailslot.cpp:131
Definition: ZAndGate.cpp:6
Q_INVOKABLE QVariant getResponse()
Removes next response from response queue and returns it.
Definition: ZMailslot.cpp:84
void onMessageQueueAvailable()
Definition: ZMailslot.cpp:138
Q_INVOKABLE void sendMessage(QVariant message)
Enqueues message and sends messageAvailable signal immediately.
Definition: ZMailslot.cpp:65
Q_INVOKABLE QVariant getMessage()
Removes next message from message queue and returns it.
Definition: ZMailslot.cpp:103
ZMessageQueue m_responseQueue
Responses sent from endpoint to mailslot owner.
Definition: ZMailslot.h:196
A two-way buffered message stream with attached user-defined data cache.
Definition: ZMailslot.h:50
ZMessageQueue m_messageQueue
Messages sent from mailslot owner to endpoint.
Definition: ZMailslot.h:190
Q_INVOKABLE void sendResponse(QVariant response)
Enqueues response and sends responseAvailable signal immediately.
Definition: ZMailslot.cpp:117
void onResponseQueueAvailable()
Definition: ZMailslot.cpp:143
Q_INVOKABLE void setSlotName(const QString &name)
Set the name of the mailslot.
Definition: ZMailslot.cpp:53
Q_INVOKABLE QVariant peekResponse()
Returns the next response from response queue without removing it from the queue. ...
Definition: ZMailslot.cpp:91
Q_INVOKABLE const QString getSlotName()
Get the name of the mailslot.
Definition: ZMailslot.cpp:60