name-prefix-table.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_NAME_PREFIX_TABLE_HPP
23 #define NLSR_NAME_PREFIX_TABLE_HPP
24 
27 #include "signals.hpp"
28 #include "test-access-control.hpp"
29 
30 #include <list>
31 #include <unordered_map>
32 
33 namespace nlsr {
34 class Nlsr;
35 
37 {
38 public:
39  using RoutingTableEntryPool =
40  std::unordered_map<ndn::Name, std::shared_ptr<RoutingTablePoolEntry>>;
41  using NptEntryList = std::list<std::shared_ptr<NamePrefixTableEntry>>;
42  using const_iterator = NptEntryList::const_iterator;
43 
44  NamePrefixTable(Nlsr& nlsr, std::unique_ptr<AfterRoutingChange>& afterRoutingChangeSignal);
45 
47 
61  void
62  addEntry(const ndn::Name& name, const ndn::Name& destRouter);
63 
75  void
76  removeEntry(const ndn::Name& name, const ndn::Name& destRouter);
77 
86  void
87  updateWithNewRoute(const std::list<RoutingTableEntry>& entries);
88 
98  std::shared_ptr<RoutingTablePoolEntry>
100 
109  void
110  deleteRtpeFromPool(std::shared_ptr<RoutingTablePoolEntry> rtpePtr);
111 
112  void
113  writeLog();
114 
116  begin() const;
117 
119  end() const;
120 
122  RoutingTableEntryPool m_rtpool;
123 
124  NptEntryList m_table;
125 
126 private:
127  Nlsr& m_nlsr;
128  ndn::util::signal::Connection m_afterRoutingChangeConnection;
129 };
130 
133 {
134  return m_table.begin();
135 }
136 
139 {
140  return m_table.end();
141 }
142 
143 std::ostream&
144 operator<<(std::ostream& os, const NamePrefixTable& table);
145 
146 } // namespace nlsr
147 
148 #endif // NLSR_NAME_PREFIX_TABLE_HPP
std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
Definition: adjacent.cpp:83
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
std::shared_ptr< RoutingTablePoolEntry > addRtpeToPool(RoutingTablePoolEntry &rtpe)
Adds a pool entry to the pool.
void deleteRtpeFromPool(std::shared_ptr< RoutingTablePoolEntry > rtpePtr)
Removes a pool entry from the pool.
void updateWithNewRoute(const std::list< RoutingTableEntry > &entries)
Updates all routing information in the NPT.
void removeEntry(const ndn::Name &name, const ndn::Name &destRouter)
Removes a destination from a name prefix table entry.
NptEntryList::const_iterator const_iterator
const_iterator end() const
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
const_iterator begin() const
std::list< std::shared_ptr< NamePrefixTableEntry >> NptEntryList
NamePrefixTable(Nlsr &nlsr, std::unique_ptr< AfterRoutingChange > &afterRoutingChangeSignal)
std::unordered_map< ndn::Name, std::shared_ptr< RoutingTablePoolEntry >> RoutingTableEntryPool
void addEntry(const ndn::Name &name, const ndn::Name &destRouter)
Adds a destination to the specified name prefix.