5G-LENA nr-v3.3-159-ga6832aa7
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-mac-harq-vector.cc
1// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#include "nr-mac-harq-vector.h"
6
7namespace ns3
8{
9
10bool
12{
13 at(id).Erase();
14 --m_usedSize;
15
16 uint32_t count = 0;
17 for (const auto& v : *this)
18 {
19 if (v.second.m_active)
20 {
21 ++count;
22 }
23 }
24 NS_ASSERT(count == m_usedSize);
25 return true;
26}
27
28bool
29NrMacHarqVector::Insert(uint8_t* id, const HarqProcess& element)
30{
31 if (m_usedSize >= m_maxSize)
32 {
33 return false;
34 }
35
36 NS_ABORT_IF(element.m_active == false);
37
38 *id = FirstAvailableId();
39 if (*id == 255)
40 {
41 return false;
42 }
43
44 NS_ABORT_IF(at(*id).m_active == true);
45 at(*id) = element;
46
47 NS_ABORT_IF(at(*id).m_active == false);
48 NS_ABORT_IF(this->FirstAvailableId() == *id);
49
50 ++m_usedSize;
51 return true;
52}
53
54std::ostream&
55operator<<(std::ostream& os, const NrMacHarqVector& item)
56{
57 for (const auto& p : item)
58 {
59 os << "Process ID " << static_cast<uint32_t>(p.first) << ": " << p.second << std::endl;
60 }
61 return os;
62}
63
64} // namespace ns3
Data structure to save all the HARQ process of an UE.
bool Insert(uint8_t *id, const HarqProcess &element)
Insert a process.
uint8_t FirstAvailableId() const
Find the first (INACTIVE) ID.
bool Erase(uint8_t id)
Erase the selected process.
The HarqProcess struct.
bool m_active
False indicate that the process is not active.