1// Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <Qt3DCore/qt3dcore-config.h>
5
6#ifndef QT3DCORE_DEBUG_ASPECTCOMMANDDEBUGGER_H
7#define QT3DCORE_DEBUG_ASPECTCOMMANDDEBUGGER_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists for the convenience
14// of other Qt classes. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QTcpServer>
21#include <Qt3DCore/private/qt3dcore_global_p.h>
22#include <QtCore/QHash>
23
24QT_BEGIN_NAMESPACE
25
26namespace Qt3DCore {
27
28class QSystemInformationService;
29
30namespace Debug {
31
32class AsynchronousCommandReply;
33
34class Q_3DCORE_PRIVATE_EXPORT AspectCommandDebugger : public QTcpServer
35{
36 Q_OBJECT
37public:
38 explicit AspectCommandDebugger(QSystemInformationService *parent = nullptr);
39
40 void initialize();
41
42 struct Q_3DCORE_PRIVATE_EXPORT ReadBuffer {
43 QByteArray buffer;
44 qsizetype startIdx = 0;
45 qsizetype endIdx = 0;
46
47 inline qsizetype size() const { return endIdx - startIdx; }
48 void insert(const QByteArray &array);
49 void trim();
50 };
51
52private Q_SLOTS:
53 void asynchronousReplyFinished(AsynchronousCommandReply *reply);
54
55private:
56 void sendReply(QTcpSocket *socket, const QByteArray &data);
57 void onCommandReceived(QTcpSocket *socket);
58 void executeCommand(const QString &command, QTcpSocket *socket);
59
60 QList<QTcpSocket *> m_connections;
61 QSystemInformationService *m_service;
62
63 ReadBuffer m_readBuffer;
64 QHash<AsynchronousCommandReply *, QTcpSocket *> m_asyncCommandToSocketEntries;
65};
66
67} // Debug
68
69} // Qt3DCore
70
71QT_END_NAMESPACE
72
73#endif // QT3DCORE_DEBUG_ASPECTCOMMANDDEBUGGER_H
74

source code of qt3d/src/core/aspects/aspectcommanddebugger_p.h