From 679ce12636e48e4337978d307e3eadb0eb309b98 Mon Sep 17 00:00:00 2001 From: Sebastien Deronne Date: Tue, 26 Apr 2022 19:45:30 +0200 Subject: [PATCH] wifi: Make InterferenceHelper inherit from Object --- src/wifi/model/interference-helper.cc | 21 +++++++++++++++++++++ src/wifi/model/interference-helper.h | 18 ++++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/wifi/model/interference-helper.cc b/src/wifi/model/interference-helper.cc index 256fce3e8..58e41d4d9 100644 --- a/src/wifi/model/interference-helper.cc +++ b/src/wifi/model/interference-helper.cc @@ -34,6 +34,8 @@ namespace ns3 { NS_LOG_COMPONENT_DEFINE ("InterferenceHelper"); +NS_OBJECT_ENSURE_REGISTERED (InterferenceHelper); + /**************************************************************** * PHY event class ****************************************************************/ @@ -178,10 +180,29 @@ InterferenceHelper::InterferenceHelper () m_numRxAntennas (1), m_rxing (false) { + NS_LOG_FUNCTION (this); } InterferenceHelper::~InterferenceHelper () { + NS_LOG_FUNCTION (this); +} + +TypeId +InterferenceHelper::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::InterferenceHelper") + .SetParent () + .SetGroupName ("Wifi") + .AddConstructor () + ; + return tid; +} + +void +InterferenceHelper::DoDispose (void) +{ + NS_LOG_FUNCTION (this); RemoveBands (); m_errorRateModel = 0; } diff --git a/src/wifi/model/interference-helper.h b/src/wifi/model/interference-helper.h index 1ffe27d21..0a513f592 100644 --- a/src/wifi/model/interference-helper.h +++ b/src/wifi/model/interference-helper.h @@ -129,11 +129,17 @@ std::ostream& operator<< (std::ostream& os, const Event &event); * \ingroup wifi * \brief handles interference calculations */ -class InterferenceHelper +class InterferenceHelper : public Object { public: InterferenceHelper (); - ~InterferenceHelper (); + virtual ~InterferenceHelper (); + + /** + * \brief Get the type ID. + * \return the object TypeId + */ + static TypeId GetTypeId (void); /** * Add a frequency band. @@ -268,8 +274,9 @@ public: */ void UpdateEvent (Ptr event, const RxPowerWattPerChannelBand& rxPower); - protected: + void DoDispose (void) override; + /** * Calculate SNR (linear ratio) from the given signal power and noise+interference power. * @@ -313,7 +320,7 @@ private: */ class NiChange { -public: + public: /** * Create a NiChange at the given time and the amount of NI change. * @@ -341,8 +348,7 @@ public: */ Ptr GetEvent (void) const; - -private: + private: double m_power; ///< power in watts Ptr m_event; ///< event };