GCC Code Coverage Report


Directory: ./
File: qtpdcom/src/MessageManager.cpp
Date: 2023-11-12 04:06:57
Exec Total Coverage
Lines: 9 42 21.4%
Branches: 3 64 4.7%

Line Branch Exec Source
1 /*****************************************************************************
2 *
3 * Copyright (C) 2022 Florian Pose <fp@igh.de>
4 *
5 * This file is part of the QtPdCom library.
6 *
7 * The QtPdCom library is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * The QtPdCom library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 * License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with the QtPdCom Library. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ****************************************************************************/
21
22 #include "MessageManager.h"
23
24 #include <QDebug>
25
26 using QtPdCom::MessageManager;
27
28 /****************************************************************************/
29
30
1/2
✓ Branch 7 taken 18 times.
✗ Branch 8 not taken.
18 MessageManager::MessageManager()
31 {
32 18 }
33
34 /****************************************************************************/
35
36 36 MessageManager::~MessageManager()
37 {
38 18 reset();
39 18 }
40
41 /****************************************************************************/
42
43 54 void MessageManager::reset()
44 {
45 54 emit processResetSignal();
46
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
54 while (!activeMessageQueue.empty())
47 activeMessageQueue.dequeue().reportCanceled();
48 while (!getMessageQueue.empty())
49 getMessageQueue.dequeue().reportCanceled();
50 54 }
51
52 /****************************************************************************/
53
54 void MessageManager::processMessage(PdCom::Message message)
55 {
56 emit processMessageSignal(message);
57 }
58
59 /****************************************************************************/
60
61 QtPdCom::MessageFuture MessageManager::getMessageQt(uint32_t seqNo)
62 {
63 MessageFutureInterface promise;
64 getMessageQueue.push_back(promise);
65 promise.reportStarted();
66 PdCom::MessageManagerBase::getMessage(seqNo);
67 return promise.future();
68 }
69
70 /****************************************************************************/
71
72 void MessageManager::getMessageReply(PdCom::Message message)
73 {
74 if (getMessageQueue.empty())
75 return;
76
77 auto promise = getMessageQueue.dequeue();
78 if (promise.isCanceled())
79 return;
80 promise.reportResult(message);
81 promise.reportFinished();
82 }
83
84 /****************************************************************************/
85
86 QtPdCom::MessageListFuture MessageManager::activeMessagesQt()
87 {
88 MessageListFutureInterface promise;
89 activeMessageQueue.push_back(promise);
90 promise.reportStarted();
91 PdCom::MessageManagerBase::activeMessages();
92 return promise.future();
93 }
94
95 /****************************************************************************/
96
97 void MessageManager::activeMessagesReply(
98 std::vector<PdCom::Message> messageList)
99 {
100 if (activeMessageQueue.empty())
101 return;
102
103 auto promise = activeMessageQueue.dequeue();
104 if (promise.isCanceled())
105 return;
106 promise.reportResult(messageList);
107 promise.reportFinished();
108 }
109
110 /****************************************************************************/
111