swift
Loading...
Searching...
No Matches
hubproxy.cpp
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
7
9#include "misc/identifier.h"
11#include "misc/variantlist.h"
12
13namespace swift::misc::shared_state::dbus
14{
15 CHubProxy::CHubProxy(const QDBusConnection &connection, const QString &service, QObject *parent)
16 : IHub(parent), m_service(service)
17 {
18 m_interface =
20 m_interface->relayParentSignals();
21 }
22
23 bool CHubProxy::isConnected() const { return m_interface->isValid(); }
24
25 std::pair<QSharedPointer<IDuplex>, QFuture<bool>> CHubProxy::getDuplex(const CIdentifier &identifier)
26 {
27 auto duplex = QSharedPointer<CDuplexProxy>::create(m_interface->connection(), m_service, this);
28 connect(duplex.get(), &QObject::destroyed, this, [=, this] { closeDuplex(identifier); });
29 return std::make_pair(duplex, openDuplexAsync(identifier));
30 }
31
33 {
34 return m_interface->callDBusRet<bool>(QLatin1String("openDuplex"), client);
35 }
36
38 {
39 m_interface->callDBus(QLatin1String("closeDuplex"), client);
40 }
41
43 {
44 return m_interface->callDBusFuture<bool>(QLatin1String("openDuplex"), client);
45 }
46
48} // namespace swift::misc::shared_state::dbus
Used for hand written interface based on virtual methods.
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition identifier.h:29
static const CIdentifier & anonymous()
Returns an anonymous identifier, which is a valid identifier without name.
QFuture< bool > openDuplexAsync(const CIdentifier &client)
Create a duplex object for the identified process.
Definition hubproxy.cpp:42
CHubProxy(const QDBusConnection &connection, const QString &service, QObject *parent=nullptr)
Constructor.
Definition hubproxy.cpp:15
void closeDuplex(const swift::misc::CIdentifier &client)
Destroy the duplex object for the identified process.
Definition hubproxy.cpp:37
bool isConnected() const
Create a duplex object for the identified process.
Definition hubproxy.cpp:23
std::pair< QSharedPointer< IDuplex >, QFuture< bool > > getDuplex(const CIdentifier &)
Create a duplex object for the identified process.
Definition hubproxy.cpp:25
bool openDuplex(const swift::misc::CIdentifier &client)
Create a duplex object for the identified process.
Definition hubproxy.cpp:32
IHub(QObject *parent=nullptr)
Constructor.
Definition hub.cpp:15
#define SWIFT_MISC_HUB_INTERFACE
DBus interface for sharedstate hub.
Definition hub.h:17
#define SWIFT_MISC_HUB_PATH
DBus object path root for sharedstate hub.
Definition hub.h:20
QObject(QObject *parent)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void destroyed(QObject *obj)
QObject * parent() const const
QSharedPointer< T > create(Args &&... args)