Vince Lehman | 76c751c | 2014-11-18 17:36:38 -0600 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame^] | 3 | * Copyright (c) 2014-2016, Regents of the University of California, |
Vince Lehman | 76c751c | 2014-11-18 17:36:38 -0600 | [diff] [blame] | 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
| 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | */ |
| 25 | |
| 26 | #ifndef NFD_RIB_RIB_UPDATE_HPP |
| 27 | #define NFD_RIB_RIB_UPDATE_HPP |
| 28 | |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame^] | 29 | #include "core/common.hpp" |
Vince Lehman | 76c751c | 2014-11-18 17:36:38 -0600 | [diff] [blame] | 30 | #include "route.hpp" |
| 31 | |
| 32 | namespace nfd { |
| 33 | namespace rib { |
| 34 | |
| 35 | /** RibUpdate |
| 36 | * \brief represents a route that will be added to or removed from a namespace |
| 37 | * |
| 38 | * \note This type is copyable so that it can be stored in STL containers. |
| 39 | */ |
| 40 | class RibUpdate |
| 41 | { |
| 42 | public: |
| 43 | enum Action { |
| 44 | REGISTER = 0, |
| 45 | UNREGISTER = 1, |
| 46 | |
| 47 | /** \brief An update triggered by a face destruction notification |
| 48 | * |
| 49 | * \note indicates a Route needs to be removed after a face is destroyed |
| 50 | */ |
| 51 | REMOVE_FACE = 2 |
| 52 | }; |
| 53 | |
| 54 | RibUpdate(); |
| 55 | |
| 56 | RibUpdate& |
| 57 | setAction(Action action); |
| 58 | |
| 59 | Action |
| 60 | getAction() const; |
| 61 | |
| 62 | RibUpdate& |
| 63 | setName(const Name& name); |
| 64 | |
| 65 | const Name& |
| 66 | getName() const; |
| 67 | |
| 68 | RibUpdate& |
| 69 | setRoute(const Route& route); |
| 70 | |
| 71 | const Route& |
| 72 | getRoute() const; |
| 73 | |
| 74 | private: |
| 75 | Action m_action; |
| 76 | Name m_name; |
| 77 | Route m_route; |
| 78 | }; |
| 79 | |
| 80 | inline RibUpdate& |
| 81 | RibUpdate::setAction(Action action) |
| 82 | { |
| 83 | m_action = action; |
| 84 | return *this; |
| 85 | } |
| 86 | |
| 87 | inline RibUpdate::Action |
| 88 | RibUpdate::getAction() const |
| 89 | { |
| 90 | return m_action; |
| 91 | } |
| 92 | |
| 93 | inline RibUpdate& |
| 94 | RibUpdate::setName(const Name& name) |
| 95 | { |
| 96 | m_name = name; |
| 97 | return *this; |
| 98 | } |
| 99 | |
| 100 | inline const Name& |
| 101 | RibUpdate::getName() const |
| 102 | { |
| 103 | return m_name; |
| 104 | } |
| 105 | |
| 106 | inline RibUpdate& |
| 107 | RibUpdate::setRoute(const Route& route) |
| 108 | { |
| 109 | m_route = route; |
| 110 | return *this; |
| 111 | } |
| 112 | |
| 113 | inline const Route& |
| 114 | RibUpdate::getRoute() const |
| 115 | { |
| 116 | return m_route; |
| 117 | } |
| 118 | |
| 119 | std::ostream& |
| 120 | operator<<(std::ostream& os, const RibUpdate::Action action); |
| 121 | |
| 122 | std::ostream& |
| 123 | operator<<(std::ostream& os, const RibUpdate& update); |
| 124 | |
| 125 | } // namespace rib |
| 126 | } // namespace nfd |
| 127 | |
| 128 | #endif // NFD_RIB_RIB_UPDATE_HPP |