swift
datalinklocal.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_DATALINKLOCAL_H
7 #define SWIFT_MISC_SHAREDSTATE_DATALINKLOCAL_H
8 
9 #include <QFuture>
10 #include <QMutex>
11 #include <QObject>
12 
14 #include "misc/swiftmiscexport.h"
15 #include "misc/variant.h"
16 
18 {
23  class SWIFT_MISC_EXPORT CDataLinkLocal : public QObject, public IDataLink
24  {
25  Q_OBJECT
27 
28  public:
30  CDataLinkLocal(QObject *parent = nullptr);
31 
33  virtual ~CDataLinkLocal() override;
34 
35  virtual void publish(const CPassiveMutator *mutator) override;
36  virtual void publish(const CActiveMutator *mutator) override;
37  virtual void subscribe(const CPassiveObserver *observer) override;
38  virtual void subscribe(const CActiveObserver *observer) override;
39 
40  private:
41  struct Channel
42  {
43  QWeakPointer<const CActiveMutator> activeMutator;
44  QVector<QWeakPointer<const CPassiveObserver>> passiveObservers;
45  };
46 
47  void dispatchEvent(const CVariant &param, const QString &channel);
48  QFuture<CVariant> handleRequest(const CVariant &param, const QString &channel);
49  Channel &getChannel(const QString &name);
50  Channel &getChannel(const QObject *object);
51 
52  QMap<QString, Channel> m_channels;
53  mutable QRecursiveMutex m_channelsMutex;
54  };
55 } // namespace swift::misc::shared_state
56 
57 #endif // SWIFT_MISC_SHAREDSTATE_DATALINKLOCAL_H
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Definition: variant.h:66
Extends CPassiveMutator with the ability to respond to requests.
Definition: activemutator.h:25
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
#define SWIFT_MISC_EXPORT
Export a class or function from the library.