refactor: clang format line length

This commit is contained in:
Lars Toenning
2024-11-16 19:27:30 +01:00
parent c7779e1461
commit 1a0b2a8c5f
1352 changed files with 25994 additions and 26603 deletions

View File

@@ -7,8 +7,5 @@
namespace swift::misc::shared_state
{
QFuture<CVariant> CActiveMutator::handleRequest(const CVariant &param) const
{
return m_requestHandler(param);
}
QFuture<CVariant> CActiveMutator::handleRequest(const CVariant &param) const { return m_requestHandler(param); }
} // namespace swift::misc::shared_state

View File

@@ -27,8 +27,10 @@ namespace swift::misc::shared_state
friend QSharedPointer<CActiveMutator>;
template <typename T, typename F>
CActiveMutator(T *parent, F requestHandler) : CPassiveMutator(parent),
m_requestHandler([=](const CVariant &param) { return private_ns::invokeMethod(parent, requestHandler, param); })
CActiveMutator(T *parent, F requestHandler)
: CPassiveMutator(parent), m_requestHandler([=](const CVariant &param) {
return private_ns::invokeMethod(parent, requestHandler, param);
})
{}
public:
@@ -43,7 +45,10 @@ namespace swift::misc::shared_state
QFuture<CVariant> handleRequest(const CVariant &param) const;
//! Get a QWeakPointer pointing to this object.
QWeakPointer<const CActiveMutator> weakRef() const { return qSharedPointerCast<const CActiveMutator>(CPassiveMutator::weakRef()); }
QWeakPointer<const CActiveMutator> weakRef() const
{
return qSharedPointerCast<const CActiveMutator>(CPassiveMutator::weakRef());
}
private:
const std::function<QFuture<CVariant>(const CVariant &)> m_requestHandler;

View File

@@ -18,9 +18,10 @@ namespace swift::misc::shared_state
{
CPromise<CVariant> promise;
emit requestPosted(param, promise);
doAfter(promise.future(), this, [callback = std::move(callback), weakRef = weakRef()](const QFuture<CVariant> &reply) {
const auto lock = weakRef.lock();
if (lock) { callback(reply.result()); }
});
doAfter(promise.future(), this,
[callback = std::move(callback), weakRef = weakRef()](const QFuture<CVariant> &reply) {
const auto lock = weakRef.lock();
if (lock) { callback(reply.result()); }
});
}
} // namespace swift::misc::shared_state

View File

@@ -45,7 +45,10 @@ namespace swift::misc::shared_state
void requestAsync(const CVariant &param, std::function<void(const CVariant &)> callback);
//! Get a QWeakPointer pointing to this object.
QWeakPointer<const CActiveObserver> weakRef() const { return qSharedPointerCast<const CActiveObserver>(CPassiveObserver::weakRef()); }
QWeakPointer<const CActiveObserver> weakRef() const
{
return qSharedPointerCast<const CActiveObserver>(CPassiveObserver::weakRef());
}
signals:
//! Emitted by request and requestAsync.

View File

