Akonadi

bridgeserver.h
1 /***************************************************************************
2  * Copyright (C) 2010 by Volker Krause <[email protected]> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU Library General Public License as *
6  * published by the Free Software Foundation; either version 2 of the *
7  * License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU Library General Public *
15  * License along with this program; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18  ***************************************************************************/
19 
20 #ifndef BRIDGESERVER_H
21 #define BRIDGESERVER_H
22 
23 #include <QObject>
24 #include <QTcpServer>
25 
26 class BridgeServerBase : public QObject
27 {
28  Q_OBJECT
29 
30 public:
31  explicit BridgeServerBase(quint16 port, QObject *parent = nullptr);
32 
33 protected Q_SLOTS:
34  virtual void slotNewConnection() = 0;
35 
36 protected:
37  QTcpServer *m_server = nullptr;
38 };
39 
40 template <typename ConnectionType>
41 class BridgeServer : public BridgeServerBase
42 {
43 public:
44  explicit BridgeServer(quint16 port, QObject *parent = nullptr)
45  : BridgeServerBase(port, parent)
46  {
47  }
48 
49 protected:
50  void slotNewConnection() override {
51  while (m_server->hasPendingConnections())
52  {
53  new ConnectionType(m_server->nextPendingConnection(), this);
54  }
55  }
56 };
57 
58 #endif // BRIDGESERVER_H
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed May 27 2020 22:43:36 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.