Bug 1271 - stronger type checking in SpectrumPhy
This commit is contained in:
@@ -86,6 +86,13 @@ width standards has had a change in capitalization:
|
||||
<li> WIFI_PHY_STANDARD_80211_10Mhz was changed to WIFI_PHY_STANDARD_80211_10MHZ
|
||||
<li> WIFI_PHY_STANDARD_80211_5Mhz was changed to WIFI_PHY_STANDARD_80211_5MHZ
|
||||
</ul>
|
||||
<li> In the SpectrumPhy base class, the methods to get/set the
|
||||
MobilityModel and the NetDevice were previously working with
|
||||
opaque Ptr<Object>. Now all these methods have been
|
||||
changed so that they work with Ptr<NetDevice>
|
||||
and Ptr<MobilityModel> as appropriate. See <A href="https://www.nsnam.org/bugzilla/show_bug.cgi?id=1271">Bug 1271</A> on
|
||||
bugzilla for the motivation.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2>Changed behavior:</h2>
|
||||
|
||||
@@ -104,7 +104,7 @@ LteSpectrumPhy::GetTypeId (void)
|
||||
|
||||
|
||||
|
||||
Ptr<Object>
|
||||
Ptr<NetDevice>
|
||||
LteSpectrumPhy::GetDevice ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
@@ -112,7 +112,7 @@ LteSpectrumPhy::GetDevice ()
|
||||
}
|
||||
|
||||
|
||||
Ptr<Object>
|
||||
Ptr<MobilityModel>
|
||||
LteSpectrumPhy::GetMobility ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
@@ -121,7 +121,7 @@ LteSpectrumPhy::GetMobility ()
|
||||
|
||||
|
||||
void
|
||||
LteSpectrumPhy::SetDevice (Ptr<Object> d)
|
||||
LteSpectrumPhy::SetDevice (Ptr<NetDevice> d)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << d);
|
||||
m_device = d;
|
||||
@@ -129,7 +129,7 @@ LteSpectrumPhy::SetDevice (Ptr<Object> d)
|
||||
|
||||
|
||||
void
|
||||
LteSpectrumPhy::SetMobility (Ptr<Object> m)
|
||||
LteSpectrumPhy::SetMobility (Ptr<MobilityModel> m)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << m);
|
||||
m_mobility = m;
|
||||
|
||||
@@ -65,10 +65,10 @@ public:
|
||||
|
||||
// inherited from SpectrumPhy
|
||||
void SetChannel (Ptr<SpectrumChannel> c);
|
||||
void SetMobility (Ptr<Object> m);
|
||||
void SetDevice (Ptr<Object> d);
|
||||
Ptr<Object> GetMobility ();
|
||||
Ptr<Object> GetDevice ();
|
||||
void SetMobility (Ptr<MobilityModel> m);
|
||||
void SetDevice (Ptr<NetDevice> d);
|
||||
Ptr<MobilityModel> GetMobility ();
|
||||
Ptr<NetDevice> GetDevice ();
|
||||
Ptr<const SpectrumModel> GetRxSpectrumModel () const;
|
||||
|
||||
/**
|
||||
@@ -182,9 +182,9 @@ private:
|
||||
|
||||
EventId m_endRxEventId;
|
||||
|
||||
Ptr<Object> m_mobility;
|
||||
Ptr<MobilityModel> m_mobility;
|
||||
|
||||
Ptr<Object> m_device;
|
||||
Ptr<NetDevice> m_device;
|
||||
|
||||
Ptr<SpectrumChannel> m_channel;
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ AdhocAlohaNoackIdealPhyHelper::Install (NodeContainer c) const
|
||||
dev->SetPhy (phy);
|
||||
|
||||
NS_ASSERT (node);
|
||||
phy->SetMobility (node);
|
||||
phy->SetMobility (node->GetObject<MobilityModel> ());
|
||||
|
||||
NS_ASSERT (dev);
|
||||
phy->SetDevice (dev);
|
||||
|
||||
@@ -142,7 +142,7 @@ SpectrumAnalyzerHelper::Install (NodeContainer c) const
|
||||
dev->SetPhy (phy);
|
||||
|
||||
NS_ASSERT (node);
|
||||
phy->SetMobility (node);
|
||||
phy->SetMobility (node->GetObject<MobilityModel> ());
|
||||
|
||||
NS_ASSERT (dev);
|
||||
phy->SetDevice (dev);
|
||||
|
||||
@@ -215,7 +215,7 @@ SpectrumPhyHelper::Create (Ptr<Node> node, Ptr<NetDevice> device) const
|
||||
NS_ASSERT (m_channel);
|
||||
Ptr<SpectrumPhy> phy = (m_phy.Create ())->GetObject<SpectrumPhy> ();
|
||||
phy->SetChannel (m_channel);
|
||||
phy->SetMobility (node);
|
||||
phy->SetMobility (node->GetObject<MobilityModel> ());
|
||||
phy->SetDevice (device);
|
||||
return phy;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ WaveformGeneratorHelper::Install (NodeContainer c) const
|
||||
dev->SetPhy (phy);
|
||||
|
||||
NS_ASSERT (node);
|
||||
phy->SetMobility (node);
|
||||
phy->SetMobility (node->GetObject<MobilityModel> ());
|
||||
|
||||
NS_ASSERT (dev);
|
||||
phy->SetDevice (dev);
|
||||
|
||||
@@ -126,7 +126,7 @@ HalfDuplexIdealPhy::GetTypeId (void)
|
||||
|
||||
|
||||
|
||||
Ptr<Object>
|
||||
Ptr<NetDevice>
|
||||
HalfDuplexIdealPhy::GetDevice ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
@@ -134,7 +134,7 @@ HalfDuplexIdealPhy::GetDevice ()
|
||||
}
|
||||
|
||||
|
||||
Ptr<Object>
|
||||
Ptr<MobilityModel>
|
||||
HalfDuplexIdealPhy::GetMobility ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
@@ -143,7 +143,7 @@ HalfDuplexIdealPhy::GetMobility ()
|
||||
|
||||
|
||||
void
|
||||
HalfDuplexIdealPhy::SetDevice (Ptr<Object> d)
|
||||
HalfDuplexIdealPhy::SetDevice (Ptr<NetDevice> d)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << d);
|
||||
m_netDevice = d;
|
||||
@@ -151,7 +151,7 @@ HalfDuplexIdealPhy::SetDevice (Ptr<Object> d)
|
||||
|
||||
|
||||
void
|
||||
HalfDuplexIdealPhy::SetMobility (Ptr<Object> m)
|
||||
HalfDuplexIdealPhy::SetMobility (Ptr<MobilityModel> m)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << m);
|
||||
m_mobility = m;
|
||||
|
||||
@@ -94,10 +94,10 @@ public:
|
||||
|
||||
// inherited from SpectrumPhy
|
||||
void SetChannel (Ptr<SpectrumChannel> c);
|
||||
void SetMobility (Ptr<Object> m);
|
||||
void SetDevice (Ptr<Object> d);
|
||||
Ptr<Object> GetMobility ();
|
||||
Ptr<Object> GetDevice ();
|
||||
void SetMobility (Ptr<MobilityModel> m);
|
||||
void SetDevice (Ptr<NetDevice> d);
|
||||
Ptr<MobilityModel> GetMobility ();
|
||||
Ptr<NetDevice> GetDevice ();
|
||||
Ptr<const SpectrumModel> GetRxSpectrumModel () const;
|
||||
void StartRx (Ptr<PacketBurst> p, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration);
|
||||
|
||||
@@ -195,8 +195,8 @@ private:
|
||||
|
||||
EventId m_endRxEventId;
|
||||
|
||||
Ptr<Object> m_mobility;
|
||||
Ptr<Object> m_netDevice;
|
||||
Ptr<MobilityModel> m_mobility;
|
||||
Ptr<NetDevice> m_netDevice;
|
||||
Ptr<SpectrumChannel> m_channel;
|
||||
|
||||
Ptr<SpectrumValue> m_txPsd;
|
||||
|
||||
@@ -222,7 +222,7 @@ MultiModelSpectrumChannel::StartTx (Ptr<PacketBurst> p, Ptr <SpectrumValue> orig
|
||||
NS_ASSERT (originalTxPowerSpectrum);
|
||||
|
||||
|
||||
Ptr<MobilityModel> txMobility = txPhy->GetMobility ()->GetObject<MobilityModel> ();
|
||||
Ptr<MobilityModel> txMobility = txPhy->GetMobility ();
|
||||
SpectrumModelUid_t txSpectrumModelUid = originalTxPowerSpectrum->GetSpectrumModelUid ();
|
||||
NS_LOG_LOGIC (" txSpectrumModelUid " << txSpectrumModelUid);
|
||||
|
||||
@@ -268,7 +268,7 @@ MultiModelSpectrumChannel::StartTx (Ptr<PacketBurst> p, Ptr <SpectrumValue> orig
|
||||
Ptr <SpectrumValue> rxPowerSpectrum = convertedTxPowerSpectrum->Copy ();
|
||||
Time delay = MicroSeconds (0);
|
||||
|
||||
Ptr<MobilityModel> receiverMobility = (*rxPhyIterator)->GetMobility ()->GetObject<MobilityModel> ();
|
||||
Ptr<MobilityModel> receiverMobility = (*rxPhyIterator)->GetMobility ();
|
||||
|
||||
if (txMobility && receiverMobility)
|
||||
{
|
||||
@@ -296,11 +296,11 @@ MultiModelSpectrumChannel::StartTx (Ptr<PacketBurst> p, Ptr <SpectrumValue> orig
|
||||
}
|
||||
|
||||
Ptr<PacketBurst> pktBurstCopy = p->Copy ();
|
||||
Ptr<Object> netDevObj = (*rxPhyIterator)->GetDevice ();
|
||||
if (netDevObj)
|
||||
Ptr<NetDevice> netDev = (*rxPhyIterator)->GetDevice ();
|
||||
if (netDev)
|
||||
{
|
||||
// the receiver has a NetDevice, so we expect that it is attached to a Node
|
||||
uint32_t dstNode = netDevObj->GetObject<NetDevice> ()->GetNode ()->GetId ();
|
||||
uint32_t dstNode = netDev->GetNode ()->GetId ();
|
||||
Simulator::ScheduleWithContext (dstNode, delay, &MultiModelSpectrumChannel::StartRx, this,
|
||||
pktBurstCopy, rxPowerSpectrum, st, duration, *rxPhyIterator);
|
||||
}
|
||||
@@ -337,7 +337,7 @@ MultiModelSpectrumChannel::GetNDevices (void) const
|
||||
Ptr<NetDevice>
|
||||
MultiModelSpectrumChannel::GetDevice (uint32_t i) const
|
||||
{
|
||||
return m_phyVector.at (i)->GetDevice ()->GetObject<NetDevice> ();
|
||||
return m_phyVector.at (i)->GetDevice ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ SingleModelSpectrumChannel::StartTx (Ptr<PacketBurst> p, Ptr <SpectrumValue> txP
|
||||
|
||||
|
||||
|
||||
Ptr<MobilityModel> senderMobility = txPhy->GetMobility ()->GetObject<MobilityModel> ();
|
||||
Ptr<MobilityModel> senderMobility = txPhy->GetMobility ();
|
||||
|
||||
for (PhyList::const_iterator rxPhyIterator = m_phyList.begin ();
|
||||
rxPhyIterator != m_phyList.end ();
|
||||
@@ -127,7 +127,7 @@ SingleModelSpectrumChannel::StartTx (Ptr<PacketBurst> p, Ptr <SpectrumValue> txP
|
||||
Ptr <SpectrumValue> rxPsd = Copy<SpectrumValue> (txPsd);
|
||||
Time delay = MicroSeconds (0);
|
||||
|
||||
Ptr<MobilityModel> receiverMobility = (*rxPhyIterator)->GetMobility ()->GetObject<MobilityModel> ();
|
||||
Ptr<MobilityModel> receiverMobility = (*rxPhyIterator)->GetMobility ();
|
||||
|
||||
if (senderMobility && receiverMobility)
|
||||
{
|
||||
@@ -155,11 +155,11 @@ SingleModelSpectrumChannel::StartTx (Ptr<PacketBurst> p, Ptr <SpectrumValue> txP
|
||||
}
|
||||
|
||||
Ptr<PacketBurst> pktBurstCopy = p->Copy ();
|
||||
Ptr<Object> netDevObj = (*rxPhyIterator)->GetDevice ();
|
||||
if (netDevObj)
|
||||
Ptr<NetDevice> netDev = (*rxPhyIterator)->GetDevice ();
|
||||
if (netDev)
|
||||
{
|
||||
// the receiver has a NetDevice, so we expect that it is attached to a Node
|
||||
uint32_t dstNode = netDevObj->GetObject<NetDevice> ()->GetNode ()->GetId ();
|
||||
uint32_t dstNode = netDev->GetNode ()->GetId ();
|
||||
Simulator::ScheduleWithContext (dstNode, delay, &SingleModelSpectrumChannel::StartRx, this,
|
||||
pktBurstCopy, rxPsd, st, duration, *rxPhyIterator);
|
||||
}
|
||||
|
||||
@@ -89,14 +89,14 @@ SpectrumAnalyzer::GetTypeId (void)
|
||||
|
||||
|
||||
|
||||
Ptr<Object>
|
||||
Ptr<NetDevice>
|
||||
SpectrumAnalyzer::GetDevice ()
|
||||
{
|
||||
return m_netDevice;
|
||||
}
|
||||
|
||||
|
||||
Ptr<Object>
|
||||
Ptr<MobilityModel>
|
||||
SpectrumAnalyzer::GetMobility ()
|
||||
{
|
||||
return m_mobility;
|
||||
@@ -110,7 +110,7 @@ SpectrumAnalyzer::GetRxSpectrumModel () const
|
||||
}
|
||||
|
||||
void
|
||||
SpectrumAnalyzer::SetDevice (Ptr<Object> d)
|
||||
SpectrumAnalyzer::SetDevice (Ptr<NetDevice> d)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << d);
|
||||
m_netDevice = d;
|
||||
@@ -118,7 +118,7 @@ SpectrumAnalyzer::SetDevice (Ptr<Object> d)
|
||||
|
||||
|
||||
void
|
||||
SpectrumAnalyzer::SetMobility (Ptr<Object> m)
|
||||
SpectrumAnalyzer::SetMobility (Ptr<MobilityModel> m)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << m);
|
||||
m_mobility = m;
|
||||
|
||||
@@ -53,10 +53,10 @@ public:
|
||||
|
||||
// inherited from SpectrumPhy
|
||||
void SetChannel (Ptr<SpectrumChannel> c);
|
||||
void SetMobility (Ptr<Object> m);
|
||||
void SetDevice (Ptr<Object> d);
|
||||
Ptr<Object> GetMobility ();
|
||||
Ptr<Object> GetDevice ();
|
||||
void SetMobility (Ptr<MobilityModel> m);
|
||||
void SetDevice (Ptr<NetDevice> d);
|
||||
Ptr<MobilityModel> GetMobility ();
|
||||
Ptr<NetDevice> GetDevice ();
|
||||
Ptr<const SpectrumModel> GetRxSpectrumModel () const;
|
||||
void StartRx (Ptr<PacketBurst> pb, Ptr <const SpectrumValue> rxPowerSpectralDensity, SpectrumType st, Time duration);
|
||||
|
||||
@@ -86,8 +86,8 @@ protected:
|
||||
void DoDispose ();
|
||||
|
||||
private:
|
||||
Ptr<Object> m_mobility;
|
||||
Ptr<Object> m_netDevice;
|
||||
Ptr<MobilityModel> m_mobility;
|
||||
Ptr<NetDevice> m_netDevice;
|
||||
Ptr<SpectrumChannel> m_channel;
|
||||
|
||||
virtual void GenerateReport ();
|
||||
|
||||
@@ -54,28 +54,28 @@ public:
|
||||
*
|
||||
* @param d the NetDevice instance
|
||||
*/
|
||||
virtual void SetDevice (Ptr<Object> d) = 0;
|
||||
virtual void SetDevice (Ptr<NetDevice> d) = 0;
|
||||
|
||||
/**
|
||||
* get the associated NetDevice instance
|
||||
*
|
||||
* @return a Ptr to the associated NetDevice instance
|
||||
*/
|
||||
virtual Ptr<Object> GetDevice () = 0;
|
||||
virtual Ptr<NetDevice> GetDevice () = 0;
|
||||
|
||||
/**
|
||||
* Set the mobility model associated with this device.
|
||||
*
|
||||
* @param m the mobility model
|
||||
*/
|
||||
virtual void SetMobility (Ptr<Object> m) = 0;
|
||||
virtual void SetMobility (Ptr<MobilityModel> m) = 0;
|
||||
|
||||
/**
|
||||
* get the associated MobilityModel instance
|
||||
*
|
||||
* @return a Ptr to the associated NetDevice instance
|
||||
*/
|
||||
virtual Ptr<Object> GetMobility () = 0;
|
||||
virtual Ptr<MobilityModel> GetMobility () = 0;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,14 +89,14 @@ WaveformGenerator::GetTypeId (void)
|
||||
|
||||
|
||||
|
||||
Ptr<Object>
|
||||
Ptr<NetDevice>
|
||||
WaveformGenerator::GetDevice ()
|
||||
{
|
||||
return m_netDevice;
|
||||
}
|
||||
|
||||
|
||||
Ptr<Object>
|
||||
Ptr<MobilityModel>
|
||||
WaveformGenerator::GetMobility ()
|
||||
{
|
||||
return m_mobility;
|
||||
@@ -111,14 +111,14 @@ WaveformGenerator::GetRxSpectrumModel () const
|
||||
}
|
||||
|
||||
void
|
||||
WaveformGenerator::SetDevice (Ptr<Object> d)
|
||||
WaveformGenerator::SetDevice (Ptr<NetDevice> d)
|
||||
{
|
||||
m_netDevice = d;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WaveformGenerator::SetMobility (Ptr<Object> m)
|
||||
WaveformGenerator::SetMobility (Ptr<MobilityModel> m)
|
||||
{
|
||||
m_mobility = m;
|
||||
}
|
||||
|
||||
@@ -56,10 +56,10 @@ public:
|
||||
|
||||
// inherited from SpectrumPhy
|
||||
void SetChannel (Ptr<SpectrumChannel> c);
|
||||
void SetMobility (Ptr<Object> m);
|
||||
void SetDevice (Ptr<Object> d);
|
||||
Ptr<Object> GetMobility ();
|
||||
Ptr<Object> GetDevice ();
|
||||
void SetMobility (Ptr<MobilityModel> m);
|
||||
void SetDevice (Ptr<NetDevice> d);
|
||||
Ptr<MobilityModel> GetMobility ();
|
||||
Ptr<NetDevice> GetDevice ();
|
||||
Ptr<const SpectrumModel> GetRxSpectrumModel () const;
|
||||
void StartRx (Ptr<PacketBurst> p, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration);
|
||||
|
||||
@@ -129,8 +129,8 @@ public:
|
||||
private:
|
||||
virtual void DoDispose (void);
|
||||
|
||||
Ptr<Object> m_mobility;
|
||||
Ptr<Object> m_netDevice;
|
||||
Ptr<MobilityModel> m_mobility;
|
||||
Ptr<NetDevice> m_netDevice;
|
||||
Ptr<SpectrumChannel> m_channel;
|
||||
|
||||
virtual void GenerateWaveform ();
|
||||
|
||||
Reference in New Issue
Block a user