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