blob: 98665fcd74b4724260f58dcc0b230509b3b69db8 [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"
Junxiao Shid3c792f2014-01-30 00:46:13 -070012#include "core/scheduler.hpp"
Junxiao Shicbba04c2014-01-26 14:21:22 -070013
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080014namespace nfd {
Junxiao Shicbba04c2014-01-26 14:21:22 -070015namespace pit {
16
17/** \class InRecordCollection
18 * \brief represents an unordered collection of InRecords
19 */
20typedef std::list< InRecord> InRecordCollection;
21
22/** \class OutRecordCollection
23 * \brief represents an unordered collection of OutRecords
24 */
25typedef std::list<OutRecord> OutRecordCollection;
26
27/** \class Entry
28 * \brief represents a PIT entry
29 */
30class Entry : noncopyable
31{
32public:
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 Shid3c792f2014-01-30 00:46:13 -070050 /** \brief records a nonce
51 *
52 * \return{ true if nonce is new; false if nonce is seen before }
Junxiao Shicbba04c2014-01-26 14:21:22 -070053 */
54 bool
Junxiao Shid3c792f2014-01-30 00:46:13 -070055 addNonce(uint32_t nonce);
Junxiao Shicbba04c2014-01-26 14:21:22 -070056
57 /** \brief inserts a InRecord for face, and updates it with interest
Junxiao Shid3c792f2014-01-30 00:46:13 -070058 *
Junxiao Shicbba04c2014-01-26 14:21:22 -070059 * If InRecord for face exists, the existing one is updated.
Junxiao Shid3c792f2014-01-30 00:46:13 -070060 * This method does not add the Nonce as a seen Nonce.
Junxiao Shicbba04c2014-01-26 14:21:22 -070061 * \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 Shid3c792f2014-01-30 00:46:13 -070071 *
Junxiao Shicbba04c2014-01-26 14:21:22 -070072 * 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 Shid3c792f2014-01-30 00:46:13 -070081
82public:
83 EventId m_unsatisfyTimer;
84 EventId m_stragglerTimer;
Junxiao Shicbba04c2014-01-26 14:21:22 -070085
86private:
87 std::set<uint32_t> m_nonces;
88 const Interest m_interest;
89 InRecordCollection m_inRecords;
90 OutRecordCollection m_outRecords;
91};
92
93inline const Interest&
94Entry::getInterest() const
95{
96 return m_interest;
97}
98
99} // namespace pit
Alexander Afanasyev18bbf812014-01-29 01:40:23 -0800100} // namespace nfd
Junxiao Shicbba04c2014-01-26 14:21:22 -0700101
102#endif // NFD_TABLE_PIT_ENTRY_HPP