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> |
| 25 | #include <set> |
| 26 | |
| 27 | #include "ns3/ptr.h" |
| 28 | |
| 29 | namespace ns3 { |
| 30 | namespace ndn { |
| 31 | |
| 32 | class Face; |
| 33 | namespace pit { class Entry; } |
| 34 | |
| 35 | class PitQueue |
| 36 | { |
| 37 | public: |
| 38 | bool |
| 39 | Enqueue (Ptr<Face> inFace, |
| 40 | Ptr<pit::Entry> pitEntry); |
| 41 | |
| 42 | Ptr<pit::Entry> |
| 43 | Pop (); |
| 44 | |
| 45 | // cleanup procedures |
| 46 | void |
| 47 | Remove (Ptr<Face> face); |
| 48 | |
| 49 | void |
| 50 | Remove (Ptr<pit::Entry> entry); |
| 51 | |
| 52 | private: |
| 53 | void |
| 54 | DecreasePerFaceCount (Ptr<Face> inFace); |
| 55 | |
| 56 | void |
| 57 | UpdateLastVirtTime (Ptr<Face> inFace); |
| 58 | |
| 59 | private: |
| 60 | // all maps here consider incoming face (the whole Queue structure is per outgoing face) |
| 61 | |
| 62 | double m_lastProcessedVirtualTime; |
| 63 | |
| 64 | typedef std::map< Ptr<Face>, uint32_t > PerInFaceMapOfNumberOfIncomingInterests; |
| 65 | PerInFaceMapOfNumberOfIncomingInterests m_numberEnqueuedInterests; |
| 66 | |
| 67 | typedef std::map< Ptr<Face>, double > PerInFaceMapOfLastVirtualTimes; |
| 68 | PerInFaceMapOfLastVirtualTimes m_lastVirtualTime; |
| 69 | |
| 70 | struct Entry |
| 71 | { |
| 72 | Entry (Ptr<Face> inFace, Ptr<pit::Entry> pitEntry, double virtualTime); |
| 73 | |
| 74 | bool |
| 75 | operator < (const Entry &otherEntry) const; |
| 76 | |
| 77 | Ptr<Face> m_inFace; |
| 78 | Ptr<pit::Entry> m_pitEntry; |
| 79 | double m_virtualTime; |
| 80 | }; |
| 81 | |
| 82 | typedef std::multiset< Entry > PendingInterestsQueue; |
| 83 | PendingInterestsQueue m_queue; |
| 84 | }; |
| 85 | |
| 86 | } // namespace ndn |
| 87 | } // namespace ns3 |
| 88 | |
| 89 | #endif // NDN_PIT_QUEUE_H |