cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
ToolsSocket.h
1//
2// Copyright 2014 - 2026 (C). Alex Robenko. All rights reserved.
3//
4// SPDX-License-Identifier: GPL-3.0-or-later
5//
6
7// This file is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20#pragma once
21
22#include "cc_tools_qt/ToolsApi.h"
23#include "cc_tools_qt/ToolsDataInfo.h"
24#include "cc_tools_qt/version.h"
25
26#include <QtCore/QObject>
27#include <QtCore/QString>
28
29#include <cstdint>
30#include <cstddef>
31#include <memory>
32#include <vector>
33
34namespace cc_tools_qt
35{
36
41class CC_TOOLS_API ToolsSocket : public QObject
42{
43 Q_OBJECT
44public:
47 {
48 ConnectionProperty_Autoconnect = 0x1,
49 ConnectionProperty_NonDisconnectable = 0x2
50 };
51
54
56 virtual ~ToolsSocket() noexcept;
57
64 bool start();
65
70 void stop();
71
73 bool isRunning() const;
74
82 bool socketConnect();
83
89 void socketDisconnect();
90
92 bool isSocketConnected() const;
93
98 void sendData(ToolsDataInfoPtr dataPtr);
99
107 unsigned connectionProperties() const;
108
114 void applyInterPluginConfig(const QVariantMap& props);
115
118 void setDebugOutputLevel(unsigned level = 0U);
119
120signals:
123 void sigDataReceivedReport(ToolsDataInfoPtr data);
124
127 void sigErrorReport(const QString& msg);
128
131 void sigConnectionStatusReport(bool connected);
132
135 void sigInterPluginConfigReport(const QVariantMap& props);
136
137protected:
142 virtual bool startImpl();
143
147 virtual void stopImpl();
148
153 virtual bool socketConnectImpl();
154
158 virtual void socketDisconnectImpl();
159
163 virtual void sendDataImpl(ToolsDataInfoPtr dataPtr) = 0;
164
169 virtual unsigned connectionPropertiesImpl() const;
170
174 virtual void applyInterPluginConfigImpl(const QVariantMap& props);
175
177 static unsigned long long currTimestamp();
178
180 unsigned getDebugOutputLevel() const;
181
182protected slots:
188 void reportDataReceived(ToolsDataInfoPtr dataPtr);
189
195 void reportError(const QString& msg);
196
202 void reportDisconnected();
203
211 void reportInterPluginConfig(const QVariantMap& props);
212
213private:
214 struct InnerState;
215 std::unique_ptr<InnerState> m_state;
216};
217
219using ToolsSocketPtr = std::shared_ptr<ToolsSocket>;
220
221} // namespace cc_tools_qt
222
Main polymorphic interface class for sockets.
Definition ToolsSocket.h:42
ConnectionProperty
Available socket connection properties values.
Definition ToolsSocket.h:47
virtual ~ToolsSocket() noexcept
Destructor.
Main namespace for all classes / functions of the shared library.
std::shared_ptr< ToolsDataInfo > ToolsDataInfoPtr
Pointer to ToolsDataInfo.
Definition ToolsDataInfo.h:59
std::shared_ptr< ToolsSocket > ToolsSocketPtr
Pointer to ToolsSocket object.
Definition ToolsSocket.h:219