diff --git a/src/devices/csma/csma-channel.cc b/src/devices/csma/csma-channel.cc index 0528b4424..2a381532b 100644 --- a/src/devices/csma/csma-channel.cc +++ b/src/devices/csma/csma-channel.cc @@ -291,7 +291,7 @@ CsmaChannel::GetNDevices (void) const } Ptr -CsmaChannel::GetDevice (uint32_t i) const +CsmaChannel::GetCsmaDevice (uint32_t i) const { Ptr< CsmaNetDevice > netDevice; @@ -354,7 +354,7 @@ CsmaChannel::GetState(void) } Ptr -CsmaChannel::DoGetDevice (uint32_t i) const +CsmaChannel::GetDevice (uint32_t i) const { return GetDevice (i); } diff --git a/src/devices/csma/csma-channel.h b/src/devices/csma/csma-channel.h index 6e6c0846e..43bd3dd57 100644 --- a/src/devices/csma/csma-channel.h +++ b/src/devices/csma/csma-channel.h @@ -237,19 +237,19 @@ public: * that have been detached from the channel. */ virtual uint32_t GetNDevices (void) const; + virtual Ptr GetDevice (uint32_t i) const; /** * \param i The deviceId of the net device for which we want the * pointer. * \return Returns the pointer to the net device that is associated * with deviceId i. */ - Ptr GetDevice (uint32_t i) const; + Ptr GetCsmaDevice (uint32_t i) const; virtual DataRate GetDataRate (void); virtual Time GetDelay (void); private: - virtual Ptr DoGetDevice (uint32_t i) const; DataRate m_bps; /// Data rate of the channel Time m_delay; /// Delay of the channel. diff --git a/src/devices/point-to-point/point-to-point-channel.cc b/src/devices/point-to-point/point-to-point-channel.cc index c4a450ead..154f51784 100644 --- a/src/devices/point-to-point/point-to-point-channel.cc +++ b/src/devices/point-to-point/point-to-point-channel.cc @@ -111,7 +111,7 @@ PointToPointChannel::GetNDevices (void) const } Ptr -PointToPointChannel::GetDevice (uint32_t i) const +PointToPointChannel::GetPointToPointDevice (uint32_t i) const { NS_LOG_FUNCTION; NS_ASSERT(i < 2); @@ -133,7 +133,7 @@ PointToPointChannel::GetDelay (void) } Ptr -PointToPointChannel::DoGetDevice (uint32_t i) const +PointToPointChannel::GetDevice (uint32_t i) const { NS_LOG_FUNCTION; return GetDevice (i); diff --git a/src/devices/point-to-point/point-to-point-channel.h b/src/devices/point-to-point/point-to-point-channel.h index 1b339cc63..3df19f4a1 100644 --- a/src/devices/point-to-point/point-to-point-channel.h +++ b/src/devices/point-to-point/point-to-point-channel.h @@ -87,7 +87,8 @@ public: * \param i Index number of the device requested * \returns Ptr to PointToPointNetDevice requested */ - Ptr GetDevice (uint32_t i) const; + Ptr GetPointToPointDevice (uint32_t i) const; + virtual Ptr GetDevice (uint32_t i) const; /* * \brief Get reference to DataRate for this channel * \returns const reference to underlying DataRate object @@ -104,7 +105,6 @@ private: // Each point to point link has exactly two net devices static const int N_DEVICES = 2; - virtual Ptr DoGetDevice (uint32_t i) const; DataRate m_bps; Time m_delay; diff --git a/src/devices/point-to-point/point-to-point-topology.cc b/src/devices/point-to-point/point-to-point-topology.cc index 0b7ef622f..65aa1e649 100644 --- a/src/devices/point-to-point/point-to-point-topology.cc +++ b/src/devices/point-to-point/point-to-point-topology.cc @@ -72,8 +72,8 @@ PointToPointTopology::GetNetDevice (Ptr n, Ptr chan) // The PointToPoint channel is used to find the relevant NetDevice NS_ASSERT (chan->GetNDevices () == 2); - Ptr nd1 = chan->GetDevice (0); - Ptr nd2 = chan->GetDevice (1); + Ptr nd1 = chan->GetPointToPointDevice (0); + Ptr nd2 = chan->GetPointToPointDevice (1); if ( nd1->GetNode ()->GetId () == n->GetId () ) { found = nd1; diff --git a/src/devices/wifi/wifi-channel.cc b/src/devices/wifi/wifi-channel.cc index 1cc9d9076..cec9770ad 100644 --- a/src/devices/wifi/wifi-channel.cc +++ b/src/devices/wifi/wifi-channel.cc @@ -117,7 +117,7 @@ WifiChannel::GetNDevices (void) const return m_deviceList.size (); } Ptr -WifiChannel::DoGetDevice (uint32_t i) const +WifiChannel::GetDevice (uint32_t i) const { return m_deviceList[i].first; } diff --git a/src/devices/wifi/wifi-channel.h b/src/devices/wifi/wifi-channel.h index 3f0adc6ee..88789b8a2 100644 --- a/src/devices/wifi/wifi-channel.h +++ b/src/devices/wifi/wifi-channel.h @@ -61,6 +61,16 @@ public: */ virtual uint32_t GetNDevices (void) const; + /** + * \param i index of the requested network interface. + * \returns the requested network interfaces connected to + * this channel. + * + * Overriden from the NetDevice base class. + * Indexes start at 0 and end at n-1. + */ + virtual Ptr GetDevice (uint32_t i) const; + /** * \param loss the new propagation loss model. */ @@ -97,15 +107,6 @@ private: typedef std::vector, Ptr > > DeviceList; void Receive (uint32_t i, Ptr packet, double rxPowerDbm, WifiMode txMode, WifiPreamble preamble) const; - /** - * \param i index of the requested network interface. - * \returns the requested network interfaces connected to - * this channel. - * - * Overriden from the NetDevice base class. - * Indexes start at 0 and end at n-1. - */ - virtual Ptr DoGetDevice (uint32_t i) const ; DeviceList m_deviceList; diff --git a/src/node/channel.cc b/src/node/channel.cc index 715faf0ff..2e8eb50ba 100644 --- a/src/node/channel.cc +++ b/src/node/channel.cc @@ -67,10 +67,4 @@ Channel::GetName(void) return m_name; } - Ptr -Channel::GetDevice (uint32_t i) const -{ - return DoGetDevice (i); -} - } // namespace ns3 diff --git a/src/node/channel.h b/src/node/channel.h index e3e5ca0c0..28648841b 100644 --- a/src/node/channel.h +++ b/src/node/channel.h @@ -52,18 +52,14 @@ public: /** * \param i index of NetDevice to retrieve * \returns one of the NetDevices connected to this channel. + * + * This method must be implemented by subclasses. */ - Ptr GetDevice (uint32_t i) const; + virtual Ptr GetDevice (uint32_t i) const = 0; protected: virtual ~Channel (); std::string m_name; - -private: - /* - * This method must be implemented by subclasses. - */ - virtual Ptr DoGetDevice (uint32_t i) const = 0; }; }; // namespace ns3 diff --git a/src/node/simple-channel.cc b/src/node/simple-channel.cc index f14968b39..642780370 100644 --- a/src/node/simple-channel.cc +++ b/src/node/simple-channel.cc @@ -45,7 +45,7 @@ SimpleChannel::GetNDevices (void) const return m_devices.size (); } Ptr -SimpleChannel::DoGetDevice (uint32_t i) const +SimpleChannel::GetDevice (uint32_t i) const { return m_devices[i]; } diff --git a/src/node/simple-channel.h b/src/node/simple-channel.h index 219207575..526948e2e 100644 --- a/src/node/simple-channel.h +++ b/src/node/simple-channel.h @@ -22,9 +22,9 @@ public: void Add (Ptr device); virtual uint32_t GetNDevices (void) const; + virtual Ptr GetDevice (uint32_t i) const; private: - virtual Ptr DoGetDevice (uint32_t i) const; std::vector > m_devices; };