cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
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
24#include <QtCore/QObject>
25#include <QtCore/QString>
26
27#include <cstdint>
28#include <cstddef>
29#include <memory>
30#include <vector>
31
32namespace cc_tools_qt
33{
34
39class CC_TOOLS_API ToolsSocket : public QObject
40{
41 Q_OBJECT
42public:
45 {
46 ConnectionProperty_Autoconnect = 0x1,
47 ConnectionProperty_NonDisconnectable = 0x2
48 };
49
52
54 virtual ~ToolsSocket() noexcept;
55
62 bool start();
63
68 void stop();
69
71 bool isRunning() const;
72
80 bool socketConnect();
81
87 void socketDisconnect();
88
90 bool isSocketConnected() const;
91
96 void sendData(ToolsDataInfoPtr dataPtr);
97
105 unsigned connectionProperties() const;
106
112 void applyInterPluginConfig(const QVariantMap& props);
113
116 void setDebugOutputLevel(unsigned level = 0U);
117
118signals:
121 void sigDataReceivedReport(ToolsDataInfoPtr data);
122
125 void sigErrorReport(const QString& msg);
126
129 void sigConnectionStatusReport(bool connected);
130
133 void sigInterPluginConfigReport(const QVariantMap& props);
134
135protected:
140 virtual bool startImpl();
141
145 virtual void stopImpl();
146
151 virtual bool socketConnectImpl();
152
156 virtual void socketDisconnectImpl();
157
161 virtual void sendDataImpl(ToolsDataInfoPtr dataPtr) = 0;
162
167 virtual unsigned connectionPropertiesImpl() const;
168
172 virtual void applyInterPluginConfigImpl(const QVariantMap& props);
173
179 void reportDataReceived(ToolsDataInfoPtr dataPtr);
180
186 void reportError(const QString& msg);
187
193 void reportDisconnected();
194
202 void reportInterPluginConfig(const QVariantMap& props);
203
205 static unsigned long long currTimestamp();
206
208 unsigned getDebugOutputLevel() const;
209
210private:
211 struct InnerState;
212 std::unique_ptr<InnerState> m_state;
213};
214
216using ToolsSocketPtr = std::shared_ptr<ToolsSocket>;
217
218} // namespace cc_tools_qt
219
Main polymorphic interface class for sockets.
Definition ToolsSocket.h:40
ConnectionProperty
Available socket connection properties values.
Definition ToolsSocket.h:45
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:57
std::shared_ptr< ToolsSocket > ToolsSocketPtr
Pointer to ToolsSocket object.
Definition ToolsSocket.h:216