implement operator << and an assert
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user