blob: 0e64386e5db5a0160c40565b99f0ddc9da1ca855 [file] [log] [blame]
Nick Gordonb50e51b2016-07-22 16:05:57 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Nick Gordonc6a85222017-01-03 16:54:34 -06003 * Copyright (c) 2014-2017, The University of Memphis,
Nick Gordonb50e51b2016-07-22 16:05:57 -05004 * 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 * \author Nicholas Gordon <nmgordon@memphis.edu>
21 *
22 **/
23
24#ifndef NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
25#define NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
26
27#include <iostream>
28#include <ndn-cxx/name.hpp>
29#include "nexthop-list.hpp"
30#include "routing-table-entry.hpp"
31
32namespace nlsr {
33class RoutingTablePoolEntry : public RoutingTableEntry
34{
35public:
36 RoutingTablePoolEntry()
37 {
38 }
39
40 ~RoutingTablePoolEntry()
41 {
42 }
43
44 RoutingTablePoolEntry(const ndn::Name& dest)
45 {
46 m_destination = dest;
47 m_useCount = 1;
48 }
49
50 RoutingTablePoolEntry(RoutingTableEntry& rte, uint64_t useCount)
51 {
52 m_destination = rte.getDestination();
53 m_nexthopList = rte.getNexthopList();
54 m_useCount = useCount;
55 }
56
57 RoutingTablePoolEntry(const ndn::Name& dest, uint64_t useCount)
58 {
59 m_destination = dest;
60 m_useCount = useCount;
61 }
62
63 uint64_t
64 getUseCount()
65 {
66 return m_useCount;
67 }
68
69 uint64_t
70 incrementUseCount()
71 {
72 return ++m_useCount;
73 }
74
75 uint64_t
76 decrementUseCount()
77 {
78 if (m_useCount != 0) {
79 return --m_useCount;
80 }
81 return 0;
82 }
83
84 void
85 setNexthopList(NexthopList nhl)
86 {
87 m_nexthopList = nhl;
88 }
89
90private:
91 uint64_t m_useCount;
92
93};
94
95bool
96operator==(const RoutingTablePoolEntry& lhs, const RoutingTablePoolEntry& rhs);
97
98std::ostream&
99operator<<(std::ostream& os, RoutingTablePoolEntry& rtpe);
100
101} // namespace nlsr
102
103#endif // NLSR_ROUTING_TABLE_POOL_ENTRY_HPP