@@ -22,10 +22,7 @@ namespace swift::misc::shared_state
IDataLink::~IDataLink() = default;
IDataLink::IDataLink()
{
qRegisterMetaType<CPromise<CVariant>>();
}
IDataLink::IDataLink() { qRegisterMetaType<CPromise<CVariant>>(); }
QString IDataLink::getChannelName(const QObject *object)
{

View File

@@ -25,15 +25,9 @@ namespace swift::misc::shared_state
m_watchTimer.setInterval(1000);
}
CDataLinkDBus::~CDataLinkDBus()
{
setConnectionStatus(false);
}
CDataLinkDBus::~CDataLinkDBus() { setConnectionStatus(false); }
void CDataLinkDBus::overrideIdentifier(const CIdentifier &id)
{
m_identifier = id;
}
void CDataLinkDBus::overrideIdentifier(const CIdentifier &id) { m_identifier = id; }
void CDataLinkDBus::initializeLocal(CDBusServer *server)
{
@@ -100,19 +94,13 @@ namespace swift::misc::shared_state
for (const auto &observerWeak : std::as_const(getChannel(channel).passiveObservers))
{
auto observer = observerWeak.lock();
if (observer && observer->eventSubscription().matches(param))
{
observer->handleEvent(param);
}
if (observer && observer->eventSubscription().matches(param)) { observer->handleEvent(param); }
}
}
void CDataLinkDBus::announceLocalSubscriptions()
{
for (const auto &channel : getChannelNames())
{
announceLocalSubscriptions(channel);
}
for (const auto &channel : getChannelNames()) { announceLocalSubscriptions(channel); }
}
void CDataLinkDBus::announceLocalSubscriptions(const QString &channel)
@@ -154,9 +142,8 @@ namespace swift::misc::shared_state
void CDataLinkDBus::publish(const CPassiveMutator *mutator)
{
connect(mutator, &CPassiveMutator::eventPosted, this, [this, channel = getChannelName(mutator)](const CVariant &param) {
handleLocalEvent(channel, param);
});
connect(mutator, &CPassiveMutator::eventPosted, this,
[this, channel = getChannelName(mutator)](const CVariant &param) { handleLocalEvent(channel, param); });
}
void CDataLinkDBus::publish(const CActiveMutator *mutator)
@@ -167,10 +154,7 @@ namespace swift::misc::shared_state
Q_ASSERT_X(!channel.activeMutator, Q_FUNC_INFO, "Tried to publish two active mutators on one channel");
channel.activeMutator = mutator->weakRef();
if (m_duplex)
{
m_duplex->advertise(getChannelName(mutator));
}
if (m_duplex) { m_duplex->advertise(getChannelName(mutator)); }
connect(mutator, &QObject::destroyed, this, [this, channel = getChannelName(mutator)] {
if (m_duplex) { m_duplex->withdraw(channel); }
});
@@ -192,9 +176,10 @@ namespace swift::misc::shared_state
{
subscribe(static_cast<const CPassiveObserver *>(observer));
connect(observer, &CActiveObserver::requestPosted, this, [this, channel = getChannelName(observer)](const CVariant &param, CPromise<CVariant> reply) {
reply.chainResult(handleLocalRequest(channel, param));
});
connect(observer, &CActiveObserver::requestPosted, this,
[this, channel = getChannelName(observer)](const CVariant &param, CPromise<CVariant> reply) {
reply.chainResult(handleLocalRequest(channel, param));
});
}
QStringList CDataLinkDBus::getChannelNames() const

View File

@@ -11,19 +11,14 @@
namespace swift::misc::shared_state
{
CDataLinkLocal::CDataLinkLocal(QObject *parent) : QObject(parent)
{
setConnectionStatus(true);
}
CDataLinkLocal::CDataLinkLocal(QObject *parent) : QObject(parent) { setConnectionStatus(true); }
CDataLinkLocal::~CDataLinkLocal()
{
setConnectionStatus(false);
}
CDataLinkLocal::~CDataLinkLocal() { setConnectionStatus(false); }
void CDataLinkLocal::publish(const CPassiveMutator *mutator)
{
connect(mutator, &CPassiveMutator::eventPosted, this, [this, channel = getChannelName(mutator)](const CVariant &param) { dispatchEvent(param, channel); });
connect(mutator, &CPassiveMutator::eventPosted, this,
[this, channel = getChannelName(mutator)](const CVariant &param) { dispatchEvent(param, channel); });
}
void CDataLinkLocal::publish(const CActiveMutator *mutator)
@@ -44,9 +39,10 @@ namespace swift::misc::shared_state
{
subscribe(static_cast<const CPassiveObserver *>(observer));
connect(observer, &CActiveObserver::requestPosted, this, [this, channel = getChannelName(observer)](const CVariant &param, CPromise<CVariant> reply) {
reply.chainResult(handleRequest(param, channel));
});
connect(observer, &CActiveObserver::requestPosted, this,
[this, channel = getChannelName(observer)](const CVariant &param, CPromise<CVariant> reply) {
reply.chainResult(handleRequest(param, channel));
});
}
void CDataLinkLocal::dispatchEvent(const CVariant &param, const QString &channel)
@@ -54,10 +50,7 @@ namespace swift::misc::shared_state
for (const auto &observerWeak : std::as_const(getChannel(channel).passiveObservers))
{
auto observer = observerWeak.lock();
if (observer && observer->eventSubscription().matches(param))
{
observer->handleEvent(param);
}
if (observer && observer->eventSubscription().matches(param)) { observer->handleEvent(param); }
}
}

View File

@@ -41,8 +41,5 @@ namespace swift::misc::shared_state::dbus
m_receivedRequests.erase(it);
}
quint32 IDuplex::getToken()
{
return m_token++;
}
quint32 IDuplex::getToken() { return m_token++; }
} // namespace swift::misc::shared_state::dbus

View File

@@ -74,7 +74,8 @@ namespace swift::misc
void peerSubscriptionsReceived(const QString &channel, const swift::misc::CVariantList &filters);
//! Server has submitted a request to be handled by the client.
void requestReceived(const QString &channel, const swift::misc::CVariant &param, quint32 token, QPrivateSignal);
void requestReceived(const QString &channel, const swift::misc::CVariant &param, quint32 token,
QPrivateSignal);
//! \private Server has relayed a reply to the client's request.
void replyReceived(const QString &channel, const swift::misc::CVariant &param, quint32 token);

