blob: 012b5aa0a9eba28a1d16ea03994f227c54d41a4c [file] [log] [blame]
Junxiao Shicbba04c2014-01-26 14:21:22 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shifef73e42016-03-29 14:15:05 -07003 * Copyright (c) 2014-2016, Regents of the University of California,
Junxiao Shi1e46be32015-01-08 20:18:05 -07004 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070010 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Alexander Afanasyev28d586a2014-07-10 20:10:54 -070024 */
Junxiao Shicbba04c2014-01-26 14:21:22 -070025
Alexander Afanasyev613e2a92014-04-15 13:36:58 -070026#ifndef NFD_DAEMON_TABLE_PIT_ENTRY_HPP
27#define NFD_DAEMON_TABLE_PIT_ENTRY_HPP
Junxiao Shicbba04c2014-01-26 14:21:22 -070028
29#include "pit-in-record.hpp"
30#include "pit-out-record.hpp"
Junxiao Shid3c792f2014-01-30 00:46:13 -070031#include "core/scheduler.hpp"
Junxiao Shicbba04c2014-01-26 14:21:22 -070032
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080033namespace nfd {
HangZhangcb4fc832014-03-11 16:57:11 +080034
35class NameTree;
36
37namespace name_tree {
38class Entry;
Junxiao Shifef73e42016-03-29 14:15:05 -070039} // namespace name_tree
HangZhangcb4fc832014-03-11 16:57:11 +080040
Junxiao Shicbba04c2014-01-26 14:21:22 -070041namespace pit {
42
Junxiao Shi66f91f82014-05-10 17:28:58 -070043/** \brief represents an unordered collection of InRecords
Junxiao Shicbba04c2014-01-26 14:21:22 -070044 */
45typedef std::list< InRecord> InRecordCollection;
46
Junxiao Shi66f91f82014-05-10 17:28:58 -070047/** \brief represents an unordered collection of OutRecords
Junxiao Shicbba04c2014-01-26 14:21:22 -070048 */
49typedef std::list<OutRecord> OutRecordCollection;
50
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070051/** \brief represents a PIT entry
Junxiao Shicbba04c2014-01-26 14:21:22 -070052 */
Junxiao Shi408a7002014-02-12 17:53:47 -070053class Entry : public StrategyInfoHost, noncopyable
Junxiao Shicbba04c2014-01-26 14:21:22 -070054{
55public:
56 explicit
57 Entry(const Interest& interest);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070058
Junxiao Shicbba04c2014-01-26 14:21:22 -070059 const Interest&
60 getInterest() const;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070061
62 /** \return Interest Name
Junxiao Shicbba04c2014-01-26 14:21:22 -070063 */
64 const Name&
65 getName() const;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070066
Junxiao Shi66f91f82014-05-10 17:28:58 -070067public: // InRecord
68 const InRecordCollection&
69 getInRecords() const;
70
Junxiao Shicbba04c2014-01-26 14:21:22 -070071 /** \brief inserts a InRecord for face, and updates it with interest
Junxiao Shid3c792f2014-01-30 00:46:13 -070072 *
Junxiao Shicbba04c2014-01-26 14:21:22 -070073 * If InRecord for face exists, the existing one is updated.
Junxiao Shid3c792f2014-01-30 00:46:13 -070074 * This method does not add the Nonce as a seen Nonce.
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070075 * \return an iterator to the InRecord
Junxiao Shicbba04c2014-01-26 14:21:22 -070076 */
77 InRecordCollection::iterator
78 insertOrUpdateInRecord(shared_ptr<Face> face, const Interest& interest);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070079
Junxiao Shi66f91f82014-05-10 17:28:58 -070080 /** \brief get the InRecord for face
81 * \return an iterator to the InRecord, or .end if it does not exist
82 */
83 InRecordCollection::const_iterator
Junxiao Shib2bcbcd2014-11-08 09:30:28 -070084 getInRecord(const Face& face) const;
Junxiao Shi66f91f82014-05-10 17:28:58 -070085
Junxiao Shi5e5e4452015-09-24 16:56:52 -070086 /// deletes one InRecord for face if exists
87 void
88 deleteInRecord(const Face& face);
89
Junxiao Shicbba04c2014-01-26 14:21:22 -070090 /// deletes all InRecords
91 void
92 deleteInRecords();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070093
Junxiao Shi66f91f82014-05-10 17:28:58 -070094public: // OutRecord
95 const OutRecordCollection&
96 getOutRecords() const;
97
Junxiao Shicbba04c2014-01-26 14:21:22 -070098 /** \brief inserts a OutRecord for face, and updates it with interest
Junxiao Shid3c792f2014-01-30 00:46:13 -070099 *
Junxiao Shicbba04c2014-01-26 14:21:22 -0700100 * If OutRecord for face exists, the existing one is updated.
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700101 * \return an iterator to the OutRecord
Junxiao Shicbba04c2014-01-26 14:21:22 -0700102 */
103 OutRecordCollection::iterator
104 insertOrUpdateOutRecord(shared_ptr<Face> face, const Interest& interest);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700105
Junxiao Shi66f91f82014-05-10 17:28:58 -0700106 /** \brief get the OutRecord for face
107 * \return an iterator to the OutRecord, or .end if it does not exist
108 */
Junxiao Shi5e5e4452015-09-24 16:56:52 -0700109 OutRecordCollection::iterator
110 getOutRecord(const Face& face);
Junxiao Shi66f91f82014-05-10 17:28:58 -0700111
Junxiao Shicbba04c2014-01-26 14:21:22 -0700112 /// deletes one OutRecord for face if exists
113 void
Junxiao Shib2bcbcd2014-11-08 09:30:28 -0700114 deleteOutRecord(const Face& face);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700115
Junxiao Shid3c792f2014-01-30 00:46:13 -0700116public:
Junxiao Shi1e46be32015-01-08 20:18:05 -0700117 scheduler::EventId m_unsatisfyTimer;
118 scheduler::EventId m_stragglerTimer;
Junxiao Shicbba04c2014-01-26 14:21:22 -0700119
120private:
Alexander Afanasyev28d586a2014-07-10 20:10:54 -0700121 shared_ptr<const Interest> m_interest;
Junxiao Shicbba04c2014-01-26 14:21:22 -0700122 InRecordCollection m_inRecords;
123 OutRecordCollection m_outRecords;
Junxiao Shi57f0f312014-03-16 11:52:20 -0700124
125 static const Name LOCALHOST_NAME;
126 static const Name LOCALHOP_NAME;
127
HangZhangcb4fc832014-03-11 16:57:11 +0800128 shared_ptr<name_tree::Entry> m_nameTreeEntry;
129
130 friend class nfd::NameTree;
131 friend class nfd::name_tree::Entry;
Junxiao Shicbba04c2014-01-26 14:21:22 -0700132};
133
134inline const Interest&
135Entry::getInterest() const
136{
Alexander Afanasyev28d586a2014-07-10 20:10:54 -0700137 return *m_interest;
Junxiao Shicbba04c2014-01-26 14:21:22 -0700138}
139
Junxiao Shib2bcbcd2014-11-08 09:30:28 -0700140inline const InRecordCollection&
141Entry::getInRecords() const
142{
143 return m_inRecords;
144}
145
146inline const OutRecordCollection&
147Entry::getOutRecords() const
148{
149 return m_outRecords;
150}
151
Junxiao Shicbba04c2014-01-26 14:21:22 -0700152} // namespace pit
Alexander Afanasyev18bbf812014-01-29 01:40:23 -0800153} // namespace nfd
Junxiao Shicbba04c2014-01-26 14:21:22 -0700154
Alexander Afanasyev613e2a92014-04-15 13:36:58 -0700155#endif // NFD_DAEMON_TABLE_PIT_ENTRY_HPP