derive WifiPhy from Object and manage it with a Ptr<>

This commit is contained in:
Mathieu Lacage
2007-10-31 12:05:25 +01:00
parent 51590ad30f
commit 92d65a529f
13 changed files with 29 additions and 22 deletions

View File

@@ -165,7 +165,7 @@ DcaTxop::SetLow (MacLow *low)
m_low->RegisterNavListener (m_navListener);
}
void
DcaTxop::SetPhy (WifiPhy *phy)
DcaTxop::SetPhy (Ptr<WifiPhy> phy)
{
m_phyListener = new DcaTxop::PhyListener (m_dcf);
phy->RegisterListener (m_phyListener);

View File

@@ -48,7 +48,7 @@ public:
~DcaTxop ();
void SetLow (MacLow *low);
void SetPhy (WifiPhy *phy);
void SetPhy (Ptr<WifiPhy> phy);
void SetParameters (MacParameters *parameters);
void SetTxMiddle (MacTxMiddle *txMiddle);
void SetTxOkCallback (TxOk callback);

View File

@@ -33,7 +33,9 @@ namespace ns3 {
MacHighAdhoc::MacHighAdhoc ()
{}
MacHighAdhoc::~MacHighAdhoc ()
{}
{
m_phy = 0;
}
void
MacHighAdhoc::SetDevice (WifiNetDevice *device)
@@ -57,7 +59,7 @@ MacHighAdhoc::SetStations (MacStations *stations)
m_stations = stations;
}
void
MacHighAdhoc::SetPhy (WifiPhy *phy)
MacHighAdhoc::SetPhy (Ptr<WifiPhy> phy)
{
m_phy = phy;
}

View File

@@ -44,7 +44,7 @@ public:
void SetForwardCallback (ForwardCallback callback);
void SetDcaTxop (DcaTxop *dca);
void SetStations (MacStations *stations);
void SetPhy (WifiPhy *phy);
void SetPhy (Ptr<WifiPhy> phy);
Mac48Address GetBssid (void) const;
@@ -57,7 +57,7 @@ private:
WifiNetDevice *m_device;
ForwardCallback m_callback;
MacStations *m_stations;
WifiPhy *m_phy;
Ptr<WifiPhy> m_phy;
};
} // namespace ns3

View File

@@ -39,7 +39,9 @@ MacHighNqap::MacHighNqap ()
: m_beaconIntervalUs (500000)
{}
MacHighNqap::~MacHighNqap ()
{}
{
m_phy = 0;
}
void
MacHighNqap::SetDcaTxop (DcaTxop *dca)
@@ -59,7 +61,7 @@ MacHighNqap::SetStations (MacStations *stations)
m_stations = stations;
}
void
MacHighNqap::SetPhy (WifiPhy *phy)
MacHighNqap::SetPhy (Ptr<WifiPhy> phy)
{
m_phy = phy;
}

View File

@@ -44,7 +44,7 @@ public:
void SetDcaTxop (DcaTxop *dca);
void SetDevice (WifiNetDevice *device);
void SetStations (MacStations *stations);
void SetPhy (WifiPhy *phy);
void SetPhy (Ptr<WifiPhy> phy);
void SetForwardCallback (ForwardCallback callback);
void SetBeaconIntervalUs (uint64_t us);
@@ -62,7 +62,7 @@ private:
DcaTxop *m_dca;
WifiNetDevice *m_device;
MacStations *m_stations;
WifiPhy *m_phy;
Ptr<WifiPhy> m_phy;
ForwardCallback m_forwardUp;
uint64_t m_beaconIntervalUs;
};

View File

@@ -69,7 +69,9 @@ MacHighNqsta::MacHighNqsta ()
}
MacHighNqsta::~MacHighNqsta ()
{}
{
m_phy = 0;
}
void
MacHighNqsta::SetDcaTxop (DcaTxop *dca)
@@ -97,7 +99,7 @@ MacHighNqsta::SetDisAssociatedCallback (DisAssociatedCallback callback)
m_disAssociatedCallback = callback;
}
void
MacHighNqsta::SetPhy (WifiPhy *phy)
MacHighNqsta::SetPhy (Ptr<WifiPhy> phy)
{
m_phy = phy;
}

