Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NFD_TABLE_PIT_ENTRY_HPP |
| 8 | #define NFD_TABLE_PIT_ENTRY_HPP |
| 9 | |
| 10 | #include "pit-in-record.hpp" |
| 11 | #include "pit-out-record.hpp" |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame^] | 12 | #include "core/scheduler.hpp" |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 13 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 14 | namespace nfd { |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 15 | namespace pit { |
| 16 | |
| 17 | /** \class InRecordCollection |
| 18 | * \brief represents an unordered collection of InRecords |
| 19 | */ |
| 20 | typedef std::list< InRecord> InRecordCollection; |
| 21 | |
| 22 | /** \class OutRecordCollection |
| 23 | * \brief represents an unordered collection of OutRecords |
| 24 | */ |
| 25 | typedef std::list<OutRecord> OutRecordCollection; |
| 26 | |
| 27 | /** \class Entry |
| 28 | * \brief represents a PIT entry |
| 29 | */ |
| 30 | class Entry : noncopyable |
| 31 | { |
| 32 | public: |
| 33 | explicit |
| 34 | Entry(const Interest& interest); |
| 35 | |
| 36 | const Interest& |
| 37 | getInterest() const; |
| 38 | |
| 39 | /** \return{ Interest Name } |
| 40 | */ |
| 41 | const Name& |
| 42 | getName() const; |
| 43 | |
| 44 | const InRecordCollection& |
| 45 | getInRecords() const; |
| 46 | |
| 47 | const OutRecordCollection& |
| 48 | getOutRecords() const; |
| 49 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame^] | 50 | /** \brief records a nonce |
| 51 | * |
| 52 | * \return{ true if nonce is new; false if nonce is seen before } |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 53 | */ |
| 54 | bool |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame^] | 55 | addNonce(uint32_t nonce); |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 56 | |
| 57 | /** \brief inserts a InRecord for face, and updates it with interest |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame^] | 58 | * |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 59 | * If InRecord for face exists, the existing one is updated. |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame^] | 60 | * This method does not add the Nonce as a seen Nonce. |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 61 | * \return{ an iterator to the InRecord } |
| 62 | */ |
| 63 | InRecordCollection::iterator |
| 64 | insertOrUpdateInRecord(shared_ptr<Face> face, const Interest& interest); |
| 65 | |
| 66 | /// deletes all InRecords |
| 67 | void |
| 68 | deleteInRecords(); |
| 69 | |
| 70 | /** \brief inserts a OutRecord for face, and updates it with interest |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame^] | 71 | * |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 72 | * If OutRecord for face exists, the existing one is updated. |
| 73 | * \return{ an iterator to the OutRecord } |
| 74 | */ |
| 75 | OutRecordCollection::iterator |
| 76 | insertOrUpdateOutRecord(shared_ptr<Face> face, const Interest& interest); |
| 77 | |
| 78 | /// deletes one OutRecord for face if exists |
| 79 | void |
| 80 | deleteOutRecord(shared_ptr<Face> face); |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame^] | 81 | |
| 82 | public: |
| 83 | EventId m_unsatisfyTimer; |
| 84 | EventId m_stragglerTimer; |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 85 | |
| 86 | private: |
| 87 | std::set<uint32_t> m_nonces; |
| 88 | const Interest m_interest; |
| 89 | InRecordCollection m_inRecords; |
| 90 | OutRecordCollection m_outRecords; |
| 91 | }; |
| 92 | |
| 93 | inline const Interest& |
| 94 | Entry::getInterest() const |
| 95 | { |
| 96 | return m_interest; |
| 97 | } |
| 98 | |
| 99 | } // namespace pit |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 100 | } // namespace nfd |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 101 | |
| 102 | #endif // NFD_TABLE_PIT_ENTRY_HPP |