OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2015 Universita' degli Studi di Napoli Federico II |
| 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 * Author: Stefano Avallone <stavallo@unina.it> |
| 19 */ |
| 20 |
| 21 #ifndef QUEUE_DISC_CONTAINER_H |
| 22 #define QUEUE_DISC_CONTAINER_H |
| 23 |
| 24 #include <stdint.h> |
| 25 #include <vector> |
| 26 #include "ns3/queue-disc.h" |
| 27 |
| 28 namespace ns3 { |
| 29 |
| 30 /** |
| 31 * \ingroup traffic-control |
| 32 * |
| 33 * \brief Holds a vector of ns3::QueueDisc pointers. |
| 34 * |
| 35 * Typically ns-3 QueueDiscs are installed on net devices using a traffic contro
l |
| 36 * helper. The helper Install method takes a NetDeviceContainer which holds |
| 37 * some number of Ptr<NetDevice>. For each of the net devices in the |
| 38 * NetDeviceContainer the helper will instantiate a queue disc and install |
| 39 * it to the net device. For each of the queue discs, the helper also |
| 40 * adds the queue disc into a Container for later use by the caller. |
| 41 * This is that container used to hold the Ptr<QueueDisc> which are |
| 42 * instantiated by the traffic control helper. |
| 43 */ |
| 44 class QueueDiscContainer |
| 45 { |
| 46 public: |
| 47 /// QueueDisc container const iterator |
| 48 typedef std::vector<Ptr<QueueDisc> >::const_iterator ConstIterator; |
| 49 |
| 50 /** |
| 51 * Create an empty QueueDiscContainer. |
| 52 */ |
| 53 QueueDiscContainer (); |
| 54 |
| 55 /** |
| 56 * \param qDisc a queue disc to add to the container |
| 57 * |
| 58 * Create a QueueDiscContainer with exactly one queue disc that has previously |
| 59 * been instantiated |
| 60 */ |
| 61 QueueDiscContainer (Ptr<QueueDisc> qDisc); |
| 62 |
| 63 /** |
| 64 * \brief Get a const iterator which refers to the first QueueDisc in the |
| 65 * container. |
| 66 * |
| 67 * QueueDiscs can be retrieved from the container in two ways. First, |
| 68 * directly by an index into the container, and second, using an iterator. |
| 69 * This method is used in the iterator method and is typically used in a |
| 70 * for-loop to run through the QueueDiscs |
| 71 * |
| 72 * \code |
| 73 * QueueDiscContainer::ConstIterator i; |
| 74 * for (i = container.Begin (); i != container.End (); ++i) |
| 75 * { |
| 76 * (*i)->method (); // some QueueDisc method |
| 77 * } |
| 78 * \endcode |
| 79 * |
| 80 * \returns a const iterator which refers to the first QueueDisc in the contai
ner. |
| 81 */ |
| 82 ConstIterator Begin (void) const; |
| 83 |
| 84 /** |
| 85 * \brief Get a const iterator which indicates past-the-last QueueDisc in the |
| 86 * container. |
| 87 * |
| 88 * QueueDiscs can be retrieved from the container in two ways. First, |
| 89 * directly by an index into the container, and second, using an iterator. |
| 90 * This method is used in the iterator method and is typically used in a |
| 91 * for-loop to run through the QueueDiscs |
| 92 * |
| 93 * \code |
| 94 * QueueDiscContainer::ConstIterator i; |
| 95 * for (i = container.Begin (); i != container.End (); ++i) |
| 96 * { |
| 97 * (*i)->method (); // some QueueDisc method |
| 98 * } |
| 99 * \endcode |
| 100 * |
| 101 * \returns a const iterator which indicates an ending condition for a loop. |
| 102 */ |
| 103 ConstIterator End (void) const; |
| 104 |
| 105 /** |
| 106 * \brief Get the number of Ptr<QueueDisc> stored in this container. |
| 107 * |
| 108 * QueueDiscs can be retrieved from the container in two ways. First, |
| 109 * directly by an index into the container, and second, using an iterator. |
| 110 * This method is used in the direct method and is typically used to |
| 111 * define an ending condition in a for-loop that runs through the stored |
| 112 * QueueDiscs |
| 113 * |
| 114 * \code |
| 115 * uint32_t nQueueDiscs = container.GetN (); |
| 116 * for (uint32_t i = 0 i < nQueueDiscs; ++i) |
| 117 * { |
| 118 * Ptr<QueueDisc> p = container.Get (i) |
| 119 * i->method (); // some QueueDisc method |
| 120 * } |
| 121 * \endcode |
| 122 * |
| 123 * \returns the number of Ptr<QueueDisc> stored in this container. |
| 124 */ |
| 125 uint32_t GetN (void) const; |
| 126 |
| 127 /** |
| 128 * \brief Get the Ptr<QueueDisc> stored in this container at a given |
| 129 * index. |
| 130 * |
| 131 * QueueDiscs can be retrieved from the container in two ways. First, |
| 132 * directly by an index into the container, and second, using an iterator. |
| 133 * This method is used in the direct method and is used to retrieve the |
| 134 * indexed Ptr<QueueDisc>. |
| 135 * |
| 136 * \code |
| 137 * uint32_t nQueueDiscs = container.GetN (); |
| 138 * for (uint32_t i = 0 i < nQueueDiscs; ++i) |
| 139 * { |
| 140 * Ptr<QueueDisc> p = container.Get (i) |
| 141 * i->method (); // some QueueDisc method |
| 142 * } |
| 143 * \endcode |
| 144 * |
| 145 * \param i the index of the requested queue disc pointer. |
| 146 * \returns the requested queue disc pointer. |
| 147 */ |
| 148 Ptr<QueueDisc> Get (uint32_t i) const; |
| 149 |
| 150 /** |
| 151 * \brief Append the contents of another QueueDiscContainer to the end of |
| 152 * this container. |
| 153 * |
| 154 * \param other The QueueDiscContainer to append. |
| 155 */ |
| 156 void Add (QueueDiscContainer other); |
| 157 |
| 158 /** |
| 159 * \brief Append a single Ptr<QueueDisc> to this container. |
| 160 * |
| 161 * \param qDisc The Ptr<QueueDisc> to append. |
| 162 */ |
| 163 void Add (Ptr<QueueDisc> qDisc); |
| 164 |
| 165 private: |
| 166 std::vector<Ptr<QueueDisc> > m_queueDiscs; //!< QueueDiscs smart pointers |
| 167 }; |
| 168 |
| 169 } // namespace ns3 |
| 170 |
| 171 #endif /* QUEUE_DISC_CONTAINER_H */ |
OLD | NEW |