cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
ToolsMsgMgr.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/ToolsFilter.h"
24#include "cc_tools_qt/ToolsMessage.h"
25#include "cc_tools_qt/ToolsProtocol.h"
26#include "cc_tools_qt/ToolsSocket.h"
27#include "cc_tools_qt/version.h"
28
29#include <memory>
30#include <list>
31#include <vector>
32
33namespace cc_tools_qt
34{
35
36class ToolsMsgMgrImpl;
37class CC_TOOLS_API ToolsMsgMgr
38{
39public:
40 using MsgType = ToolsMessage::Type;
41
42 ToolsMsgMgr();
43 ~ToolsMsgMgr() noexcept;
44
45 void start();
46 void stop();
47 void clear();
48
49 ToolsSocketPtr getSocket() const;
50 ToolsProtocolPtr getProtocol() const;
51 void setRecvEnabled(bool enabled);
52
53 void deleteMsg(ToolsMessagePtr msg);
54 void deleteMsgs(const ToolsMessagesList& msgs);
55 void deleteAllMsgs();
56
57 void sendMsgs(ToolsMessagesList&& msgs);
58
59 const ToolsMessagesList& getAllMsgs() const;
60 void addMsgs(const ToolsMessagesList& msgs, bool reportAdded = true);
61
62 void setSocket(ToolsSocketPtr socket);
63 void setProtocol(ToolsProtocolPtr protocol);
64 void clearFilters();
65 void addFilter(ToolsFilterPtr filter);
66
67 using MsgAddedCallbackFunc = std::function<void (ToolsMessagePtr msg)>;
68 using ErrorReportCallbackFunc = std::function<void (const QString& error)>;
69 using SocketConnectionStatusReportCallbackFunc = std::function<void (bool connected)>;
70
71 void setMsgAddedCallbackFunc(MsgAddedCallbackFunc&& func);
72 void setErrorReportCallbackFunc(ErrorReportCallbackFunc&& func);
73 void setSocketConnectionStatusReportCallbackFunc(SocketConnectionStatusReportCallbackFunc&& func);
74
75private:
76 std::unique_ptr<ToolsMsgMgrImpl> m_impl;
77};
78
79} // namespace cc_tools_qt
Main namespace for all classes / functions of the shared library.