blob: 0c57ba3517f503ab8e90ae50cdb8f0e9d51b573d [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Nick Gordonf8b5bcd2016-08-11 15:06:50 -05003 * Copyright (c) 2014-2016, The University of Memphis,
4 * Regents of the University of California
akmhoque3d06e792014-05-27 16:23:20 -05005 *
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 * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
21 *
22 **/
akmhoquefdbddb12014-05-02 18:35:19 -050023#ifndef NLSR_NEXTHOP_LIST_HPP
24#define NLSR_NEXTHOP_LIST_HPP
akmhoque53353462014-04-22 08:43:45 -050025
akmhoque53353462014-04-22 08:43:45 -050026#include <list>
27#include <iostream>
akmhoquefdbddb12014-05-02 18:35:19 -050028#include <boost/cstdint.hpp>
29
30#include <ndn-cxx/face.hpp>
akmhoque53353462014-04-22 08:43:45 -050031
32#include "nexthop.hpp"
33#include "adjacent.hpp"
34
35namespace nlsr {
36
akmhoquec8a10f72014-04-25 18:42:55 -050037class NexthopList
akmhoque53353462014-04-22 08:43:45 -050038{
39public:
akmhoquec8a10f72014-04-25 18:42:55 -050040 NexthopList()
akmhoque53353462014-04-22 08:43:45 -050041 {
42 }
43
akmhoquec8a10f72014-04-25 18:42:55 -050044 ~NexthopList()
akmhoque53353462014-04-22 08:43:45 -050045 {
46 }
akmhoquefdbddb12014-05-02 18:35:19 -050047
Nick G97e34942016-07-11 14:46:27 -050048
49 /*! \brief Adds a next hop to the list.
50 \param nh The next hop.
51
52 Add next hop to the Next Hop list If next hop is new it is added
53 If next hop already exists in next hop list then updates the route
54 cost with new next hop's route cost
55 */
akmhoque53353462014-04-22 08:43:45 -050056 void
57 addNextHop(NextHop& nh);
58
Nick G97e34942016-07-11 14:46:27 -050059 /*! \brief Removes a next hop.
60 \param nh The next hop.
61
62 Remove a next hop only if both next hop face and route cost are same.
63 */
akmhoque53353462014-04-22 08:43:45 -050064 void
65 removeNextHop(NextHop& nh);
66
67 void
68 sort();
69
akmhoquefdbddb12014-05-02 18:35:19 -050070 size_t
akmhoque53353462014-04-22 08:43:45 -050071 getSize()
72 {
73 return m_nexthopList.size();
74 }
75
76 void
77 reset()
78 {
akmhoquefdbddb12014-05-02 18:35:19 -050079 m_nexthopList.clear();
akmhoque53353462014-04-22 08:43:45 -050080 }
81
82 std::list<NextHop>&
akmhoquefdbddb12014-05-02 18:35:19 -050083 getNextHops()
akmhoque53353462014-04-22 08:43:45 -050084 {
85 return m_nexthopList;
86 }
87
Vince Lehman18841082014-08-19 17:15:24 -050088 typedef std::list<NextHop>::iterator iterator;
Vince Lehman942eb7b2014-10-02 10:09:27 -050089 typedef std::list<NextHop>::const_iterator const_iterator;
Vince Lehman18841082014-08-19 17:15:24 -050090
91 iterator
92 begin()
93 {
94 return m_nexthopList.begin();
95 }
96
97 iterator
98 end()
99 {
100 return m_nexthopList.end();
101 }
102
Vince Lehman942eb7b2014-10-02 10:09:27 -0500103 const_iterator
104 cbegin() const
105 {
106 return m_nexthopList.begin();
107 }
108
109 const_iterator
110 cend() const
111 {
112 return m_nexthopList.end();
113 }
114
akmhoque674b0b12014-05-20 14:33:28 -0500115 void
116 writeLog();
117
akmhoque53353462014-04-22 08:43:45 -0500118private:
119 std::list<NextHop> m_nexthopList;
120};
121
Nick Gordonfad8e252016-08-11 14:21:38 -0500122} // namespace nlsr
akmhoque53353462014-04-22 08:43:45 -0500123
akmhoquefdbddb12014-05-02 18:35:19 -0500124#endif //NLSR_NEXTHOP_LIST_HPP