blob: 9ea5aac6ba3e6ac5be1733b9dc99b3372ea36881 [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_HPP
8#define NFD_TABLE_PIT_HPP
9
Haowei Yuan78c84d12014-02-27 15:35:13 -060010#include "name-tree.hpp"
Junxiao Shicbba04c2014-01-26 14:21:22 -070011#include "pit-entry.hpp"
Haowei Yuan78c84d12014-02-27 15:35:13 -060012
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080013namespace nfd {
Junxiao Shicbba04c2014-01-26 14:21:22 -070014namespace pit {
15
16/** \class DataMatchResult
17 * \brief an unordered iterable of all PIT entries matching Data
18 * This type shall support:
19 * iterator<shared_ptr<pit::Entry>> begin()
20 * iterator<shared_ptr<pit::Entry>> end()
21 */
22typedef std::vector<shared_ptr<pit::Entry> > DataMatchResult;
23
24} // namespace pit
25
26/** \class Pit
27 * \brief represents the PIT
28 */
29class Pit : noncopyable
30{
31public:
Haowei Yuan78c84d12014-02-27 15:35:13 -060032 explicit
33 Pit(NameTree& nameTree);
34
Junxiao Shicbba04c2014-01-26 14:21:22 -070035 ~Pit();
Haowei Yuan78c84d12014-02-27 15:35:13 -060036
37 /**
38 * \brief Get the number of items stored in the PIT.
39 */
40 size_t
41 size() const;
Junxiao Shicbba04c2014-01-26 14:21:22 -070042
43 /** \brief inserts a FIB entry for prefix
44 * If an entry for exact same prefix exists, that entry is returned.
45 * \return{ the entry, and true for new entry, false for existing entry }
46 */
47 std::pair<shared_ptr<pit::Entry>, bool>
48 insert(const Interest& interest);
49
50 /** \brief performs a Data match
51 * \return{ an iterable of all PIT entries matching data }
52 */
53 shared_ptr<pit::DataMatchResult>
54 findAllDataMatches(const Data& data) const;
Haowei Yuan78c84d12014-02-27 15:35:13 -060055
56 /**
57 * \brief Erase a PIT Entry
58 */
Junxiao Shicbba04c2014-01-26 14:21:22 -070059 void
Haowei Yuan78c84d12014-02-27 15:35:13 -060060 erase(shared_ptr<pit::Entry> pitEntry);
Junxiao Shicbba04c2014-01-26 14:21:22 -070061
62private:
Haowei Yuan78c84d12014-02-27 15:35:13 -060063 NameTree& m_nameTree;
64 size_t m_nItems;
Junxiao Shicbba04c2014-01-26 14:21:22 -070065};
66
Haowei Yuan78c84d12014-02-27 15:35:13 -060067inline size_t
68Pit::size() const
69{
70 return m_nItems;
71}
72
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080073} // namespace nfd
Junxiao Shicbba04c2014-01-26 14:21:22 -070074
75#endif // NFD_TABLE_PIT_HPP