network: Change GetNDevices returned type in channel class and all subclasses to properly fix Visual Studio warnings
--- a/CHANGES.html Thu May 31 23:18:15 2018 +0200
+++ b/CHANGES.html Fri Jun 01 00:07:24 2018 +0200
@@ -87,6 +87,7 @@
<li>The Mode and QueueLimit attributes of the PieQueueDisc class, that had been deprecated in favor of the MaxSize attribute in ns-3.28, have now been removed and cannot be used anymore. Likewise, the methods to get/set the old attributes have been removed as well. The GetMaxSize/SetMaxSize methods of the base QueueDisc class must be used instead.</li>
<li>The Mode and QueueLimit attributes of the RedQueueDisc class, that had been deprecated in favor of the MaxSize attribute in ns-3.28, have now been removed and cannot be used anymore. Likewise, the methods to get/set the old attributes have been removed as well. The GetMaxSize/SetMaxSize methods of the base QueueDisc class must be used instead.</li>
<li> Several traffic generating applications have additional trace sources that export not only the transmitted or received packet but also the source and destination addresses.</li>
+ <li>The returned type of <b>GetNDevices</b> methods in <b>Channel</b> and subclasses derived from it were changed from uint32_t to std::size_t. Likewise, the input parameter type of <b>GetDevice</b> in <b>Channel</b> and its subclasses were changed from uint32_t to std::size_t.</li>
</ul>
<h2>Changes to build system:</h2>
<ul>
--- a/src/bridge/model/bridge-channel.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/bridge/model/bridge-channel.cc Fri Jun 01 00:07:24 2018 +0200
@@ -61,7 +61,7 @@
m_bridgedChannels.push_back (bridgedChannel);
}
-uint32_t
+std::size_t
BridgeChannel::GetNDevices (void) const
{
uint32_t ndevices = 0;
@@ -75,9 +75,9 @@
Ptr<NetDevice>
-BridgeChannel::GetDevice (uint32_t i) const
+BridgeChannel::GetDevice (std::size_t i) const
{
- uint32_t ndevices = 0;
+ std::size_t ndevices = 0;
for (std::vector< Ptr<Channel> >::const_iterator iter = m_bridgedChannels.begin ();
iter != m_bridgedChannels.end (); iter++)
{
--- a/src/bridge/model/bridge-channel.h Thu May 31 23:18:15 2018 +0200
+++ b/src/bridge/model/bridge-channel.h Fri Jun 01 00:07:24 2018 +0200
@@ -51,8 +51,8 @@
void AddChannel (Ptr<Channel> bridgedChannel);
// virtual methods implementation, from Channel
- virtual uint32_t GetNDevices (void) const;
- virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
+ virtual std::size_t GetNDevices (void) const;
+ virtual Ptr<NetDevice> GetDevice (std::size_t i) const;
private:
--- a/src/csma/model/csma-channel.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/csma/model/csma-channel.cc Fri Jun 01 00:07:24 2018 +0200
@@ -268,17 +268,16 @@
return numActDevices;
}
-uint32_t
+std::size_t
CsmaChannel::GetNDevices (void) const
{
- return (m_deviceList.size ());
+ return m_deviceList.size ();
}
Ptr<CsmaNetDevice>
-CsmaChannel::GetCsmaDevice (uint32_t i) const
+CsmaChannel::GetCsmaDevice (std::size_t i) const
{
- Ptr<CsmaNetDevice> netDevice = m_deviceList[i].devicePtr;
- return netDevice;
+ return m_deviceList[i].devicePtr;
}
int32_t
@@ -336,7 +335,7 @@
}
Ptr<NetDevice>
-CsmaChannel::GetDevice (uint32_t i) const
+CsmaChannel::GetDevice (std::size_t i) const
{
return GetCsmaDevice (i);
}
--- a/src/csma/model/csma-channel.h Thu May 31 23:18:15 2018 +0200
+++ b/src/csma/model/csma-channel.h Fri Jun 01 00:07:24 2018 +0200
@@ -256,7 +256,7 @@
* \return Returns the total number of devices including devices
* that have been detached from the channel.
*/
- virtual uint32_t GetNDevices (void) const;
+ virtual std::size_t GetNDevices (void) const;
/**
* \return Get a NetDevice pointer to a connected network device.
@@ -265,7 +265,7 @@
* \return Returns the pointer to the net device that is associated
* with deviceId i.
*/
- virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
+ virtual Ptr<NetDevice> GetDevice (std::size_t i) const;
/**
* \return Get a CsmaNetDevice pointer to a connected network device.
@@ -275,7 +275,7 @@
* \return Returns the pointer to the net device that is associated
* with deviceId i.
*/
- Ptr<CsmaNetDevice> GetCsmaDevice (uint32_t i) const;
+ Ptr<CsmaNetDevice> GetCsmaDevice (std::size_t i) const;
/**
* Get the assigned data rate of the channel
--- a/src/internet/model/global-router-interface.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/internet/model/global-router-interface.cc Fri Jun 01 00:07:24 2018 +0200
@@ -1201,7 +1201,7 @@
//
ClearBridgesVisited ();
Ptr<Channel> ch = ndLocal->GetChannel ();
- uint32_t nDevices = ch->GetNDevices ();
+ std::size_t nDevices = ch->GetNDevices ();
NS_ASSERT (nDevices);
NetDeviceContainer deviceList = FindAllNonBridgedDevicesOnLink (ch);
NS_LOG_LOGIC ("Found " << deviceList.GetN () << " non-bridged devices on channel");
@@ -1270,7 +1270,7 @@
NS_LOG_FUNCTION (this << ch);
NetDeviceContainer c;
- for (uint32_t i = 0; i < ch->GetNDevices (); i++)
+ for (std::size_t i = 0; i < ch->GetNDevices (); i++)
{
Ptr<NetDevice> nd = ch->GetDevice (i);
NS_LOG_LOGIC ("checking to see if the device " << nd << " is bridged");
--- a/src/netanim/model/animation-interface.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/netanim/model/animation-interface.cc Fri Jun 01 00:07:24 2018 +0200
@@ -561,7 +561,7 @@
AnimationInterface::GetElementsFromContext (const std::string& context) const
{
std::vector <std::string> elements;
- size_t pos1=0, pos2;
+ std::size_t pos1=0, pos2;
while (pos1 != context.npos)
{
pos1 = context.find ("/",pos1);
@@ -1956,8 +1956,8 @@
else if (channelType == std::string ("ns3::PointToPointChannel"))
{ // Since these are duplex links, we only need to dump
// if srcid < dstid
- uint32_t nChDev = ch->GetNDevices ();
- for (uint32_t j = 0; j < nChDev; ++j)
+ std::size_t nChDev = ch->GetNDevices ();
+ for (std::size_t j = 0; j < nChDev; ++j)
{
Ptr<NetDevice> chDev = ch->GetDevice (j);
uint32_t n2Id = chDev->GetNode ()->GetId ();
--- a/src/network/model/channel.h Thu May 31 23:18:15 2018 +0200
+++ b/src/network/model/channel.h Fri Jun 01 00:07:24 2018 +0200
@@ -65,14 +65,14 @@
*
* This method must be implemented by subclasses.
*/
- virtual uint32_t GetNDevices (void) const = 0;
+ virtual std::size_t GetNDevices (void) const = 0;
/**
* \param i index of NetDevice to retrieve
* \returns one of the NetDevices connected to this channel.
*
* This method must be implemented by subclasses.
*/
- virtual Ptr<NetDevice> GetDevice (uint32_t i) const = 0;
+ virtual Ptr<NetDevice> GetDevice (std::size_t i) const = 0;
private:
uint32_t m_id; //!< Channel id for this channel
--- a/src/network/utils/error-channel.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/network/utils/error-channel.cc Fri Jun 01 00:07:24 2018 +0200
@@ -135,14 +135,14 @@
m_devices.push_back (device);
}
-uint32_t
+std::size_t
ErrorChannel::GetNDevices (void) const
{
return m_devices.size ();
}
Ptr<NetDevice>
-ErrorChannel::GetDevice (uint32_t i) const
+ErrorChannel::GetDevice (std::size_t i) const
{
return m_devices[i];
}
--- a/src/network/utils/error-channel.h Thu May 31 23:18:15 2018 +0200
+++ b/src/network/utils/error-channel.h Fri Jun 01 00:07:24 2018 +0200
@@ -53,8 +53,8 @@
virtual void Add (Ptr<SimpleNetDevice> device);
// inherited from ns3::Channel
- virtual uint32_t GetNDevices (void) const;
- virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
+ virtual std::size_t GetNDevices (void) const;
+ virtual Ptr<NetDevice> GetDevice (std::size_t i) const;
/**
* \brief Set the delay for the odd packets (even ones are not delayed)
--- a/src/network/utils/simple-channel.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/network/utils/simple-channel.cc Fri Jun 01 00:07:24 2018 +0200
@@ -84,7 +84,7 @@
m_devices.push_back (device);
}
-uint32_t
+std::size_t
SimpleChannel::GetNDevices (void) const
{
NS_LOG_FUNCTION (this);
@@ -92,7 +92,7 @@
}
Ptr<NetDevice>
-SimpleChannel::GetDevice (uint32_t i) const
+SimpleChannel::GetDevice (std::size_t i) const
{
NS_LOG_FUNCTION (this << i);
return m_devices[i];
--- a/src/network/utils/simple-channel.h Thu May 31 23:18:15 2018 +0200
+++ b/src/network/utils/simple-channel.h Fri Jun 01 00:07:24 2018 +0200
@@ -94,8 +94,8 @@
virtual void UnBlackList (Ptr<SimpleNetDevice> from, Ptr<SimpleNetDevice> to);
// inherited from ns3::Channel
- virtual uint32_t GetNDevices (void) const;
- virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
+ virtual std::size_t GetNDevices (void) const;
+ virtual Ptr<NetDevice> GetDevice (std::size_t i) const;
private:
Time m_delay; //!< The assigned speed-of-light delay of the channel
--- a/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc Fri Jun 01 00:07:24 2018 +0200
@@ -307,7 +307,7 @@
{
NS_LOG_FUNCTION_NOARGS ();
- for (uint32_t i = 0; i < channel->GetNDevices (); i++)
+ for (std::size_t i = 0; i < channel->GetNDevices (); i++)
{
Ptr<NetDevice> remoteDevice = channel->GetDevice (i);
if (remoteDevice != netDevice)
--- a/src/point-to-point/model/point-to-point-channel.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/point-to-point/model/point-to-point-channel.cc Fri Jun 01 00:07:24 2018 +0200
@@ -106,7 +106,7 @@
return true;
}
-uint32_t
+std::size_t
PointToPointChannel::GetNDevices (void) const
{
NS_LOG_FUNCTION_NOARGS ();
@@ -114,7 +114,7 @@
}
Ptr<PointToPointNetDevice>
-PointToPointChannel::GetPointToPointDevice (uint32_t i) const
+PointToPointChannel::GetPointToPointDevice (std::size_t i) const
{
NS_LOG_FUNCTION_NOARGS ();
NS_ASSERT (i < 2);
@@ -122,7 +122,7 @@
}
Ptr<NetDevice>
-PointToPointChannel::GetDevice (uint32_t i) const
+PointToPointChannel::GetDevice (std::size_t i) const
{
NS_LOG_FUNCTION_NOARGS ();
return GetPointToPointDevice (i);
--- a/src/point-to-point/model/point-to-point-channel.h Thu May 31 23:18:15 2018 +0200
+++ b/src/point-to-point/model/point-to-point-channel.h Fri Jun 01 00:07:24 2018 +0200
@@ -84,21 +84,21 @@
* \brief Get number of devices on this channel
* \returns number of devices on this channel
*/
- virtual uint32_t GetNDevices (void) const;
+ virtual std::size_t GetNDevices (void) const;
/**
* \brief Get PointToPointNetDevice corresponding to index i on this channel
* \param i Index number of the device requested
* \returns Ptr to PointToPointNetDevice requested
*/
- Ptr<PointToPointNetDevice> GetPointToPointDevice (uint32_t i) const;
+ Ptr<PointToPointNetDevice> GetPointToPointDevice (std::size_t i) const;
/**
* \brief Get NetDevice corresponding to index i on this channel
* \param i Index number of the device requested
* \returns Ptr to NetDevice requested
*/
- virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
+ virtual Ptr<NetDevice> GetDevice (std::size_t i) const;
protected:
/**
@@ -147,10 +147,10 @@
private:
/** Each point to point link has exactly two net devices. */
- static const int N_DEVICES = 2;
+ static const std::size_t N_DEVICES = 2;
Time m_delay; //!< Propagation delay
- int32_t m_nDevices; //!< Devices of this channel
+ std::size_t m_nDevices; //!< Devices of this channel
/**
* The trace source for the packet transmission animation events that the
--- a/src/point-to-point/model/point-to-point-net-device.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/point-to-point/model/point-to-point-net-device.cc Fri Jun 01 00:07:24 2018 +0200
@@ -653,7 +653,7 @@
{
NS_LOG_FUNCTION (this);
NS_ASSERT (m_channel->GetNDevices () == 2);
- for (uint32_t i = 0; i < m_channel->GetNDevices (); ++i)
+ for (std::size_t i = 0; i < m_channel->GetNDevices (); ++i)
{
Ptr<NetDevice> tmp = m_channel->GetDevice (i);
if (tmp != this)
--- a/src/spectrum/model/multi-model-spectrum-channel.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/spectrum/model/multi-model-spectrum-channel.cc Fri Jun 01 00:07:24 2018 +0200
@@ -397,18 +397,14 @@
receiver->StartRx (params);
}
-
-
-uint32_t
+std::size_t
MultiModelSpectrumChannel::GetNDevices (void) const
{
return m_numDevices;
-
}
-
Ptr<NetDevice>
-MultiModelSpectrumChannel::GetDevice (uint32_t i) const
+MultiModelSpectrumChannel::GetDevice (std::size_t i) const
{
NS_ASSERT (i < m_numDevices);
// this method implementation is computationally intensive. This
@@ -419,7 +415,7 @@
// acceptable as it is not used much at run time (often not at all).
// On the other hand, having slow SpectrumModel conversion would be
// less acceptable.
- uint32_t j = 0;
+ std::size_t j = 0;
for (RxSpectrumModelInfoMap_t::const_iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin ();
rxInfoIterator != m_rxSpectrumModelInfoMap.end ();
++rxInfoIterator)
--- a/src/spectrum/model/multi-model-spectrum-channel.h Thu May 31 23:18:15 2018 +0200
+++ b/src/spectrum/model/multi-model-spectrum-channel.h Fri Jun 01 00:07:24 2018 +0200
@@ -124,8 +124,8 @@
// inherited from Channel
- virtual uint32_t GetNDevices (void) const;
- virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
+ virtual std::size_t GetNDevices (void) const;
+ virtual Ptr<NetDevice> GetDevice (std::size_t i) const;
/**
* Get the frequency-dependent propagation loss model.
@@ -198,7 +198,7 @@
/**
* Number of devices connected to the channel.
*/
- uint32_t m_numDevices;
+ std::size_t m_numDevices;
/**
* Maximum loss [dB].
--- a/src/spectrum/model/single-model-spectrum-channel.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/spectrum/model/single-model-spectrum-channel.cc Fri Jun 01 00:07:24 2018 +0200
@@ -207,7 +207,6 @@
}
}
}
-
}
void
@@ -217,24 +216,20 @@
receiver->StartRx (params);
}
-
-
-uint32_t
+std::size_t
SingleModelSpectrumChannel::GetNDevices (void) const
{
NS_LOG_FUNCTION (this);
return m_phyList.size ();
}
-
Ptr<NetDevice>
-SingleModelSpectrumChannel::GetDevice (uint32_t i) const
+SingleModelSpectrumChannel::GetDevice (std::size_t i) const
{
NS_LOG_FUNCTION (this << i);
return m_phyList.at (i)->GetDevice ()->GetObject<NetDevice> ();
}
-
void
SingleModelSpectrumChannel::AddPropagationLossModel (Ptr<PropagationLossModel> loss)
{
--- a/src/spectrum/model/single-model-spectrum-channel.h Thu May 31 23:18:15 2018 +0200
+++ b/src/spectrum/model/single-model-spectrum-channel.h Fri Jun 01 00:07:24 2018 +0200
@@ -58,8 +58,8 @@
// inherited from Channel
- virtual uint32_t GetNDevices (void) const;
- virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
+ virtual std::size_t GetNDevices (void) const;
+ virtual Ptr<NetDevice> GetDevice (std::size_t i) const;
/// Container: SpectrumPhy objects
typedef std::vector<Ptr<SpectrumPhy> > PhyList;
--- a/src/uan/model/uan-channel.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/uan/model/uan-channel.cc Fri Jun 01 00:07:24 2018 +0200
@@ -124,14 +124,14 @@
m_prop = prop;
}
-uint32_t
+std::size_t
UanChannel::GetNDevices () const
{
- return static_cast<uint32_t> (m_devList.size ());
+ return m_devList.size ();
}
Ptr<NetDevice>
-UanChannel::GetDevice (uint32_t i) const
+UanChannel::GetDevice (std::size_t i) const
{
return m_devList[i].first;
}
--- a/src/uan/model/uan-channel.h Thu May 31 23:18:15 2018 +0200
+++ b/src/uan/model/uan-channel.h Fri Jun 01 00:07:24 2018 +0200
@@ -61,8 +61,8 @@
static TypeId GetTypeId (void);
// Inherited methods
- virtual uint32_t GetNDevices (void) const;
- virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
+ virtual std::size_t GetNDevices (void) const;
+ virtual Ptr<NetDevice> GetDevice (std::size_t i) const;
/**
* Send a packet out on the channel.
--- a/src/wifi/helper/athstats-helper.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/wifi/helper/athstats-helper.cc Fri Jun 01 00:07:24 2018 +0200
@@ -90,7 +90,7 @@
for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
{
Ptr<Node> node = *i;
- for (uint32_t j = 0; j < node->GetNDevices (); ++j)
+ for (std::size_t j = 0; j < node->GetNDevices (); ++j)
{
devs.Add (node->GetDevice (j));
}
--- a/src/wifi/model/yans-wifi-channel.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/wifi/model/yans-wifi-channel.cc Fri Jun 01 00:07:24 2018 +0200
@@ -128,14 +128,14 @@
phy->StartReceivePreambleAndHeader (packet, DbmToW (rxPowerDbm + phy->GetRxGain ()), duration);
}
-uint32_t
+std::size_t
YansWifiChannel::GetNDevices (void) const
{
- return static_cast<uint32_t> (m_phyList.size ());
+ return m_phyList.size ();
}
Ptr<NetDevice>
-YansWifiChannel::GetDevice (uint32_t i) const
+YansWifiChannel::GetDevice (std::size_t i) const
{
return m_phyList[i]->GetDevice ()->GetObject<NetDevice> ();
}
--- a/src/wifi/model/yans-wifi-channel.h Thu May 31 23:18:15 2018 +0200
+++ b/src/wifi/model/yans-wifi-channel.h Fri Jun 01 00:07:24 2018 +0200
@@ -54,8 +54,8 @@
virtual ~YansWifiChannel ();
//inherited from Channel.
- virtual uint32_t GetNDevices (void) const;
- virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
+ virtual std::size_t GetNDevices (void) const;
+ virtual Ptr<NetDevice> GetDevice (std::size_t i) const;
/**
* Adds the given YansWifiPhy to the PHY list
--- a/src/wimax/model/simple-ofdm-wimax-channel.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/wimax/model/simple-ofdm-wimax-channel.cc Fri Jun 01 00:07:24 2018 +0200
@@ -121,16 +121,16 @@
m_phyList.push_back (o_phy);
}
-uint32_t
+std::size_t
SimpleOfdmWimaxChannel::DoGetNDevices (void) const
{
return m_phyList.size ();
}
Ptr<NetDevice>
-SimpleOfdmWimaxChannel::DoGetDevice (uint32_t index) const
+SimpleOfdmWimaxChannel::DoGetDevice (std::size_t index) const
{
- uint32_t j = 0;
+ std::size_t j = 0;
for (std::list<Ptr<SimpleOfdmWimaxPhy> >::const_iterator iter = m_phyList.begin (); iter != m_phyList.end (); ++iter)
{
if (j == index)
--- a/src/wimax/model/simple-ofdm-wimax-channel.h Thu May 31 23:18:15 2018 +0200
+++ b/src/wimax/model/simple-ofdm-wimax-channel.h Fri Jun 01 00:07:24 2018 +0200
@@ -111,7 +111,7 @@
* Get number of devices function
* \returns the number of devices
*/
- uint32_t DoGetNDevices (void) const;
+ std::size_t DoGetNDevices (void) const;
/**
* End send dummy block function
* \param rxphy the Ptr<SimpleOfdmWimaxPhy>
@@ -123,7 +123,7 @@
* \param i the device index
* \returns the device
*/
- Ptr<NetDevice> DoGetDevice (uint32_t i) const;
+ Ptr<NetDevice> DoGetDevice (std::size_t i) const;
Ptr<PropagationLossModel> m_loss; ///< loss
};
--- a/src/wimax/model/wimax-channel.cc Thu May 31 23:18:15 2018 +0200
+++ b/src/wimax/model/wimax-channel.cc Fri Jun 01 00:07:24 2018 +0200
@@ -51,14 +51,14 @@
DoAttach (phy);
}
-uint32_t
+std::size_t
WimaxChannel::GetNDevices (void) const
{
return DoGetNDevices ();
}
Ptr<NetDevice>
-WimaxChannel::GetDevice (uint32_t index) const
+WimaxChannel::GetDevice (std::size_t index) const
{
return DoGetDevice (index);
}
--- a/src/wimax/model/wimax-channel.h Thu May 31 23:18:15 2018 +0200
+++ b/src/wimax/model/wimax-channel.h Fri Jun 01 00:07:24 2018 +0200
@@ -55,12 +55,12 @@
/**
* \return the number of attached devices
*/
- uint32_t GetNDevices (void) const;
+ std::size_t GetNDevices (void) const;
/**
* \param i the ith device
* \return the ith attached device
*/
- Ptr<NetDevice> GetDevice (uint32_t i) const;
+ Ptr<NetDevice> GetDevice (std::size_t i) const;
/**
* Assign a fixed random variable stream number to the random variables
@@ -83,13 +83,13 @@
* Get number of devices on the channel
* \returns the number of devices
*/
- virtual uint32_t DoGetNDevices (void) const = 0;
+ virtual std::size_t DoGetNDevices (void) const = 0;
/**
* Get device corresponding to index
* \param i the device index
* \returns the device
*/
- virtual Ptr<NetDevice> DoGetDevice (uint32_t i) const = 0;
+ virtual Ptr<NetDevice> DoGetDevice (std::size_t i) const = 0;
};
} // namespace ns3