GCC Code Coverage Report


Directory: ./
File: src/MessageManager.cpp
Date: 2024-11-19 17:00:39
Exec Total Coverage
Lines: 36 43 83.7%
Branches: 30 64 46.9%

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 2 taken 12 times.
✗ Branch 3 not taken.
12 MessageManager::MessageManager()
31 {
32 12 }
33
34 /****************************************************************************/
35
36 24 MessageManager::~MessageManager()
37 {
38 12 reset();
39 12 }
40
41 /****************************************************************************/
42
43 29 void MessageManager::reset()
44 {
45 29 emit processResetSignal();
46
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
29 while (!activeMessageQueue.empty())
47 activeMessageQueue.dequeue().reportCanceled();
48 while (!getMessageQueue.empty())
49 getMessageQueue.dequeue().reportCanceled();
50 29 }
51
52 /****************************************************************************/
53
54 17 void MessageManager::processMessage(PdCom::Message message)
55 {
56
1/2
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
17 emit processMessageSignal(message);
57 17 }
58
59 /****************************************************************************/
60
61 13 QtPdCom::MessageFuture MessageManager::getMessageQt(uint32_t seqNo)
62 {
63
1/2
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
26 MessageFutureInterface promise;
64
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 getMessageQueue.push_back(promise);
65
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 promise.reportStarted();
66
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 PdCom::MessageManagerBase::getMessage(seqNo);
67
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
26 return promise.future();
68 }
69
70 /****************************************************************************/
71
72 13 void MessageManager::getMessageReply(PdCom::Message message)
73 {
74
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
13 if (getMessageQueue.empty())
75 return;
76
77
2/4
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
26 auto promise = getMessageQueue.dequeue();
78
2/4
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
13 if (promise.isCanceled())
79 return;
80
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 promise.reportResult(message);
81
2/4
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 promise.reportFinished();
82 }
83
84 /****************************************************************************/
85
86 5 QtPdCom::MessageListFuture MessageManager::activeMessagesQt()
87 {
88
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
10 MessageListFutureInterface promise;
89
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 activeMessageQueue.push_back(promise);
90
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 promise.reportStarted();
91
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 PdCom::MessageManagerBase::activeMessages();
92
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
10 return promise.future();
93 }
94
95 /****************************************************************************/
96
97 5 void MessageManager::activeMessagesReply(
98 std::vector<PdCom::Message> messageList)
99 {
100
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 if (activeMessageQueue.empty())
101 return;
102
103
2/4
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
10 auto promise = activeMessageQueue.dequeue();
104
2/4
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
5 if (promise.isCanceled())
105 return;
106
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 promise.reportResult(messageList);
107
2/4
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 promise.reportFinished();
108 }
109
110 /****************************************************************************/
111