summaryrefslogtreecommitdiffstats
path: root/framework/src/fabric.h
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/fabric.h')
-rw-r--r--framework/src/fabric.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/framework/src/fabric.h b/framework/src/fabric.h
new file mode 100644
index 00000000..764c42b1
--- /dev/null
+++ b/framework/src/fabric.h
@@ -0,0 +1,70 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19#pragma once
20
21#include <QObject>
22#include <QVariant>
23#include <QVector>
24
25namespace Kube {
26/**
27 * The Fabric is a publish/subscribe message bus to interconnect components in kube.
28 *
29 * It provides a background mesh ("the fabric"), that interconnects various parts of kube.
30 * This is useful as it allows us to decouple functionality from the UI components, and keeps us from writing unnecessary API
31 * for visual components to pass through all necessary information for interaction.
32 */
33namespace Fabric {
34
35class Fabric : public QObject {
36 Q_OBJECT
37public:
38 Q_INVOKABLE void postMessage(const QString &id, const QVariantMap &);
39};
40
41/**
42 * A message handler.
43 *
44 * Can beinstantiated from QML like so:
45 * Listener {
46 * function onMessageReceived(msg) {
47 * ...do something
48 * }
49 * }
50 */
51class Listener : public QObject
52{
53 Q_OBJECT
54 Q_PROPERTY(QString filter MEMBER mFilter)
55
56public:
57 Listener(QObject *parent = 0);
58 virtual ~Listener();
59
60 virtual void notify(const QString &id, const QVariantMap &notification);
61
62signals:
63 void messageReceived(const QVariantMap &message);
64
65private:
66 QString mFilter;
67};
68
69}
70}