View File

@@ -13,7 +13,8 @@
namespace swift::misc::shared_state::dbus
{
CDuplex::CDuplex(CHub *hub, const CIdentifier &client, CDBusServer *server, QObject *parent) : IDuplex(parent), m_hub(hub)
CDuplex::CDuplex(CHub *hub, const CIdentifier &client, CDBusServer *server, QObject *parent)
: IDuplex(parent), m_hub(hub)
{
if (server) { server->addObject(client.toDBusObjectPath(SWIFT_MISC_DUPLEX_PATH_ROOT), this); }
}
@@ -61,10 +62,7 @@ namespace swift::misc::shared_state::dbus
channels.unite(subscriptions);
}
}
for (const auto &channel : channels)
{
requestPeerSubscriptions(channel);
}
for (const auto &channel : channels) { requestPeerSubscriptions(channel); }
}
void CDuplex::requestPeerSubscriptions(const QString &channel)
@@ -84,21 +82,16 @@ namespace swift::misc::shared_state::dbus
{
if (handler != this && handler->m_handlingChannels.contains(channel))
{
doAfter(handler->receiveRequest(channel, param), this, [this, channel, token](QFuture<CVariant> future) {
emit this->replyReceived(channel, future.result(), token);
});
doAfter(handler->receiveRequest(channel, param), this,
[this, channel, token](QFuture<CVariant> future) {
emit this->replyReceived(channel, future.result(), token);
});
return;
}
}
}
void CDuplex::advertise(const QString &channel)
{
m_handlingChannels.insert(channel);
}
void CDuplex::advertise(const QString &channel) { m_handlingChannels.insert(channel); }
void CDuplex::withdraw(const QString &channel)
{
m_handlingChannels.remove(channel);
}
void CDuplex::withdraw(const QString &channel) { m_handlingChannels.remove(channel); }
} // namespace swift::misc::shared_state::dbus

View File

