Alexander Afanasyev | 048ae42 | 2012-08-17 17:33:02 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2012 University of California, Los Angeles |
| 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #ifndef NDN_PIT_QUEUE_H |
| 22 | #define NDN_PIT_QUEUE_H |
| 23 | |
| 24 | #include <map> |
Alexander Afanasyev | ec1e395 | 2012-08-20 13:48:15 -0700 | [diff] [blame] | 25 | #include <list> |
Alexander Afanasyev | 048ae42 | 2012-08-17 17:33:02 -0700 | [diff] [blame] | 26 | |
| 27 | #include "ns3/ptr.h" |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame^] | 28 | #include "ns3/ndn-fw-tag.h" |
| 29 | |
| 30 | #include <boost/tuple/tuple.hpp> |
| 31 | #include <boost/shared_ptr.hpp> |
| 32 | #include <boost/make_shared.hpp> |
Alexander Afanasyev | 048ae42 | 2012-08-17 17:33:02 -0700 | [diff] [blame] | 33 | |
| 34 | namespace ns3 { |
| 35 | namespace ndn { |
| 36 | |
| 37 | class Face; |
| 38 | namespace pit { class Entry; } |
| 39 | |
| 40 | class PitQueue |
| 41 | { |
| 42 | public: |
Alexander Afanasyev | ec1e395 | 2012-08-20 13:48:15 -0700 | [diff] [blame] | 43 | PitQueue (); |
| 44 | |
| 45 | void |
| 46 | SetMaxQueueSize (uint32_t size); |
| 47 | |
| 48 | uint32_t |
| 49 | GetMaxQueueSize () const; |
| 50 | |
Alexander Afanasyev | 048ae42 | 2012-08-17 17:33:02 -0700 | [diff] [blame] | 51 | bool |
| 52 | Enqueue (Ptr<Face> inFace, |
| 53 | Ptr<pit::Entry> pitEntry); |
| 54 | |
| 55 | Ptr<pit::Entry> |
| 56 | Pop (); |
| 57 | |
| 58 | // cleanup procedures |
| 59 | void |
| 60 | Remove (Ptr<Face> face); |
| 61 | |
| 62 | void |
| 63 | Remove (Ptr<pit::Entry> entry); |
| 64 | |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame^] | 65 | public: |
Alexander Afanasyev | ec1e395 | 2012-08-20 13:48:15 -0700 | [diff] [blame] | 66 | typedef std::list< Ptr<pit::Entry> > Queue; |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame^] | 67 | typedef std::map< Ptr<Face>, boost::shared_ptr<Queue> > PerInFaceQueue; |
Alexander Afanasyev | ec1e395 | 2012-08-20 13:48:15 -0700 | [diff] [blame] | 68 | |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame^] | 69 | private: |
Alexander Afanasyev | 048ae42 | 2012-08-17 17:33:02 -0700 | [diff] [blame] | 70 | |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame^] | 71 | uint32_t m_maxQueueSize; |
| 72 | PerInFaceQueue::iterator m_lastQueue; // last queue from which interest was taken |
Alexander Afanasyev | ec1e395 | 2012-08-20 13:48:15 -0700 | [diff] [blame] | 73 | PerInFaceQueue m_queues; |
Alexander Afanasyev | 048ae42 | 2012-08-17 17:33:02 -0700 | [diff] [blame] | 74 | }; |
| 75 | |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame^] | 76 | namespace fw { |
| 77 | |
| 78 | class PitQueueTag : |
| 79 | public Tag |
| 80 | { |
| 81 | public: |
| 82 | virtual |
| 83 | ~PitQueueTag () { }; |
| 84 | |
| 85 | typedef boost::tuple< boost::shared_ptr<PitQueue::Queue>, PitQueue::Queue::iterator > Item; |
| 86 | }; |
| 87 | |
| 88 | } // namespace fw |
| 89 | |
Alexander Afanasyev | 048ae42 | 2012-08-17 17:33:02 -0700 | [diff] [blame] | 90 | } // namespace ndn |
| 91 | } // namespace ns3 |
| 92 | |
| 93 | #endif // NDN_PIT_QUEUE_H |