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_HPP |
| 8 | #define NFD_TABLE_PIT_HPP |
| 9 | |
Haowei Yuan | 78c84d1 | 2014-02-27 15:35:13 -0600 | [diff] [blame] | 10 | #include "name-tree.hpp" |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 11 | #include "pit-entry.hpp" |
Haowei Yuan | 78c84d1 | 2014-02-27 15:35:13 -0600 | [diff] [blame] | 12 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 13 | namespace nfd { |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 14 | namespace 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 | */ |
| 22 | typedef std::vector<shared_ptr<pit::Entry> > DataMatchResult; |
| 23 | |
| 24 | } // namespace pit |
| 25 | |
| 26 | /** \class Pit |
| 27 | * \brief represents the PIT |
| 28 | */ |
| 29 | class Pit : noncopyable |
| 30 | { |
| 31 | public: |
Haowei Yuan | 78c84d1 | 2014-02-27 15:35:13 -0600 | [diff] [blame] | 32 | explicit |
| 33 | Pit(NameTree& nameTree); |
| 34 | |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 35 | ~Pit(); |
Haowei Yuan | 78c84d1 | 2014-02-27 15:35:13 -0600 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * \brief Get the number of items stored in the PIT. |
| 39 | */ |
| 40 | size_t |
| 41 | size() const; |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 42 | |
| 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 Yuan | 78c84d1 | 2014-02-27 15:35:13 -0600 | [diff] [blame] | 55 | |
| 56 | /** |
| 57 | * \brief Erase a PIT Entry |
| 58 | */ |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 59 | void |
Haowei Yuan | 78c84d1 | 2014-02-27 15:35:13 -0600 | [diff] [blame] | 60 | erase(shared_ptr<pit::Entry> pitEntry); |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 61 | |
| 62 | private: |
Haowei Yuan | 78c84d1 | 2014-02-27 15:35:13 -0600 | [diff] [blame] | 63 | NameTree& m_nameTree; |
| 64 | size_t m_nItems; |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
Haowei Yuan | 78c84d1 | 2014-02-27 15:35:13 -0600 | [diff] [blame] | 67 | inline size_t |
| 68 | Pit::size() const |
| 69 | { |
| 70 | return m_nItems; |
| 71 | } |
| 72 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 73 | } // namespace nfd |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 74 | |
| 75 | #endif // NFD_TABLE_PIT_HPP |