Akonadi

bridgeserver.h
1/***************************************************************************
2 * SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org> *
3 * *
4 * SPDX-License-Identifier: LGPL-2.0-or-later *
5 ***************************************************************************/
6
7#pragma once
8
9#include <QObject>
10#include <QTcpServer>
11
12class BridgeServerBase : public QObject
13{
15
16public:
17 explicit BridgeServerBase(quint16 port, QObject *parent = nullptr);
18
19protected Q_SLOTS:
20 virtual void slotNewConnection() = 0;
21
22protected:
23 QTcpServer *const m_server;
24};
25
26template<typename ConnectionType>
27class BridgeServer : public BridgeServerBase
28{
29public:
30 explicit BridgeServer(quint16 port, QObject *parent = nullptr)
31 : BridgeServerBase(port, parent)
32 {
33 }
34
35protected:
36 void slotNewConnection() override
37 {
38 while (m_server->hasPendingConnections()) {
39 new ConnectionType(m_server->nextPendingConnection(), this);
40 }
41 }
42};
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * parent() const const
ConnectionType
virtual bool hasPendingConnections() const const
virtual QTcpSocket * nextPendingConnection()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:38 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.