cc_tools_qt
Common Environment for Protocol Analysis.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ToolsSocket.h
1//
2// Copyright 2014 - 2025 (C). Alex Robenko. All rights reserved.
3//
4
5// This file is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18
19#pragma once
20
21#include "cc_tools_qt/ToolsApi.h"
22#include "cc_tools_qt/ToolsDataInfo.h"
23#include "cc_tools_qt/version.h"
24
25#include <QtCore/QObject>
26#include <QtCore/QString>
27
28#include <cstdint>
29#include <cstddef>
30#include <memory>
31#include <vector>
32
33namespace cc_tools_qt
34{
35
40class CC_TOOLS_API ToolsSocket : public QObject
41{
42 Q_OBJECT
43public:
46 {
47 ConnectionProperty_Autoconnect = 0x1,
48 ConnectionProperty_NonDisconnectable = 0x2
49 };
50
53
55 virtual ~ToolsSocket() noexcept;
56
63 bool start();
64
69 void stop();
70
72 bool isRunning() const;
73
81 bool socketConnect();
82
88 void socketDisconnect();
89
91 bool isSocketConnected() const;
92
97 void sendData(ToolsDataInfoPtr dataPtr);
98
106 unsigned connectionProperties() const;
107
113 void applyInterPluginConfig(const QVariantMap& props);
114
117 void setDebugOutputLevel(unsigned level = 0U);
118
119signals:
122 void sigDataReceivedReport(ToolsDataInfoPtr data);
123
126 void sigErrorReport(const QString& msg);
127
130 void sigConnectionStatusReport(bool connected);
131
134 void sigInterPluginConfigReport(const QVariantMap& props);
135
136protected:
141 virtual bool startImpl();
142
146 virtual void stopImpl();
147
152 virtual bool socketConnectImpl();
153
157 virtual void socketDisconnectImpl();
158
162 virtual void sendDataImpl(ToolsDataInfoPtr dataPtr) = 0;
163
168 virtual unsigned connectionPropertiesImpl() const;
169
173 virtual void applyInterPluginConfigImpl(const QVariantMap& props);
174
176 static unsigned long long currTimestamp();
177
179 unsigned getDebugOutputLevel() const;
180
181protected slots:
187 void reportDataReceived(ToolsDataInfoPtr dataPtr);
188
194 void reportError(const QString& msg);
195
201 void reportDisconnected();
202
210 void reportInterPluginConfig(const QVariantMap& props);
211
212private:
213 struct InnerState;
214 std::unique_ptr<InnerState> m_state;
215};
216
218using ToolsSocketPtr = std::shared_ptr<ToolsSocket>;
219
220} // namespace cc_tools_qt
221
Main polymorphic interface class for sockets.
Definition ToolsSocket.h:41
ConnectionProperty
Available socket connection properties values.
Definition ToolsSocket.h:46
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:58
std::shared_ptr< ToolsSocket > ToolsSocketPtr
Pointer to ToolsSocket object.
Definition ToolsSocket.h:218