From 0b4d0fcf67283a454beb2fb1343a324c1f618bb9 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Wed, 17 Oct 2007 12:01:08 +0200 Subject: [PATCH] implement operator << and an assert --- src/devices/wifi/wifi-mode.cc | 13 ++++++++++++- src/devices/wifi/wifi-mode.h | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/devices/wifi/wifi-mode.cc b/src/devices/wifi/wifi-mode.cc index baf36b124..1f5f44505 100644 --- a/src/devices/wifi/wifi-mode.cc +++ b/src/devices/wifi/wifi-mode.cc @@ -7,6 +7,11 @@ bool operator == (const WifiMode &a, const WifiMode &b) { return a.GetUid () == b.GetUid (); } +std::ostream & operator << (std::ostream & os, const WifiMode &mode) +{ + os << mode.GetUniqueName (); + return os; +} uint32_t WifiMode::GetBandwidth (void) const @@ -50,6 +55,12 @@ WifiMode::GetConstellationSize (void) const struct WifiModeFactory::WifiModeItem *item = WifiModeFactory::GetFactory ()->Get (m_uid); return item->constellationSize; } +std::string +WifiMode::GetUniqueName (void) const +{ + struct WifiModeFactory::WifiModeItem *item = WifiModeFactory::GetFactory ()->Get (m_uid); + return item->uniqueUid; +} bool WifiMode::IsMandatory (void) const { @@ -130,7 +141,7 @@ WifiModeFactory::AllocateUid (std::string uniqueUid) struct WifiModeFactory::WifiModeItem * WifiModeFactory::Get (uint32_t uid) { - NS_ASSERT (uid > 0); + NS_ASSERT (uid > 0 && uid <= m_itemList.size ()); return &m_itemList[uid - 1]; } diff --git a/src/devices/wifi/wifi-mode.h b/src/devices/wifi/wifi-mode.h index 247c40273..e0dca2073 100644 --- a/src/devices/wifi/wifi-mode.h +++ b/src/devices/wifi/wifi-mode.h @@ -4,6 +4,7 @@ #include #include #include +#include namespace ns3 { @@ -49,6 +50,8 @@ class WifiMode */ uint8_t GetConstellationSize (void) const; + std::string GetUniqueName (void) const; + /** * \returns true if this mode is a mandatory mode, false * otherwise. @@ -73,6 +76,7 @@ private: }; bool operator == (const WifiMode &a, const WifiMode &b); +std::ostream & operator << (std::ostream & os, const WifiMode &mode); class WifiModeFactory {