cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
ToolsMsgSendMgrImpl.h
1//
2// Copyright 2016 - 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/ToolsMsgSendMgr.h"
23#include "cc_tools_qt/ToolsProtocol.h"
24
25#include <QtCore/QObject>
26#include <QtCore/QTimer>
27
28#include <memory>
29
30namespace cc_tools_qt
31{
32
33class ToolsMsgSendMgrImpl : public QObject
34{
35 Q_OBJECT
36public:
37 using SendMsgsCallbackFunc = ToolsMsgSendMgr::SendMsgsCallbackFunc;
38 using SendCompleteCallbackFunc = ToolsMsgSendMgr::SendCompleteCallbackFunc;
39
40 ToolsMsgSendMgrImpl();
41 ~ToolsMsgSendMgrImpl() noexcept;
42
43 template <typename TFunc>
44 void setSendMsgsCallbackFunc(TFunc&& func)
45 {
46 m_sendCallback = std::forward<TFunc>(func);
47 }
48
49 template <typename TFunc>
50 void setSendCompleteCallbackFunc(TFunc&& func)
51 {
52 m_sendCompleteCallback = std::forward<TFunc>(func);
53 }
54
55 void start(ToolsProtocolPtr protocol, const ToolsMessagesList& msgs);
56
57 void stop();
58
59private slots:
60 void sendPendingAndWait();
61
62private:
63 SendMsgsCallbackFunc m_sendCallback;
64 SendCompleteCallbackFunc m_sendCompleteCallback;
65 ToolsProtocolPtr m_protocol;
66 ToolsMessagesList m_msgsToSend;
67 QTimer m_timer;
68};
69
70} // namespace cc_tools_qt
Main namespace for all classes / functions of the shared library.
std::shared_ptr< ToolsProtocol > ToolsProtocolPtr
Pointer to ToolsProtocol object.
Definition ToolsProtocol.h:235