Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
SocketClient.h
Go to the documentation of this file.
1#pragma once
2#include <QAbstractSocket>
3#include <QMutex>
4#include <QThread>
5#include <QWaitCondition>
8#include <misc/gen/Sync.h>
9#include <misc/qt/QtSync.h>
10
11namespace sf
12{
13
15 : public QThread
16 , protected QtSync
17{
18 public:
19 explicit SocketClient(QObject* parent);
20
21 ~SocketClient() override;
22
23 void connectHost(const QString& hostName, int portNumber);
24
25 private:
26 void run() override;
27
28 void handleError(QAbstractSocket::SocketError socketError) const;
29
30 QString _hostName;
31 int _portNumber{0};
32 // Timeout in milliseconds.
33 int _waitTimeout{5000};
34 // Mutex for the condition.
35 QMutex _mutex;
36 //
37 QAbstractSocket* _socket{nullptr};
38 //
39 QWaitCondition _waitCondition;
40 //
41 ClientConnection* _connection;
42
43 // LLDB Crashes and GDB freezes when this MACRO is in top of the class.
44 Q_OBJECT
45};
46
47}// namespace sf
QSync provides a interface to build classes that act like monitors.
Definition QtSync.h:14
Definition SocketClient.h:17
~SocketClient() override
void connectHost(const QString &hostName, int portNumber)
SocketClient(QObject *parent)
Definition Application.h:10