Bug 1271 - stronger type checking in SpectrumPhy

This commit is contained in:
Nicola Baldo
2011-10-04 18:40:50 +02:00
parent 0a28cb2916
commit 35fb5e4032
16 changed files with 66 additions and 59 deletions

View File

@@ -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&#60;Object&#62;. Now all these methods have been
changed so that they work with Ptr&#60;NetDevice&#62;
and Ptr&#60;MobilityModel&#62; 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>

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 ();
}

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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 ();

View File

@@ -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;
/**

View File

@@ -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;
}

View File

@@ -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 ();