swift
hub.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2020 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_DBUS_HUB_H
7 #define SWIFT_MISC_SHAREDSTATE_DBUS_HUB_H
8 
9 #include <QFuture>
10 #include <QObject>
11 #include <QSharedPointer>
12 
13 #include "core/corefacadeconfig.h"
14 #include "misc/swiftmiscexport.h"
15 
17 #define SWIFT_MISC_HUB_INTERFACE "org.swift_project.misc.sharedstate.hub"
18 
20 #define SWIFT_MISC_HUB_PATH "/org/swift_project/hub"
21 
22 class QDBusConnection;
23 
24 namespace swift::misc
25 {
26  class CDBusServer;
27  class CIdentifier;
28 
29  namespace shared_state::dbus
30  {
31  class IDuplex;
32 
36  class SWIFT_MISC_EXPORT IHub : public QObject
37  {
38  Q_OBJECT
39  Q_CLASSINFO("D-Bus Interface", SWIFT_MISC_HUB_INTERFACE)
40 
41  public:
43  static IHub *create(bool proxy, CDBusServer *server, const QDBusConnection &connection,
44  const QString &service, QObject *parent = nullptr);
45 
47  virtual bool isConnected() const = 0;
48 
50  virtual std::pair<QSharedPointer<IDuplex>, QFuture<bool>> getDuplex(const CIdentifier &) = 0;
51 
52  public slots:
54  virtual bool openDuplex(const swift::misc::CIdentifier &client) = 0;
55 
57  virtual void closeDuplex(const swift::misc::CIdentifier &client) = 0;
58 
59  protected:
61  virtual QFuture<bool> openDuplexAsync(const CIdentifier &client) = 0;
62 
64  IHub(QObject *parent = nullptr);
65  };
66  } // namespace shared_state::dbus
67 } // namespace swift::misc
68 
69 #endif // SWIFT_MISC_SHAREDSTATE_DBUS_HUB_H
Custom DBusServer.
Definition: dbusserver.h:34
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition: identifier.h:29
Abstract interface for the hub in a star topology.
Definition: hub.h:37
virtual std::pair< QSharedPointer< IDuplex >, QFuture< bool > > getDuplex(const CIdentifier &)=0
Get a duplex object for the calling process.
virtual bool openDuplex(const swift::misc::CIdentifier &client)=0
Create a duplex object for the identified process.
virtual bool isConnected() const =0
Is connected?
virtual void closeDuplex(const swift::misc::CIdentifier &client)=0
Destroy the duplex object for the identified process.
virtual QFuture< bool > openDuplexAsync(const CIdentifier &client)=0
Create a duplex object and return status via future.
#define SWIFT_MISC_HUB_INTERFACE
DBus interface for sharedstate hub.
Definition: hub.h:17
Free functions in swift::misc.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.