Akonadi

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

KDE's Doxygen guidelines are available online.