From 005eab842928eed26ac459ca30862abb9fd45dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Tue, 24 Mar 2020 09:13:46 +0100 Subject: [PATCH] wifi: Move operator << for WifiPhyState to its header file --- src/wifi/model/wifi-phy-state.h | 33 +++++++++++++++++++++++++++++++++ src/wifi/model/wifi-phy.cc | 24 ------------------------ src/wifi/model/wifi-phy.h | 7 ------- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/wifi/model/wifi-phy-state.h b/src/wifi/model/wifi-phy-state.h index ae43af539..d18fa798d 100644 --- a/src/wifi/model/wifi-phy-state.h +++ b/src/wifi/model/wifi-phy-state.h @@ -22,6 +22,8 @@ #ifndef WIFI_PHY_STATE_H #define WIFI_PHY_STATE_H +#include "ns3/fatal-error.h" + /** * The state of the PHY layer. */ @@ -58,4 +60,35 @@ enum WifiPhyState OFF }; +/** +* \brief Stream insertion operator. +* +* \param os the stream +* \param state the state +* \returns a reference to the stream +*/ +inline std::ostream& operator<< (std::ostream& os, WifiPhyState state) +{ + switch (state) + { + case IDLE: + return (os << "IDLE"); + case CCA_BUSY: + return (os << "CCA_BUSY"); + case TX: + return (os << "TX"); + case RX: + return (os << "RX"); + case SWITCHING: + return (os << "SWITCHING"); + case SLEEP: + return (os << "SLEEP"); + case OFF: + return (os << "OFF"); + default: + NS_FATAL_ERROR ("Invalid state"); + return (os << "INVALID"); + } +} + #endif /* WIFI_PHY_STATE_H */ diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 8ecb05827..e9d4f43d4 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -4135,30 +4135,6 @@ WifiPhy::AssignStreams (int64_t stream) return 1; } -std::ostream& operator<< (std::ostream& os, WifiPhyState state) -{ - switch (state) - { - case WifiPhyState::IDLE: - return (os << "IDLE"); - case WifiPhyState::CCA_BUSY: - return (os << "CCA_BUSY"); - case WifiPhyState::TX: - return (os << "TX"); - case WifiPhyState::RX: - return (os << "RX"); - case WifiPhyState::SWITCHING: - return (os << "SWITCHING"); - case WifiPhyState::SLEEP: - return (os << "SLEEP"); - case WifiPhyState::OFF: - return (os << "OFF"); - default: - NS_FATAL_ERROR ("Invalid WifiPhy state"); - return (os << "INVALID"); - } -} - } //namespace ns3 namespace { diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 05d7e0b4c..040b5163c 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -1998,13 +1998,6 @@ private: Callback m_capabilitiesChangedCallback; //!< Callback when PHY capabilities changed }; -/** - * \param os output stream - * \param state wifi state to stringify - * \return output stream - */ -std::ostream& operator<< (std::ostream& os, WifiPhyState state); - } //namespace ns3 #endif /* WIFI_PHY_H */