cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
ToolsMsgMgr.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/ToolsFilter.h"
23#include "cc_tools_qt/ToolsMessage.h"
24#include "cc_tools_qt/ToolsProtocol.h"
25#include "cc_tools_qt/ToolsSocket.h"
26#include "cc_tools_qt/version.h"
27
28#include <memory>
29#include <list>
30#include <vector>
31
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 addFilter(ToolsFilterPtr filter);
65
66 using MsgAddedCallbackFunc = std::function<void (ToolsMessagePtr msg)>;
67 using ErrorReportCallbackFunc = std::function<void (const QString& error)>;
68 using SocketConnectionStatusReportCallbackFunc = std::function<void (bool connected)>;
69
70 void setMsgAddedCallbackFunc(MsgAddedCallbackFunc&& func);
71 void setErrorReportCallbackFunc(ErrorReportCallbackFunc&& func);
72 void setSocketConnectionStatusReportCallbackFunc(SocketConnectionStatusReportCallbackFunc&& func);
73
74private:
75 std::unique_ptr<ToolsMsgMgrImpl> m_impl;
76};
77
78} // namespace cc_tools_qt
Main namespace for all classes / functions of the shared library.