View File

@@ -52,7 +52,7 @@ public:
void SetForwardCallback (ForwardCallback callback);
void SetAssociatedCallback (AssociatedCallback callback);
void SetDisAssociatedCallback (DisAssociatedCallback callback);
void SetPhy (WifiPhy *phy);
void SetPhy (Ptr<WifiPhy> phy);
void SetStations (MacStations *stations);
void SetMaxMissedBeacons (uint32_t missed);
@@ -98,7 +98,7 @@ private:
Time m_beaconWatchdogEnd;
Mac48Address m_bssid;
uint32_t m_maxMissedBeacons;
WifiPhy *m_phy;
Ptr<WifiPhy> m_phy;
MacStations *m_stations;
};

View File

@@ -237,6 +237,7 @@ MacLow::MacLow ()
MacLow::~MacLow ()
{
CancelAllEvents ();
m_phy = 0;
}
void
@@ -304,7 +305,7 @@ MacLow::SetDevice (Ptr<WifiNetDevice> device)
m_device = device;
}
void
MacLow::SetPhy (WifiPhy *phy)
MacLow::SetPhy (Ptr<WifiPhy> phy)
{
m_phy = phy;
}

View File

@@ -152,7 +152,7 @@ public:
~MacLow ();
void SetDevice (Ptr<WifiNetDevice> device);
void SetPhy (WifiPhy *phy);
void SetPhy (Ptr<WifiPhy> phy);
void SetStations (MacStations *stations);
void SetParameters (MacParameters *parameters);
void SetRxCallback (MacLowRxCallback callback);
@@ -216,7 +216,7 @@ private:
void StartDataTxTimers (void);
Ptr<WifiNetDevice> m_device;
WifiPhy *m_phy;
Ptr<WifiPhy> m_phy;
MacStations *m_stations;
MacParameters *m_parameters;
MacLowRxCallback m_rxCallback;

View File

@@ -81,7 +81,7 @@ WifiNetDeviceTraceType::GetTypeName (void) const
static WifiMode
GetWifiModeForPhyMode (WifiPhy *phy, enum WifiDefaultParameters::PhyModeParameter mode)
GetWifiModeForPhyMode (Ptr<WifiPhy> phy, enum WifiDefaultParameters::PhyModeParameter mode)
{
uint32_t phyRate = (uint32_t)mode;
for (uint32_t i= 0; i < phy->GetNModes (); i++)
@@ -112,7 +112,7 @@ void
WifiNetDevice::Construct (void)
{
// the physical layer.
m_phy = new WifiPhy (this);
m_phy = Create<WifiPhy> (this);
// the rate control algorithm
switch (WifiDefaultParameters::GetRateControlAlgorithm ()) {
@@ -282,7 +282,6 @@ WifiNetDevice::DoDispose (void)
NetDevice::DoDispose ();
// cleanup local
m_channel = 0;
delete m_phy;
delete m_stations;
delete m_low;
delete m_rxMiddle;

View File

@@ -120,7 +120,7 @@ protected:
DcaTxop *CreateDca (uint32_t minCw, uint32_t maxCw) const;
Ptr<WifiChannel> m_channel;
WifiPhy *m_phy;
Ptr<WifiPhy> m_phy;
MacStations *m_stations;
MacLow *m_low;
MacRxMiddle *m_rxMiddle;

View File

@@ -27,6 +27,7 @@
#include "ns3/callback.h"
#include "ns3/event-id.h"
#include "ns3/packet.h"
#include "ns3/object.h"
#include "ns3/callback-trace-source.h"
#include "ns3/nstime.h"
#include "ns3/ptr.h"
@@ -68,7 +69,7 @@ public:
class WifiPhy
class WifiPhy : public Object
{
public:
typedef Callback<void,Packet, double, WifiMode, enum WifiPreamble> SyncOkCallback;