nexthop-list.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2020, 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_NEXTHOP_LIST_HPP
22 #define NLSR_NEXTHOP_LIST_HPP
23 
24 #include "nexthop.hpp"
25 #include "adjacent.hpp"
26 
27 #include <ndn-cxx/face.hpp>
28 #include <set>
29 
30 namespace nlsr {
31 
33  bool
34  operator() (const NextHop& nh1, const NextHop& nh2) const {
36  return true;
37  }
39  return nh1.getConnectingFaceUri() < nh2.getConnectingFaceUri();
40  }
41  else {
42  return false;
43  }
44  }
45 };
46 
48 {
49 public:
50  NexthopList() = default;
51 
59  void
60  addNextHop(const NextHop& nh);
61 
67  void
68  removeNextHop(const NextHop& nh);
69 
70  size_t
71  size() const
72  {
73  return m_nexthopList.size();
74  }
75 
76  void
78  {
79  m_nexthopList.clear();
80  }
81 
82  const std::set<NextHop, NextHopComparator>&
83  getNextHops() const
84  {
85  return m_nexthopList;
86  }
87 
88  typedef std::set<NextHop, NextHopComparator>::iterator iterator;
89  typedef std::set<NextHop, NextHopComparator>::const_iterator const_iterator;
90  typedef std::set<NextHop, NextHopComparator>::reverse_iterator reverse_iterator;
91 
92  iterator
94  {
95  return m_nexthopList.begin();
96  }
97 
98  iterator
99  end()
100  {
101  return m_nexthopList.end();
102  }
103 
105  cbegin() const
106  {
107  return m_nexthopList.begin();
108  }
109 
111  cend() const
112  {
113  return m_nexthopList.end();
114  }
115 
117  rbegin() const
118  {
119  return m_nexthopList.rbegin();
120  }
121 
123  rend() const
124  {
125  return m_nexthopList.rend();
126  }
127 
128 private:
129  std::set<NextHop, NextHopComparator> m_nexthopList;
130 };
131 
132 bool
134 
135 bool
136 operator==(const NexthopList& lhs, const NexthopList& rhs);
137 
138 bool
139 operator!=(const NexthopList& lhs, const NexthopList& rhs);
140 
141 std::ostream&
142 operator<<(std::ostream& os, const NexthopList& nhl);
143 
144 } // namespace nlsr
145 
146 #endif // NLSR_NEXTHOP_LIST_HPP
Data abstraction for Nexthop.
Definition: nexthop.hpp:44
const std::string & getConnectingFaceUri() const
Definition: nexthop.hpp:68
uint64_t getRouteCostAsAdjustedInteger() const
Definition: nexthop.hpp:80
std::set< NextHop, NextHopComparator >::const_iterator const_iterator
size_t size() const
void addNextHop(const NextHop &nh)
Adds a next hop to the list.
const_iterator cend() const
std::set< NextHop, NextHopComparator >::reverse_iterator reverse_iterator
const_iterator cbegin() const
void removeNextHop(const NextHop &nh)
Remove a next hop from the Next Hop list.
NexthopList()=default
std::set< NextHop, NextHopComparator >::iterator iterator
const std::set< NextHop, NextHopComparator > & getNextHops() const
reverse_iterator rend() const
reverse_iterator rbegin() 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:179
bool operator==(const NamePrefixTableEntry &lhs, const NamePrefixTableEntry &rhs)
bool operator!=(const NexthopList &lhs, const NexthopList &rhs)
bool operator()(const NextHop &nh1, const NextHop &nh2) const