Skip to content

Commit

Permalink
wifi: Add stream insertion operator for WifiPsduMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefano Avallone committed Dec 16, 2024
1 parent 7b276d9 commit a0120b7
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 31 deletions.
9 changes: 0 additions & 9 deletions src/wifi/model/he/he-frame-exchange-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ namespace ns3
class MultiUserScheduler;
class CtrlTriggerHeader;

/**
* Map of PSDUs indexed by STA-ID
*/
typedef std::unordered_map<uint16_t /* staId */, Ptr<WifiPsdu> /* PSDU */> WifiPsduMap;
/**
* Map of const PSDUs indexed by STA-ID
*/
typedef std::unordered_map<uint16_t /* staId */, Ptr<const WifiPsdu> /* PSDU */> WifiConstPsduMap;

/**
* @param psduMap a PSDU map
* @return true if the given PSDU map contains a single PSDU including a single MPDU
Expand Down
2 changes: 0 additions & 2 deletions src/wifi/model/he/multi-user-scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ namespace ns3

class HeFrameExchangeManager;

typedef std::unordered_map<uint16_t /* staId */, Ptr<WifiPsdu> /* PSDU */> WifiPsduMap;

/**
* @ingroup wifi
*
Expand Down
1 change: 0 additions & 1 deletion src/wifi/model/ht/ht-frame-exchange-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "ns3/mpdu-aggregator.h"
#include "ns3/msdu-aggregator.h"
#include "ns3/qos-frame-exchange-manager.h"
#include "ns3/wifi-psdu.h"

class AmpduAggregationTest;

Expand Down
10 changes: 0 additions & 10 deletions src/wifi/model/wifi-ppdu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,4 @@ operator<<(std::ostream& os, const Ptr<const WifiPpdu>& ppdu)
return os;
}

std::ostream&
operator<<(std::ostream& os, const WifiConstPsduMap& psdus)
{
for (const auto& psdu : psdus)
{
os << "PSDU for STA_ID=" << psdu.first << " (" << *psdu.second << ") ";
}
return os;
}

} // namespace ns3
9 changes: 0 additions & 9 deletions src/wifi/model/wifi-ppdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,6 @@ class WifiPpdu : public SimpleRefCount<WifiPpdu>
*/
std::ostream& operator<<(std::ostream& os, const Ptr<const WifiPpdu>& ppdu);

/**
* @brief Stream insertion operator.
*
* @param os the stream
* @param psdus the PSDUs
* @returns a reference to the stream
*/
std::ostream& operator<<(std::ostream& os, const WifiConstPsduMap& psdus);

} // namespace ns3

#endif /* WIFI_PPDU_H */
36 changes: 36 additions & 0 deletions src/wifi/model/wifi-psdu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,40 @@ operator<<(std::ostream& os, const WifiPsdu& psdu)
return os;
}

std::ostream&
operator<<(std::ostream& os, const WifiPsduMap& psduMap)
{
for (const auto& [staId, psdu] : psduMap)
{
if (staId != SU_STA_ID)
{
os << "[PSDU for STA_ID=" << staId << ", ";
}
psdu->Print(os);
if (staId != SU_STA_ID)
{
os << "]";
}
}
return os;
}

std::ostream&
operator<<(std::ostream& os, const WifiConstPsduMap& psduMap)
{
for (const auto& [staId, psdu] : psduMap)
{
if (staId != SU_STA_ID)
{
os << "[PSDU for STA_ID=" << staId << ", ";
}
psdu->Print(os);
if (staId != SU_STA_ID)
{
os << "]";
}
}
return os;
}

} // namespace ns3
25 changes: 25 additions & 0 deletions src/wifi/model/wifi-psdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "ns3/nstime.h"

#include <set>
#include <unordered_map>
#include <vector>

namespace ns3
Expand Down Expand Up @@ -259,6 +260,30 @@ class WifiPsdu : public SimpleRefCount<WifiPsdu>
*/
std::ostream& operator<<(std::ostream& os, const WifiPsdu& psdu);

/// Map of PSDUs indexed by STA-ID
using WifiPsduMap = std::unordered_map<uint16_t /* staId */, Ptr<WifiPsdu> /* PSDU */>;

/// Map of const PSDUs indexed by STA-ID
using WifiConstPsduMap = std::unordered_map<uint16_t /* staId */, Ptr<const WifiPsdu> /* PSDU */>;

/**
* @brief Stream insertion operator.
*
* @param os the stream
* @param psduMap the PSDU map
* @returns a reference to the stream
*/
std::ostream& operator<<(std::ostream& os, const WifiPsduMap& psduMap);

/**
* @brief Stream insertion operator.
*
* @param os the stream
* @param psduMap the PSDU map
* @returns a reference to the stream
*/
std::ostream& operator<<(std::ostream& os, const WifiConstPsduMap& psduMap);

} // namespace ns3

#endif /* WIFI_PSDU_H */

0 comments on commit a0120b7

Please sign in to comment.