GCC Code Coverage Report


Directory: ./
File: src/MessageManagerBase.cpp
Date: 2024-02-26 09:07:35
Exec Total Coverage
Lines: 12 31 38.7%
Branches: 7 28 25.0%

Line Branch Exec Source
1 /*****************************************************************************
2 * vim:tw=78
3 *
4 * Copyright (C) 2021 Bjarne von Horn (vh at igh dot de).
5 *
6 * This file is part of the PdCom library.
7 *
8 * The PdCom library is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * The PdCom library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 * License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with the PdCom library. If not, see <http://www.gnu.org/licenses/>.
20 *
21 *****************************************************************************/
22
23 #include "Process.h"
24
25 #include <pdcom5/Exception.h>
26 #include <pdcom5/MessageManagerBase.h>
27
28 using PdCom::MessageManagerBase;
29
30 MessageManagerBase::MessageManagerBase() = default;
31
32 MessageManagerBase::MessageManagerBase(MessageManagerBase &&o) noexcept :
33 process_(std::move(o.process_))
34 {
35 if (const auto p = process_.lock()) {
36 if (p->message_manager_ == &o) {
37 p->message_manager_ = this;
38 }
39 }
40 }
41
42 MessageManagerBase &
43 MessageManagerBase::operator=(MessageManagerBase &&o) noexcept
44 {
45 if (&o == this)
46 return *this;
47 if (const auto my_process = process_.lock())
48 my_process->message_manager_ = nullptr;
49 process_ = std::move(o.process_);
50 if (const auto my_process = process_.lock())
51 my_process->message_manager_ = this;
52 return *this;
53 }
54
55 8 MessageManagerBase::~MessageManagerBase()
56 {
57
1/2
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
8 if (const auto p = process_.lock())
58 4 p->setMessageManager(nullptr);
59 4 }
60
61 2 void MessageManagerBase::getMessage(uint32_t seqNo) const
62 {
63
1/2
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (const auto p = process_.lock()) {
64
2/4
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
2 p->protocolHandler().getMessage(seqNo);
65 }
66 else
67 throw ProcessGoneAway();
68 2 }
69
70 2 void MessageManagerBase::activeMessages() const
71 {
72
1/2
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (const auto p = process_.lock()) {
73
2/4
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
2 p->protocolHandler().getActiveMessages();
74 }
75 else
76 throw ProcessGoneAway();
77 2 }
78
79 void MessageManagerBase::getMessageReply(PdCom::Message)
80 {}
81
82 void MessageManagerBase::processMessage(PdCom::Message)
83 {}
84
85 void MessageManagerBase::activeMessagesReply(std::vector<PdCom::Message>)
86 {}
87