blob: 00e8a796138df73d668b3f120b8593d3a1856563 [file] [log] [blame]
Junxiao Shicbba04c2014-01-26 14:21:22 -07001/* -*- 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"
12
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080013namespace nfd {
Junxiao Shicbba04c2014-01-26 14:21:22 -070014namespace pit {
15
16/** \class InRecordCollection
17 * \brief represents an unordered collection of InRecords
18 */
19typedef std::list< InRecord> InRecordCollection;
20
21/** \class OutRecordCollection
22 * \brief represents an unordered collection of OutRecords
23 */
24typedef std::list<OutRecord> OutRecordCollection;
25
26/** \class Entry
27 * \brief represents a PIT entry
28 */
29class Entry : noncopyable
30{
31public:
32 explicit
33 Entry(const Interest& interest);
34
35 const Interest&
36 getInterest() const;
37
38 /** \return{ Interest Name }
39 */
40 const Name&
41 getName() const;
42
43 const InRecordCollection&
44 getInRecords() const;
45
46 const OutRecordCollection&
47 getOutRecords() const;
48
49 /** \brief determines whether nonce is seen before
50 * in an incoming or outgoing Interest
51 */
52 bool
53 isNonceSeen(uint32_t nonce) const;
54
55 /** \brief inserts a InRecord for face, and updates it with interest
56 * If InRecord for face exists, the existing one is updated.
57 * \return{ an iterator to the InRecord }
58 */
59 InRecordCollection::iterator
60 insertOrUpdateInRecord(shared_ptr<Face> face, const Interest& interest);
61
62 /// deletes all InRecords
63 void
64 deleteInRecords();
65
66 /** \brief inserts a OutRecord for face, and updates it with interest
67 * If OutRecord for face exists, the existing one is updated.
68 * \return{ an iterator to the OutRecord }
69 */
70 OutRecordCollection::iterator
71 insertOrUpdateOutRecord(shared_ptr<Face> face, const Interest& interest);
72
73 /// deletes one OutRecord for face if exists
74 void
75 deleteOutRecord(shared_ptr<Face> face);
76
77private:
78 std::set<uint32_t> m_nonces;
79 const Interest m_interest;
80 InRecordCollection m_inRecords;
81 OutRecordCollection m_outRecords;
82};
83
84inline const Interest&
85Entry::getInterest() const
86{
87 return m_interest;
88}
89
90} // namespace pit
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080091} // namespace nfd
Junxiao Shicbba04c2014-01-26 14:21:22 -070092
93#endif // NFD_TABLE_PIT_ENTRY_HPP