swift
Loading...
Searching...
No Matches
datalink.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_SHAREDSTATE_DATALINK_H
7#define SWIFT_MISC_SHAREDSTATE_DATALINK_H
8
9#include <QMetaClassInfo>
10#include <QMetaObject>
11#include <QObject>
12#include <QStringBuilder>
13
14#include "misc/promise.h"
16#include "misc/variant.h"
17
22
27#define SWIFT_SHARED_STATE_CHANNEL(ID) Q_CLASSINFO("SharedStateChannel", ID)
28
30{
31 class IDataLink;
32 class CPassiveMutator;
33 class CActiveMutator;
34 class CPassiveObserver;
35 class CActiveObserver;
36
41 class CDataLinkConnectionWatcher : public QObject
42 {
44
45 public:
47 bool isConnected() const { return m_connected; }
48
49 signals:
51 void connected();
52
55
56 private:
57 friend class IDataLink;
58 CDataLinkConnectionWatcher() = default;
59 void setStatus(bool connected);
60 bool m_connected = false;
61 };
62
68 {
69 public:
71 IDataLink();
72
74 virtual ~IDataLink() = 0;
75
77 CDataLinkConnectionWatcher *watcher() { return &m_watcher; }
78
81 virtual void publish(const CPassiveMutator *mutator) = 0;
82 virtual void publish(const CActiveMutator *mutator) = 0;
84
87 virtual void subscribe(const CPassiveObserver *observer) = 0;
88 virtual void subscribe(const CActiveObserver *observer) = 0;
90
91 protected:
93 void setConnectionStatus(bool connected) { m_watcher.setStatus(connected); }
94
96 static QString getChannelName(const QObject *object);
97
98 private:
100 };
101} // namespace swift::misc::shared_state
102
103Q_DECLARE_INTERFACE(swift::misc::shared_state::IDataLink, "swift::misc::shared_state::IDataLink")
104Q_DECLARE_METATYPE(swift::misc::CPromise<swift::misc::CVariant>)
105
106#endif // SWIFT_MISC_SHAREDSTATE_DATALINK_H
Extends CPassiveMutator with the ability to respond to requests.
Extends CPassiveObserver with the ability to send requests and receive replies.
Endpoint which can emit events to subscribers.
Endpoint which can subscribe to events emitted by CPassiveMutator.
Utilities for sharing state between multiple objects.
Definition application.h:48
Free functions in swift::misc.
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
#define SWIFT_MISC_EXPORT
Export a class or function from the library.