@@ -20,7 +20,8 @@ namespace swift::misc
class CHub;
/*!
* Server side implementation of IDuplex. Receives messages from clients and forwards them to other clients via the CHub.
* Server side implementation of IDuplex. Receives messages from clients and forwards them to other clients via
* the CHub.
*/
class SWIFT_MISC_EXPORT CDuplex final : public IDuplex
{
@@ -48,7 +49,8 @@ namespace swift::misc
virtual void requestPeerSubscriptions() override;
//! \copydoc swift::misc::shared_state::dbus::IDuplex::submitRequest
virtual void submitRequest(const QString &channel, const swift::misc::CVariant &param, quint32 token) override;
virtual void submitRequest(const QString &channel, const swift::misc::CVariant &param,
quint32 token) override;
//! \copydoc swift::misc::shared_state::dbus::IDuplex::advertise
virtual void advertise(const QString &channel) override;

View File

@@ -11,7 +11,8 @@
namespace swift::misc::shared_state::dbus
{
CDuplexProxy::CDuplexProxy(const QDBusConnection &connection, const QString &service, QObject *parent) : IDuplex(parent)
CDuplexProxy::CDuplexProxy(const QDBusConnection &connection, const QString &service, QObject *parent)
: IDuplex(parent)
{
const QString path = CIdentifier::anonymous().toDBusObjectPath(SWIFT_MISC_DUPLEX_PATH_ROOT);
m_interface = new CGenericDBusInterface(service, path, SWIFT_MISC_DUPLEX_INTERFACE, connection, this);
@@ -28,10 +29,7 @@ namespace swift::misc::shared_state::dbus
m_interface->callDBus(QLatin1String("setSubscription"), channel, filters);
}
void CDuplexProxy::requestPeerSubscriptions()
{
m_interface->callDBus(QLatin1String("requestPeerSubscriptions"));
}
void CDuplexProxy::requestPeerSubscriptions() { m_interface->callDBus(QLatin1String("requestPeerSubscriptions")); }
void CDuplexProxy::submitRequest(const QString &channel, const CVariant &param, quint32 token)
{
@@ -43,13 +41,7 @@ namespace swift::misc::shared_state::dbus
m_interface->callDBus(QLatin1String("reply"), param, token);
}
void CDuplexProxy::advertise(const QString &channel)
{
m_interface->callDBus(QLatin1String("advertise"), channel);
}
void CDuplexProxy::advertise(const QString &channel) { m_interface->callDBus(QLatin1String("advertise"), channel); }
void CDuplexProxy::withdraw(const QString &channel)
{
m_interface->callDBus(QLatin1String("withdraw"), channel);
}
void CDuplexProxy::withdraw(const QString &channel) { m_interface->callDBus(QLatin1String("withdraw"), channel); }
} // namespace swift::misc::shared_state::dbus

View File

@@ -40,7 +40,8 @@ namespace swift::misc
virtual void requestPeerSubscriptions() override;
//! \copydoc swift::misc::shared_state::dbus::IDuplex::submitRequest
virtual void submitRequest(const QString &channel, const swift::misc::CVariant &param, quint32 token) override;
virtual void submitRequest(const QString &channel, const swift::misc::CVariant &param,
quint32 token) override;
//! \copydoc swift::misc::shared_state::dbus::IDuplex::reply
virtual void reply(const swift::misc::CVariant &param, quint32 token) override;

View File

@@ -12,10 +12,10 @@
namespace swift::misc::shared_state::dbus
{
IHub::IHub(QObject *parent) : QObject(parent)
{}
IHub::IHub(QObject *parent) : QObject(parent) {}
IHub *IHub::create(bool proxy, CDBusServer *server, const QDBusConnection &connection, const QString &service, QObject *parent)
IHub *IHub::create(bool proxy, CDBusServer *server, const QDBusConnection &connection, const QString &service,
QObject *parent)
{
if (proxy) { return new CHubProxy(connection, service, parent); }
else { return new CHub(server, parent); }

View File

@@ -40,7 +40,8 @@ namespace swift::misc
public:
//! Construct a new hub.
static IHub *create(bool proxy, CDBusServer *server, const QDBusConnection &connection, const QString &service, QObject *parent = nullptr);
static IHub *create(bool proxy, CDBusServer *server, const QDBusConnection &connection,
const QString &service, QObject *parent = nullptr);
//! Is connected?
virtual bool isConnected() const = 0;

View File

@@ -12,16 +12,15 @@
namespace swift::misc::shared_state::dbus
{
CHubProxy::CHubProxy(const QDBusConnection &connection, const QString &service, QObject *parent) : IHub(parent), m_service(service)
CHubProxy::CHubProxy(const QDBusConnection &connection, const QString &service, QObject *parent)
: IHub(parent), m_service(service)
{
m_interface = new CGenericDBusInterface(service, SWIFT_MISC_HUB_PATH, SWIFT_MISC_HUB_INTERFACE, connection, this);
m_interface =
new CGenericDBusInterface(service, SWIFT_MISC_HUB_PATH, SWIFT_MISC_HUB_INTERFACE, connection, this);
m_interface->relayParentSignals();
}
bool CHubProxy::isConnected() const
{
return m_interface->isValid();
}
bool CHubProxy::isConnected() const { return m_interface->isValid(); }
std::pair<QSharedPointer<IDuplex>, QFuture<bool>> CHubProxy::getDuplex(const CIdentifier &identifier)
{
@@ -45,8 +44,5 @@ namespace swift::misc::shared_state::dbus
return m_interface->callDBusFuture<bool>(QLatin1String("openDuplex"), client);
}
CHubProxy::~CHubProxy()
{
closeDuplex(CIdentifier::anonymous());
}
CHubProxy::~CHubProxy() { closeDuplex(CIdentifier::anonymous()); }
} // namespace swift::misc::shared_state::dbus

View File

@@ -26,8 +26,5 @@ namespace swift::misc::shared_state
return CVariant::from(copy);
}
void CGenericListJournal::handleEvent(const CVariant &param)
{
m_value.push_back(param);
}
void CGenericListJournal::handleEvent(const CVariant &param) { m_value.push_back(param); }
} // namespace swift::misc::shared_state

View File

@@ -9,13 +9,7 @@
namespace swift::misc::shared_state
{
void CGenericListMutator::initialize(IDataLink *dataLink)
{
dataLink->publish(m_mutator.data());
}
void CGenericListMutator::initialize(IDataLink *dataLink) { dataLink->publish(m_mutator.data()); }
void CGenericListMutator::addElement(const CVariant &value)
{
m_mutator->postEvent(value);
}
void CGenericListMutator::addElement(const CVariant &value) { m_mutator->postEvent(value); }
} // namespace swift::misc::shared_state

View File

@@ -42,9 +42,8 @@ namespace swift::misc::shared_state
int CGenericListObserver::cleanValues()
{
QMutexLocker lock(&m_listMutex);
return m_list.removeIf([filter = m_observer->eventSubscription()](const CVariant &value) {
return !value.matches(filter);
});
return m_list.removeIf(
[filter = m_observer->eventSubscription()](const CVariant &value) { return !value.matches(filter); });
}
void CGenericListObserver::handleEvent(const CVariant &param)

View File

@@ -86,8 +86,14 @@ namespace swift::misc::shared_state
virtual void onElementsReplaced(const T &values) = 0;
private:
virtual void onGenericElementAdded(const CVariant &value) override final { onElementAdded(value.to<typename T::value_type>()); }
virtual void onGenericElementsReplaced(const CVariantList &values) override final { onElementsReplaced(values.to<T>()); }
virtual void onGenericElementAdded(const CVariant &value) override final
{
onElementAdded(value.to<typename T::value_type>());
}
virtual void onGenericElementsReplaced(const CVariantList &values) override final
{
onElementsReplaced(values.to<T>());
}
};
} // namespace swift::misc::shared_state

