routing-table-pool-entry.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2022, The University of Memphis,
4  * Regents of the University of California
5  *
6  * This file is part of NLSR (Named-data Link State Routing).
7  * See AUTHORS.md for complete list of NLSR authors and contributors.
8  *
9  * NLSR is free software: you can redistribute it and/or modify it under the terms
10  * of the GNU General Public License as published by the Free Software Foundation,
11  * either version 3 of the License, or (at your option) any later version.
12  *
13  * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
22 #define NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
23 
24 #include "routing-table-entry.hpp"
25 #include "nexthop-list.hpp"
26 
27 #include <ndn-cxx/name.hpp>
28 #include <unordered_map>
29 
30 namespace nlsr {
31 
46 class NamePrefixTableEntry;
47 
49 {
50 public:
51  RoutingTablePoolEntry() = default;
52 
53  RoutingTablePoolEntry(const ndn::Name& dest)
54  {
55  m_destination = dest;
56  m_useCount = 1;
57  }
58 
59  RoutingTablePoolEntry(RoutingTableEntry& rte, uint64_t useCount)
60  {
63  m_useCount = useCount;
64  }
65 
66  RoutingTablePoolEntry(const ndn::Name& dest, uint64_t useCount)
67  {
68  m_destination = dest;
69  m_useCount = useCount;
70  }
71 
72  uint64_t
73  getUseCount() const
74  {
75  return m_useCount;
76  }
77 
78  uint64_t
80  {
81  return ++m_useCount;
82  }
83 
84  uint64_t
86  {
87  if (m_useCount != 0) {
88  return --m_useCount;
89  }
90  return 0;
91  }
92 
93  void
95  {
96  m_nexthopList = std::move(nhl);
97  }
98 
99 public:
100  std::unordered_map<ndn::Name, std::weak_ptr<NamePrefixTableEntry>> namePrefixTableEntries;
101 
102 private:
103  uint64_t m_useCount;
104 };
105 
106 bool
108 
109 std::ostream&
110 operator<<(std::ostream& os, RoutingTablePoolEntry& rtpe);
111 
112 } // namespace nlsr
113 
114 #endif // NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
Data abstraction for RouteTableInfo.
const ndn::Name & getDestination() const
NexthopList & getNexthopList()
ndn::Name m_destination
NexthopList m_nexthopList
uint64_t incrementUseCount()
RoutingTablePoolEntry()=default
RoutingTablePoolEntry(const ndn::Name &dest)
RoutingTablePoolEntry(RoutingTableEntry &rte, uint64_t useCount)
void setNexthopList(NexthopList nhl)
std::unordered_map< ndn::Name, std::weak_ptr< NamePrefixTableEntry > > namePrefixTableEntries
uint64_t decrementUseCount()
RoutingTablePoolEntry(const ndn::Name &dest, uint64_t useCount)
uint64_t getUseCount() const
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
Definition: adjacent.cpp:176
bool operator==(const NamePrefixTableEntry &lhs, const NamePrefixTableEntry &rhs)