A Discrete-Event Network Simulator
API
drop-tail-queue.h
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 #ifndef DROPTAIL_H
20 #define DROPTAIL_H
21 
22 #include "ns3/queue.h"
23 
24 namespace ns3 {
25 
31 template <typename Item>
32 class DropTailQueue : public Queue<Item>
33 {
34 public:
39  static TypeId GetTypeId (void);
45  DropTailQueue ();
46 
47  virtual ~DropTailQueue ();
48 
49  virtual bool Enqueue (Ptr<Item> item);
50  virtual Ptr<Item> Dequeue (void);
51  virtual Ptr<Item> Remove (void);
52  virtual Ptr<const Item> Peek (void) const;
53 
54 private:
55  using Queue<Item>::begin;
56  using Queue<Item>::end;
60  using Queue<Item>::DoPeek;
61 
63 };
64 
65 
70 template <typename Item>
71 TypeId
73 {
74  static TypeId tid = TypeId (("ns3::DropTailQueue<" + GetTypeParamName<DropTailQueue<Item> > () + ">").c_str ())
76  .SetGroupName ("Network")
77  .template AddConstructor<DropTailQueue<Item> > ()
78  ;
79  return tid;
80 }
81 
82 template <typename Item>
84  Queue<Item> (),
85  NS_LOG_TEMPLATE_DEFINE ("DropTailQueue")
86 {
87  NS_LOG_FUNCTION (this);
88 }
89 
90 template <typename Item>
92 {
93  NS_LOG_FUNCTION (this);
94 }
95 
96 template <typename Item>
97 bool
99 {
100  NS_LOG_FUNCTION (this << item);
101 
102  return DoEnqueue (end (), item);
103 }
104 
105 template <typename Item>
106 Ptr<Item>
108 {
109  NS_LOG_FUNCTION (this);
110 
111  Ptr<Item> item = DoDequeue (begin ());
112 
113  NS_LOG_LOGIC ("Popped " << item);
114 
115  return item;
116 }
117 
118 template <typename Item>
119 Ptr<Item>
121 {
122  NS_LOG_FUNCTION (this);
123 
124  Ptr<Item> item = DoRemove (begin ());
125 
126  NS_LOG_LOGIC ("Removed " << item);
127 
128  return item;
129 }
130 
131 template <typename Item>
134 {
135  NS_LOG_FUNCTION (this);
136 
137  return DoPeek (begin ());
138 }
139 
140 // The following explicit template instantiation declarations prevent all the
141 // translation units including this header file to implicitly instantiate the
142 // DropTailQueue<Packet> class and the DropTailQueue<QueueDiscItem> class. The
143 // unique instances of these classes are explicitly created through the macros
144 // NS_OBJECT_TEMPLATE_CLASS_DEFINE (DropTailQueue,Packet) and
145 // NS_OBJECT_TEMPLATE_CLASS_DEFINE (DropTailQueue,QueueDiscItem), which are included
146 // in drop-tail-queue.cc
147 extern template class DropTailQueue<Packet>;
148 extern template class DropTailQueue<QueueDiscItem>;
149 
150 } // namespace ns3
151 
152 #endif /* DROPTAIL_H */
virtual Ptr< const Item > Peek(void) const
Get a copy of an item in the queue (each subclass defines the position) without removing it...
static TypeId GetTypeId(void)
Get the type ID.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual Ptr< Item > Remove(void)
Remove an item from the Queue (each subclass defines the position), counting it as dropped...
virtual bool Enqueue(Ptr< Item > item)
Place an item into the Queue (each subclass defines the position)
Template class for packet Queues.
virtual ~DropTailQueue()
#define NS_LOG_TEMPLATE_DEFINE(name)
Initialize a reference to a Log component.
Definition: log.h:238
Introspection did not find any typical Config paths.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
DropTailQueue()
DropTailQueue Constructor.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
NS_LOG_TEMPLATE_DECLARE
redefinition of the log component
virtual Ptr< Item > Dequeue(void)
Remove an item from the Queue (each subclass defines the position), counting it as dequeued...
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
A FIFO packet queue that drops tail-end packets on overflow.
std::string GetTypeParamName(void)
Helper function to get the name (as a string) of the type parameter of a template class...
Definition: object-base.h:102