diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 5b2f6bfc2..1228a9d89 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -286,7 +286,6 @@ const std::set WifiPhy::m_frequencyChannels = { std::make_tuple (207, 6975, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) } }; -std::map > WifiPhy::m_staticPhyEntities; //will be filled by g_constructor_XXX TypeId WifiPhy::GetTypeId (void) @@ -620,6 +619,13 @@ WifiPhy::DoDispose (void) m_phyEntities.clear (); } +std::map > & +WifiPhy::GetStaticPhyEntities (void) +{ + static std::map > g_staticPhyEntities; + return g_staticPhyEntities; +} + Ptr WifiPhy::GetState (void) const { @@ -864,8 +870,8 @@ WifiPhy::CalculateSnr (const WifiTxVector& txVector, double ber) const const Ptr WifiPhy::GetStaticPhyEntity (WifiModulationClass modulation) { - const auto it = m_staticPhyEntities.find (modulation); - NS_ABORT_MSG_IF (it == m_staticPhyEntities.end (), "Unimplemented Wi-Fi modulation class"); + const auto it = GetStaticPhyEntities ().find (modulation); + NS_ABORT_MSG_IF (it == GetStaticPhyEntities ().end (), "Unimplemented Wi-Fi modulation class"); return it->second; } @@ -881,15 +887,15 @@ void WifiPhy::AddStaticPhyEntity (WifiModulationClass modulation, Ptr phyEntity) { NS_LOG_FUNCTION (modulation); - NS_ASSERT_MSG (m_staticPhyEntities.find (modulation) == m_staticPhyEntities.end (), "The PHY entity has already been added. The setting should only be done once per modulation class"); - m_staticPhyEntities[modulation] = phyEntity; + NS_ASSERT_MSG (GetStaticPhyEntities ().find (modulation) == GetStaticPhyEntities ().end (), "The PHY entity has already been added. The setting should only be done once per modulation class"); + GetStaticPhyEntities ()[modulation] = phyEntity; } void WifiPhy::AddPhyEntity (WifiModulationClass modulation, Ptr phyEntity) { NS_LOG_FUNCTION (this << modulation); - NS_ABORT_MSG_IF (m_staticPhyEntities.find (modulation) == m_staticPhyEntities.end (), "Cannot add an unimplemented PHY to supported list. Update the former first."); + NS_ABORT_MSG_IF (GetStaticPhyEntities ().find (modulation) == GetStaticPhyEntities ().end (), "Cannot add an unimplemented PHY to supported list. Update the former first."); NS_ASSERT_MSG (m_phyEntities.find (modulation) == m_phyEntities.end (), "The PHY entity has already been added. The setting should only be done once per modulation class"); phyEntity->SetOwner (this); m_phyEntities[modulation] = phyEntity; diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 22643534f..e16a12d4f 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -1167,7 +1167,7 @@ protected: * Add the PHY entity to the map of supported PHY entities for the * given modulation class for the WifiPhy instance. * This is a wrapper method used to check that the PHY entity is - * in the static map of implemented PHY entities (\see m_staticPhyEntities). + * in the static map of implemented PHY entities (\see GetStaticPhyEntities). * In addition, child classes can add their own PHY entities. * * \param modulation the modulation class @@ -1376,12 +1376,13 @@ private: TracedCallback, uint16_t /* frequency (MHz) */, WifiTxVector, MpduInfo, uint16_t /* STA-ID*/> m_phyMonitorSniffTxTrace; /** - * Map of __implemented__ PHY entities. This is used to compute the different + * \return the map of __implemented__ PHY entities. + * This is used to compute the different * amendment-specific parameters in a static manner. * For PHY entities supported by a given WifiPhy instance, * \see m_phyEntities. */ - static std::map > m_staticPhyEntities; + static std::map > & GetStaticPhyEntities (void); WifiPhyStandard m_standard; //!< WifiPhyStandard WifiPhyBand m_band; //!< WifiPhyBand