Yanbiao Li | d7c9636 | 2015-01-30 23:58:24 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | a314808 | 2018-04-12 18:21:54 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2014-2018, Regents of the University of California, |
Yanbiao Li | d7c9636 | 2015-01-30 23:58:24 -0800 | [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 | |
Yanbiao Li | d7c9636 | 2015-01-30 23:58:24 -0800 | [diff] [blame] | 26 | #include "propagated-entry.hpp" |
| 27 | |
| 28 | namespace nfd { |
| 29 | namespace rib { |
| 30 | |
| 31 | void |
| 32 | operator<<(std::ostream& out, PropagationStatus status) |
| 33 | { |
| 34 | switch (status) { |
| 35 | case PropagationStatus::NEW: |
| 36 | out << "NEW"; |
| 37 | break; |
| 38 | case PropagationStatus::PROPAGATING: |
| 39 | out << "PROPAGATING"; |
| 40 | break; |
| 41 | case PropagationStatus::PROPAGATED: |
| 42 | out << "PROPAGATED"; |
| 43 | break; |
| 44 | case PropagationStatus::PROPAGATE_FAIL: |
| 45 | out << "PROPAGATE_FAIL"; |
| 46 | break; |
| 47 | default: |
| 48 | out << "undefined status"; |
| 49 | break; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | PropagatedEntry::PropagatedEntry() |
| 54 | : m_propagationStatus(PropagationStatus::NEW) |
| 55 | { |
| 56 | } |
| 57 | |
| 58 | PropagatedEntry::PropagatedEntry(const PropagatedEntry& other) |
| 59 | : m_signingIdentity(other.m_signingIdentity) |
| 60 | , m_propagationStatus(other.m_propagationStatus) |
| 61 | { |
| 62 | BOOST_ASSERT(!other.isPropagated() && !other.isPropagateFail()); |
| 63 | } |
| 64 | |
| 65 | PropagatedEntry& |
| 66 | PropagatedEntry::setSigningIdentity(const Name& identity) |
| 67 | { |
| 68 | m_signingIdentity = identity; |
| 69 | return *this; |
| 70 | } |
| 71 | |
| 72 | const Name& |
| 73 | PropagatedEntry::getSigningIdentity() const |
| 74 | { |
| 75 | return m_signingIdentity; |
| 76 | } |
| 77 | |
| 78 | void |
| 79 | PropagatedEntry::startPropagation() |
| 80 | { |
| 81 | m_propagationStatus = PropagationStatus::PROPAGATING; |
| 82 | } |
| 83 | |
| 84 | void |
| 85 | PropagatedEntry::succeed(const scheduler::EventId& event) |
| 86 | { |
| 87 | m_propagationStatus = PropagationStatus::PROPAGATED; |
| 88 | m_rePropagateEvent = event; |
| 89 | } |
| 90 | |
| 91 | void |
| 92 | PropagatedEntry::fail(const scheduler::EventId& event) |
| 93 | { |
| 94 | m_propagationStatus = PropagationStatus::PROPAGATE_FAIL; |
| 95 | m_rePropagateEvent = event; |
| 96 | } |
| 97 | |
| 98 | void |
| 99 | PropagatedEntry::initialize() |
| 100 | { |
| 101 | m_propagationStatus = PropagationStatus::NEW; |
| 102 | m_rePropagateEvent.cancel(); |
| 103 | } |
| 104 | |
| 105 | bool |
| 106 | PropagatedEntry::isNew() const |
| 107 | { |
| 108 | return PropagationStatus::NEW == m_propagationStatus; |
| 109 | } |
| 110 | |
| 111 | bool |
| 112 | PropagatedEntry::isPropagating() const |
| 113 | { |
| 114 | return PropagationStatus::PROPAGATING == m_propagationStatus; |
| 115 | } |
| 116 | |
| 117 | bool |
| 118 | PropagatedEntry::isPropagated() const |
| 119 | { |
| 120 | return PropagationStatus::PROPAGATED == m_propagationStatus; |
| 121 | } |
| 122 | |
| 123 | bool |
| 124 | PropagatedEntry::isPropagateFail() const |
| 125 | { |
| 126 | return PropagationStatus::PROPAGATE_FAIL == m_propagationStatus; |
| 127 | } |
| 128 | |
| 129 | } // namespace rib |
| 130 | } // namespace nfd |