View File

@@ -7,8 +7,5 @@
namespace swift::misc::shared_state
{
void CPassiveMutator::postEvent(const CVariant &param)
{
emit eventPosted(param);
}
void CPassiveMutator::postEvent(const CVariant &param) { emit eventPosted(param); }
} // namespace swift::misc::shared_state

View File

@@ -23,8 +23,5 @@ namespace swift::misc::shared_state
return m_eventSubscription;
}
void CPassiveObserver::handleEvent(const CVariant &param) const
{
m_eventHandler(param);
}
void CPassiveObserver::handleEvent(const CVariant &param) const { m_eventHandler(param); }
} // namespace swift::misc::shared_state

View File

@@ -31,8 +31,9 @@ namespace swift::misc::shared_state
friend QSharedPointer<CPassiveObserver>;
template <typename T, typename F>
CPassiveObserver(T *parent, F eventHandler) : QObject(parent),
m_eventHandler([=](const CVariant &param) { private_ns::invokeMethod(parent, eventHandler, param); })
CPassiveObserver(T *parent, F eventHandler)
: QObject(parent),
m_eventHandler([=](const CVariant &param) { private_ns::invokeMethod(parent, eventHandler, param); })
{}
public:

View File

@@ -23,8 +23,5 @@ namespace swift::misc::shared_state
return m_value;
}
void CGenericScalarJournal::handleEvent(const CVariant &param)
{
m_value = param;
}
void CGenericScalarJournal::handleEvent(const CVariant &param) { m_value = param; }
} // namespace swift::misc::shared_state

View File

@@ -39,7 +39,8 @@ namespace swift::misc::shared_state
void handleEvent(const CVariant &param);
QSharedPointer<CActiveMutator> m_mutator = CActiveMutator::create(this, &CGenericScalarJournal::handleRequest);
QSharedPointer<CPassiveObserver> m_observer = CPassiveObserver::create(this, &CGenericScalarJournal::handleEvent);
QSharedPointer<CPassiveObserver> m_observer =
CPassiveObserver::create(this, &CGenericScalarJournal::handleEvent);
CVariant m_value;
};

View File

@@ -9,13 +9,7 @@
namespace swift::misc::shared_state
{
void CGenericScalarMutator::initialize(IDataLink *dataLink)
{
dataLink->publish(m_mutator.data());
}
void CGenericScalarMutator::initialize(IDataLink *dataLink) { dataLink->publish(m_mutator.data()); }
void CGenericScalarMutator::setValue(const CVariant &value)
{
m_mutator->postEvent(value);
}
void CGenericScalarMutator::setValue(const CVariant &value) { m_mutator->postEvent(value); }
} // namespace swift::misc::shared_state

View File

@@ -13,7 +13,8 @@ namespace swift::misc::shared_state
{
dataLink->subscribe(m_observer.data());
m_observer->setEventSubscription(CVariant::from(CAnyMatch()));
connect(dataLink->watcher(), &CDataLinkConnectionWatcher::connected, this, &CGenericScalarObserver::reconstruct);
connect(dataLink->watcher(), &CDataLinkConnectionWatcher::connected, this,
&CGenericScalarObserver::reconstruct);
if (dataLink->watcher()->isConnected()) { reconstruct(); }
}

View File

@@ -41,7 +41,8 @@ namespace swift::misc::shared_state
void handleEvent(const CVariant &param);
virtual void onGenericValueChanged(const CVariant &value) = 0;
QSharedPointer<CActiveObserver> m_observer = CActiveObserver::create(this, &CGenericScalarObserver::handleEvent);
QSharedPointer<CActiveObserver> m_observer =
CActiveObserver::create(this, &CGenericScalarObserver::handleEvent);
mutable QMutex m_valueMutex;
CVariant m_value;
};