Skip to content

Commit 755f946

Browse files
committed
LteMac*,etc: eliminate use of getTagsWithInherit()
The C++ types of tag objects in question can be known beforehand, so just use getTag.
1 parent 6afb111 commit 755f946

4 files changed

Lines changed: 7 additions & 39 deletions

File tree

src/simu5g/common/LteCommon.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -518,26 +518,6 @@ bool checkIfHeaderType(const inet::Packet *pkt, bool checkFirst = false) {
518518
return false;
519519
}
520520

521-
template<typename T>
522-
std::vector<T> getTagsWithInherit(inet::Packet *pkt)
523-
{
524-
std::vector<T> t;
525-
auto tags = pkt->getTags();
526-
if (tags.getNumTags() == 0)
527-
return t;
528-
529-
// check if a tag that is derived from this exists.
530-
//
531-
for (int i = 0; i < tags.getNumTags(); i++) {
532-
auto tag = tags.getTagForUpdate(i);
533-
auto temp = inet::dynamicPtrCast<T>(tag);
534-
if (temp != nullptr) {
535-
t.push_back(*temp.get());
536-
}
537-
}
538-
return t;
539-
}
540-
541521
} //namespace
542522

543523
#endif

src/simu5g/stack/mac/LteMacUeD2D.cc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,9 @@ void LteMacUeD2D::macPduMake(MacCid cid)
224224
auto pkt = check_and_cast<Packet *>(connDescOut_[destCid].queue->popFront());
225225

226226
// multicast support
227-
// this trick gets the group ID from the MAC SDU and sets item in the MAC PDU
228-
auto infoVec = getTagsWithInherit<LteControlInfo>(pkt);
229-
230-
if (infoVec.empty())
231-
throw cRuntimeError("No tag of type LteControlInfo found");
232-
233-
int32_t groupId = infoVec.front().getMulticastGroupId();
227+
// this trick gets the group ID from the MAC SDU and sets it in the MAC PDU
228+
auto flowInfo = pkt->getTag<FlowControlInfo>();
229+
int32_t groupId = flowInfo->getMulticastGroupId();
234230
if (groupId >= 0) // for unicast, group id is -1
235231
macPkt->getTagForUpdate<UserControlInfo>()->setMulticastGroupId(groupId);
236232

src/simu5g/stack/mac/NrMacUe.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,8 @@ void NrMacUe::macPduMake(MacCid cid)
429429

430430
// multicast support
431431
// this trick gets the group ID from the MAC SDU and sets it in the MAC PDU
432-
auto infoVec = getTagsWithInherit<LteControlInfo>(pkt);
433-
if (infoVec.empty())
434-
throw cRuntimeError("No tag of type LteControlInfo found");
435-
436-
int32_t groupId = infoVec.front().getMulticastGroupId();
432+
auto flowInfo = pkt->getTag<FlowControlInfo>();
433+
int32_t groupId = flowInfo->getMulticastGroupId();
437434
if (groupId >= 0) // for unicast, group id is -1
438435
macPkt->getTagForUpdate<UserControlInfo>()->setMulticastGroupId(groupId);
439436

src/simu5g/stack/mac/buffer/harq_d2d/LteHarqProcessTxD2D.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,8 @@ Packet *LteHarqProcessTxD2D::extractPdu(Codeword cw)
3838

3939
numSelected_--;
4040
Packet *pkt = units_[cw]->extractPdu();
41-
auto pdu = pkt->peekAtFront<LteMacPdu>();
42-
auto infoVec = getTagsWithInherit<LteControlInfo>(pkt);
43-
if (infoVec.empty())
44-
throw cRuntimeError("No tag of type LteControlInfo found");
45-
auto info = infoVec.front();
46-
47-
if (info.getDirection() == D2D_MULTI) {
41+
auto info = pkt->getTag<UserControlInfo>();
42+
if (info->getDirection() == D2D_MULTI) {
4843
// if the PDU is for a multicast/broadcast connection, the selected unit has been emptied
4944
numEmptyUnits_++;
5045
}

0 commit comments

Comments
 (0)