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
ZMailbox.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: ZMailbox.h
6  * Created on: 1/2/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 ZMAILBOX_H
26 #define ZMAILBOX_H
27 
28 
29 #include <QMap>
30 #include "ZMessageQueue.h"
31 
32 namespace Zbl {
33 
34 class ZMailslot;
35 
52 class ZMailbox : public QObject
53 {
54  Q_OBJECT
55 
56  typedef QMap<QString, ZMailslot*> zMailslotMap;
57 
58 public:
59  explicit ZMailbox(QObject *parent = 0);
60 
65  static void registerType();
66 
71  Q_INVOKABLE void setOwnerName(const QString& name);
72 
77  Q_INVOKABLE const QString getOwnerName();
78 
83  Q_INVOKABLE QObject* mailslot(const QString& slotName);
84 
89  Q_INVOKABLE QObject* createMailslot(const QString& mailslot);
90 
98  Q_INVOKABLE void removeMailslot(const QString& mailslot);
99 
103  Q_INVOKABLE bool hasMailslot(const QString& mailslot);
104 
110  Q_INVOKABLE QStringList getSlotNames();
111 
112 signals:
113 
118  void mailslotCreated(const QString& owner, const QString& mailslot);
119 
124  void mailslotRemoved(const QString& owner, const QString& mailslot);
125 
126 
127 public slots:
128 
129 protected:
130 
135  zMailslotMap m_slots;
136 
141  QString m_ownerName;
142 
143 };
144 
145 
146 } // Zbl
147 
148 #endif // ZMAILBOX_H
Q_INVOKABLE QObject * createMailslot(const QString &mailslot)
creates and returns the ZMailslot object for the named mailslot.
Definition: ZMailbox.cpp:59
void mailslotCreated(const QString &owner, const QString &mailslot)
Sent when a mail slot has been created.
QMap< QString, ZMailslot * > zMailslotMap
Definition: ZMailbox.h:56
ZMailbox(QObject *parent=0)
Definition: ZMailbox.cpp:33
Q_INVOKABLE QStringList getSlotNames()
Returns an array containing the names of all mailslots in the mailbox.
Definition: ZMailbox.cpp:94
zMailslotMap m_slots
Mail slots mapped by name.
Definition: ZMailbox.h:135
A two-way messaging communication channel that supports buffered message streams to multiple end poin...
Definition: ZMailbox.h:52
Q_INVOKABLE const QString getOwnerName()
Get the name of the mailbox owner.
Definition: ZMailbox.cpp:49
Definition: ZAndGate.cpp:6
Q_INVOKABLE QObject * mailslot(const QString &slotName)
Returns the ZMailslot object for the named mailslot.
Definition: ZMailbox.cpp:54
Q_INVOKABLE void removeMailslot(const QString &mailslot)
removes the ZMailslot object for the named mailslot from the Mailbox.
Definition: ZMailbox.cpp:75
QString m_ownerName
Name of the mailbox owner.
Definition: ZMailbox.h:141
Q_INVOKABLE bool hasMailslot(const QString &mailslot)
Checks to see if a mailslot exists.
Definition: ZMailbox.cpp:89
static void registerType()
Register ZMailbox as a QML type.
Definition: ZMailbox.cpp:38
void mailslotRemoved(const QString &owner, const QString &mailslot)
Sent when a mail slot has been removed.
Q_INVOKABLE void setOwnerName(const QString &name)
Set the name of the mailbox owner.
Definition: ZMailbox.cpp:44