A Discrete-Event Network Simulator
API
drop-tail-queue.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */
18 
19 #include "ns3/log.h"
20 #include "drop-tail-queue.h"
21 
22 namespace ns3 {
23 
24 NS_LOG_COMPONENT_DEFINE ("DropTailQueue");
25 
26 NS_OBJECT_ENSURE_REGISTERED (DropTailQueue);
27 
29 {
30  static TypeId tid = TypeId ("ns3::DropTailQueue")
31  .SetParent<Queue> ()
32  .SetGroupName ("Network")
33  .AddConstructor<DropTailQueue> ()
34  ;
35  return tid;
36 }
37 
39  Queue (),
40  m_packets ()
41 {
42  NS_LOG_FUNCTION (this);
43 }
44 
46 {
47  NS_LOG_FUNCTION (this);
48 }
49 
50 bool
52 {
53  NS_LOG_FUNCTION (this << item);
54  NS_ASSERT (m_packets.size () == GetNPackets ());
55 
56  m_packets.push (item);
57 
58  return true;
59 }
60 
63 {
64  NS_LOG_FUNCTION (this);
65  NS_ASSERT (m_packets.size () == GetNPackets ());
66 
67  Ptr<QueueItem> item = m_packets.front ();
68  m_packets.pop ();
69 
70  NS_LOG_LOGIC ("Popped " << item);
71 
72  return item;
73 }
74 
77 {
78  NS_LOG_FUNCTION (this);
79  NS_ASSERT (m_packets.size () == GetNPackets ());
80 
81  Ptr<QueueItem> item = m_packets.front ();
82  m_packets.pop ();
83 
84  NS_LOG_LOGIC ("Removed " << item);
85 
86  return item;
87 }
88 
91 {
92  NS_LOG_FUNCTION (this);
93  NS_ASSERT (m_packets.size () == GetNPackets ());
94 
95  return m_packets.front ();
96 }
97 
98 } // namespace ns3
99 
virtual bool DoEnqueue(Ptr< QueueItem > item)
Push an item in the queue.
static TypeId GetTypeId(void)
Get the type ID.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual Ptr< QueueItem > DoDequeue(void)
Pull the item to dequeue from the queue.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
std::queue< Ptr< QueueItem > > m_packets
the items in the queue
Abstract base class for packet Queues.
Definition: queue.h:44
uint32_t GetNPackets(void) const
Definition: queue.cc:213
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual Ptr< const QueueItem > DoPeek(void) const
Peek the front item in the queue.
virtual Ptr< QueueItem > DoRemove(void)
Pull the item to drop from the queue.
DropTailQueue()
DropTailQueue Constructor.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
A FIFO packet queue that drops tail-end packets on overflow.