akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Muktadir R Chowdhury | 800833b | 2016-07-29 13:43:59 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2016, The University of Memphis, |
Vince Lehman | cae33b6 | 2015-06-05 09:21:30 -0500 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 6 | * |
| 7 | * This file is part of NLSR (Named-data Link State Routing). |
| 8 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 9 | * |
| 10 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 11 | * of the GNU General Public License as published by the Free Software Foundation, |
| 12 | * either version 3 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE. See the GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along with |
| 19 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 20 | **/ |
Vince Lehman | cae33b6 | 2015-06-05 09:21:30 -0500 | [diff] [blame] | 21 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 22 | #ifndef NLSR_NAME_PREFIX_TABLE_HPP |
| 23 | #define NLSR_NAME_PREFIX_TABLE_HPP |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 24 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 25 | #include "name-prefix-table-entry.hpp" |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 26 | #include "routing-table-entry.hpp" |
| 27 | |
Vince Lehman | cae33b6 | 2015-06-05 09:21:30 -0500 | [diff] [blame] | 28 | #include <list> |
| 29 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 30 | namespace nlsr { |
| 31 | class Nlsr; |
| 32 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 33 | class NamePrefixTable |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 34 | { |
| 35 | public: |
Vince Lehman | cae33b6 | 2015-06-05 09:21:30 -0500 | [diff] [blame] | 36 | |
| 37 | typedef std::list<NamePrefixTableEntry> NptEntryList; |
| 38 | typedef NptEntryList::const_iterator const_iterator; |
| 39 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 40 | NamePrefixTable(Nlsr& nlsr) |
| 41 | : m_nlsr(nlsr) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 42 | { |
| 43 | } |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 44 | |
| 45 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 46 | addEntry(const ndn::Name& name, const ndn::Name& destRouter); |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 47 | |
| 48 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 49 | removeEntry(const ndn::Name& name, const ndn::Name& destRouter); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 50 | |
| 51 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 52 | updateWithNewRoute(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 53 | |
| 54 | void |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 55 | writeLog(); |
| 56 | |
Vince Lehman | cae33b6 | 2015-06-05 09:21:30 -0500 | [diff] [blame] | 57 | const_iterator |
| 58 | begin() const; |
| 59 | |
| 60 | const_iterator |
| 61 | end() const; |
| 62 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 63 | private: |
| 64 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 65 | addEntry(const ndn::Name& name, RoutingTableEntry& rte); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 66 | |
| 67 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 68 | removeEntry(const ndn::Name& name, RoutingTableEntry& rte); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 69 | |
| 70 | private: |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 71 | Nlsr& m_nlsr; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 72 | std::list<NamePrefixTableEntry> m_table; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 73 | }; |
| 74 | |
Vince Lehman | cae33b6 | 2015-06-05 09:21:30 -0500 | [diff] [blame] | 75 | inline NamePrefixTable::const_iterator |
| 76 | NamePrefixTable::begin() const |
| 77 | { |
| 78 | return m_table.begin(); |
| 79 | } |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 80 | |
Vince Lehman | cae33b6 | 2015-06-05 09:21:30 -0500 | [diff] [blame] | 81 | inline NamePrefixTable::const_iterator |
| 82 | NamePrefixTable::end() const |
| 83 | { |
| 84 | return m_table.end(); |
| 85 | } |
| 86 | |
| 87 | std::ostream& |
| 88 | operator<<(std::ostream& os, const NamePrefixTable& table); |
| 89 | |
| 90 | } // namespace nlsr |
| 91 | |
| 92 | #endif // NLSR_NAME_PREFIX_TABLE_HPP |