Nick Gordon | b50e51b | 2016-07-22 16:05:57 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Nick Gordon | c6a8522 | 2017-01-03 16:54:34 -0600 | [diff] [blame^] | 3 | * Copyright (c) 2014-2017, The University of Memphis, |
Nick Gordon | b50e51b | 2016-07-22 16:05:57 -0500 | [diff] [blame] | 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 | * \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 | |
| 32 | namespace nlsr { |
| 33 | class RoutingTablePoolEntry : public RoutingTableEntry |
| 34 | { |
| 35 | public: |
| 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 | |
| 90 | private: |
| 91 | uint64_t m_useCount; |
| 92 | |
| 93 | }; |
| 94 | |
| 95 | bool |
| 96 | operator==(const RoutingTablePoolEntry& lhs, const RoutingTablePoolEntry& rhs); |
| 97 | |
| 98 | std::ostream& |
| 99 | operator<<(std::ostream& os, RoutingTablePoolEntry& rtpe); |
| 100 | |
| 101 | } // namespace nlsr |
| 102 | |
| 103 | #endif // NLSR_ROUTING_TABLE_POOL_ENTRY_HPP |