make Queue derive from Interface
parent
666e00b097
commit
5cb92847c4
|
@ -55,8 +55,6 @@ PointToPointNetDevice::PointToPointNetDevice (Ptr<Node> node)
|
|||
PointToPointNetDevice::~PointToPointNetDevice()
|
||||
{
|
||||
NS_DEBUG ("PointToPointNetDevice::~PointToPointNetDevice ()");
|
||||
|
||||
delete m_queue;
|
||||
m_queue = 0;
|
||||
}
|
||||
|
||||
|
@ -286,7 +284,7 @@ PointToPointNetDevice::DoCreateTraceResolver (TraceContext const &context)
|
|||
{
|
||||
CompositeTraceResolver *resolver = new CompositeTraceResolver (context);
|
||||
resolver->Add ("queue",
|
||||
MakeCallback (&Queue::CreateTraceResolver, m_queue),
|
||||
MakeCallback (&Queue::CreateTraceResolver, PeekPointer (m_queue)),
|
||||
PointToPointNetDevice::QUEUE);
|
||||
resolver->Add ("rx",
|
||||
m_rxTrace,
|
||||
|
@ -318,7 +316,7 @@ PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch)
|
|||
}
|
||||
|
||||
void
|
||||
PointToPointNetDevice::AddQueue (Queue* q)
|
||||
PointToPointNetDevice::AddQueue (Ptr<Queue> q)
|
||||
{
|
||||
NS_DEBUG ("PointToPointNetDevice::AddQueue (" << q << ")");
|
||||
|
||||
|
@ -335,7 +333,7 @@ PointToPointNetDevice::Receive (Packet& p)
|
|||
ForwardUp (p);
|
||||
}
|
||||
|
||||
Queue*
|
||||
Ptr<Queue>
|
||||
PointToPointNetDevice::GetQueue(void) const
|
||||
{
|
||||
return m_queue;
|
||||
|
|
|
@ -155,7 +155,7 @@ public:
|
|||
* @param queue a pointer to the queue for which object is assuming
|
||||
* ownership.
|
||||
*/
|
||||
void AddQueue(Queue* queue);
|
||||
void AddQueue(Ptr<Queue> queue);
|
||||
/**
|
||||
* Receive a packet from a connected PointToPointChannel.
|
||||
*
|
||||
|
@ -179,7 +179,7 @@ protected:
|
|||
* @see PointToPointTopology
|
||||
* @returns a pointer to the queue.
|
||||
*/
|
||||
Queue* GetQueue(void) const;
|
||||
Ptr<Queue> GetQueue(void) const;
|
||||
/**
|
||||
* Get a copy of the attached Channel
|
||||
*
|
||||
|
@ -296,7 +296,7 @@ private:
|
|||
* @see class Queue
|
||||
* @see class DropTailQueue
|
||||
*/
|
||||
Queue* m_queue;
|
||||
Ptr<Queue> m_queue;
|
||||
/**
|
||||
* The trace source for the packet reception events that the device can
|
||||
* fire.
|
||||
|
|
|
@ -49,13 +49,15 @@ PointToPointTopology::AddPointToPointLink(
|
|||
|
||||
Ptr<PointToPointNetDevice> net1 = MakeNewObject<PointToPointNetDevice> (n1);
|
||||
|
||||
net1->AddQueue(Queue::Default().Copy());
|
||||
Ptr<Queue> q = MakeNewObject<DropTailQueue> ();
|
||||
net1->AddQueue(q);
|
||||
n1->AddDevice (net1);
|
||||
net1->Attach (channel);
|
||||
|
||||
Ptr<PointToPointNetDevice> net2 = MakeNewObject<PointToPointNetDevice> (n2);
|
||||
|
||||
net2->AddQueue(Queue::Default().Copy());
|
||||
q = MakeNewObject<DropTailQueue> ();
|
||||
net2->AddQueue(q);
|
||||
n2->AddDevice (net2);
|
||||
net2->Attach (channel);
|
||||
|
||||
|
@ -137,14 +139,14 @@ Ptr<PointToPointChannel> PointToPointTopology::GetChannel(
|
|||
return nd->GetChannel();
|
||||
}
|
||||
|
||||
Queue* PointToPointTopology::GetQueue(Ptr<Node> n1, Ptr<Node> n2)
|
||||
Ptr<Queue> PointToPointTopology::GetQueue(Ptr<Node> n1, Ptr<Node> n2)
|
||||
{
|
||||
Ptr<NetDevice> nd = GetNetDevice(n1, n2);
|
||||
if (!nd) return 0; // No net device, so in queue
|
||||
return nd->GetQueue();
|
||||
}
|
||||
|
||||
Queue* PointToPointTopology::SetQueue(Ptr<Node> n1, Ptr<Node> n2, const Queue& q)
|
||||
void PointToPointTopology::SetQueue(Ptr<Node> n1, Ptr<Node> n2, Ptr<Queue> q)
|
||||
{
|
||||
Ptr<NetDevice> nd = GetNetDevice(n1, n2);
|
||||
if (!nd) return 0; // No net device, can't set queue
|
||||
|
@ -190,14 +192,14 @@ Ptr<Channel> Topology::GetChannel(Ptr<Node> n1, Ptr<Node> n2)
|
|||
return nd->GetChannel();
|
||||
}
|
||||
|
||||
Queue* Topology::GetQueue(Ptr<Node> n1, Ptr<Node> n2)
|
||||
Ptr<Queue> Topology::GetQueue(Ptr<Node> n1, Ptr<Node> n2)
|
||||
{
|
||||
Ptr<NetDevice> nd = GetNetDevice(n1, n2);
|
||||
if (!nd) return 0; // No net device, so in queue
|
||||
return nd->GetQueue();
|
||||
}
|
||||
|
||||
Queue* Topology::SetQueue(Ptr<Node> n1, Ptr<Node> n2, const Queue& q)
|
||||
void Topology::SetQueue(Ptr<Node> n1, Ptr<Node> n2, Ptr<Queue> q)
|
||||
{
|
||||
Ptr<NetDevice> nd = GetNetDevice(n1, n2);
|
||||
if (!nd) return 0; // No net device, can't set queue
|
||||
|
|
|
@ -26,9 +26,12 @@ NS_DEBUG_COMPONENT_DEFINE ("Queue");
|
|||
|
||||
namespace ns3 {
|
||||
|
||||
const InterfaceId Queue::iid ("Queue");
|
||||
|
||||
Queue* Queue::defaultQueue = 0;
|
||||
|
||||
Queue::Queue() :
|
||||
Interface (Queue::iid),
|
||||
m_nBytes(0),
|
||||
m_nTotalReceivedBytes(0),
|
||||
m_nPackets(0),
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <string>
|
||||
#include <list>
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/interface.h"
|
||||
#include "ns3/callback-trace-source.h"
|
||||
#include "ns3/trace-resolver.h"
|
||||
|
||||
|
@ -35,9 +36,11 @@ namespace ns3 {
|
|||
|
||||
class StringEnumDefaultValue;
|
||||
|
||||
class Queue
|
||||
class Queue : public Interface
|
||||
{
|
||||
public:
|
||||
static const InterfaceId iid;
|
||||
|
||||
enum TraceType {
|
||||
ENQUEUE,
|
||||
DEQUEUE,
|
||||
|
|
Loading…
Reference in New Issue