blob: ff4f0de851e8a0ca0b53d86740cc346bea751dd5 [file] [log] [blame]
Alexander Afanasyev048ae422012-08-17 17:33:02 -07001/* -*- 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 Afanasyevec1e3952012-08-20 13:48:15 -070025#include <list>
Alexander Afanasyev048ae422012-08-17 17:33:02 -070026
27#include "ns3/ptr.h"
Alexander Afanasyeved449cc2012-08-21 11:10:33 -070028#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 Afanasyev048ae422012-08-17 17:33:02 -070033
34namespace ns3 {
35namespace ndn {
36
37class Face;
38namespace pit { class Entry; }
39
40class PitQueue
41{
42public:
Alexander Afanasyevec1e3952012-08-20 13:48:15 -070043 PitQueue ();
44
45 void
46 SetMaxQueueSize (uint32_t size);
47
48 uint32_t
49 GetMaxQueueSize () const;
50
Alexander Afanasyev048ae422012-08-17 17:33:02 -070051 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 Afanasyeved449cc2012-08-21 11:10:33 -070065public:
Alexander Afanasyevec1e3952012-08-20 13:48:15 -070066 typedef std::list< Ptr<pit::Entry> > Queue;
Alexander Afanasyeved449cc2012-08-21 11:10:33 -070067 typedef std::map< Ptr<Face>, boost::shared_ptr<Queue> > PerInFaceQueue;
Alexander Afanasyevec1e3952012-08-20 13:48:15 -070068
Alexander Afanasyeved449cc2012-08-21 11:10:33 -070069private:
Alexander Afanasyeved449cc2012-08-21 11:10:33 -070070 uint32_t m_maxQueueSize;
71 PerInFaceQueue::iterator m_lastQueue; // last queue from which interest was taken
Alexander Afanasyevec1e3952012-08-20 13:48:15 -070072 PerInFaceQueue m_queues;
Alexander Afanasyev048ae422012-08-17 17:33:02 -070073};
74
Alexander Afanasyeved449cc2012-08-21 11:10:33 -070075namespace fw {
76
77class PitQueueTag :
78 public Tag
79{
80public:
Alexander Afanasyev38ba9b22012-08-21 13:32:43 -070081 // map based on addresses, should be good enough
82 typedef std::map< boost::shared_ptr<PitQueue::Queue>, PitQueue::Queue::iterator > MapOfItems;
Alexander Afanasyeved449cc2012-08-21 11:10:33 -070083
Alexander Afanasyev38ba9b22012-08-21 13:32:43 -070084public:
85 virtual
86 ~PitQueueTag () { };
87
88 void
89 InsertQueue (boost::shared_ptr<PitQueue::Queue> item, PitQueue::Queue::iterator iterator);
90
91 void
92 RemoveFromAllQueues ();
93
94 void
95 RemoveFromQueue (boost::shared_ptr<PitQueue::Queue> queue);
96
97private:
98 MapOfItems m_items;
Alexander Afanasyeved449cc2012-08-21 11:10:33 -070099};
100
101} // namespace fw
102
Alexander Afanasyev048ae422012-08-17 17:33:02 -0700103} // namespace ndn
104} // namespace ns3
105
106#endif // NDN_PIT_QUEUE_H