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