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 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | namespace Qt3DCore { |
26 | |
27 | class QSystemInformationService; |
28 | |
29 | namespace Debug { |
30 | |
31 | class AsynchronousCommandReply; |
32 | |
33 | class Q_3DCORE_PRIVATE_EXPORT AspectCommandDebugger : public QTcpServer |
34 | { |
35 | Q_OBJECT |
36 | public: |
37 | explicit AspectCommandDebugger(QSystemInformationService *parent = nullptr); |
38 | |
39 | void initialize(); |
40 | |
41 | struct Q_3DCORE_PRIVATE_EXPORT ReadBuffer { |
42 | QByteArray buffer; |
43 | qsizetype startIdx = 0; |
44 | qsizetype endIdx = 0; |
45 | |
46 | inline qsizetype size() const { return endIdx - startIdx; } |
47 | void insert(const QByteArray &array); |
48 | void trim(); |
49 | }; |
50 | |
51 | private Q_SLOTS: |
52 | void asynchronousReplyFinished(AsynchronousCommandReply *reply); |
53 | |
54 | private: |
55 | void sendReply(QTcpSocket *socket, const QByteArray &data); |
56 | void onCommandReceived(QTcpSocket *socket); |
57 | void executeCommand(const QString &command, QTcpSocket *socket); |
58 | |
59 | QList<QTcpSocket *> m_connections; |
60 | QSystemInformationService *m_service; |
61 | |
62 | ReadBuffer m_readBuffer; |
63 | QHash<AsynchronousCommandReply *, QTcpSocket *> m_asyncCommandToSocketEntries; |
64 | }; |
65 | |
66 | } // Debug |
67 | |
68 | } // Qt3DCore |
69 | |
70 | QT_END_NAMESPACE |
71 | |
72 | #endif // QT3DCORE_DEBUG_ASPECTCOMMANDDEBUGGER_H |
73 |