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