blob: e0b5ba2ff67381cc83158eca323bf370558b99ae [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);
Haowei Yuane1079fc2014-03-08 14:41:25 -060034
Junxiao Shicbba04c2014-01-26 14:21:22 -070035 ~Pit();
Haowei Yuan78c84d12014-02-27 15:35:13 -060036
Haowei Yuane1079fc2014-03-08 14:41:25 -060037 /**
Haowei Yuan78c84d12014-02-27 15:35:13 -060038 * \brief Get the number of items stored in the PIT.
39 */
Haowei Yuane1079fc2014-03-08 14:41:25 -060040 size_t
Haowei Yuan78c84d12014-02-27 15:35:13 -060041 size() const;
Haowei Yuane1079fc2014-03-08 14:41:25 -060042
Junxiao Shicbba04c2014-01-26 14:21:22 -070043 /** \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);
Haowei Yuane1079fc2014-03-08 14:41:25 -060049
Junxiao Shicbba04c2014-01-26 14:21:22 -070050 /** \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 Yuane1079fc2014-03-08 14:41:25 -060055
Haowei Yuan78c84d12014-02-27 15:35:13 -060056 /**
57 * \brief Erase a PIT Entry
Haowei Yuane1079fc2014-03-08 14:41:25 -060058 */
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