propagated-entry.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2018, Regents of the University of California,
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 #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) {
36  out << "NEW";
37  break;
39  out << "PROPAGATING";
40  break;
42  out << "PROPAGATED";
43  break;
45  out << "PROPAGATE_FAIL";
46  break;
47  default:
48  out << "undefined status";
49  break;
50  }
51 }
52 
54  : m_propagationStatus(PropagationStatus::NEW)
55 {
56 }
57 
59  : m_signingIdentity(other.m_signingIdentity)
60  , m_propagationStatus(other.m_propagationStatus)
61 {
62  BOOST_ASSERT(!other.isPropagated() && !other.isPropagateFail());
63 }
64 
67 {
68  m_signingIdentity = identity;
69  return *this;
70 }
71 
72 const Name&
74 {
75  return m_signingIdentity;
76 }
77 
78 void
80 {
81  m_propagationStatus = PropagationStatus::PROPAGATING;
82 }
83 
84 void
86 {
87  m_propagationStatus = PropagationStatus::PROPAGATED;
88  m_rePropagateEvent = event;
89 }
90 
91 void
93 {
94  m_propagationStatus = PropagationStatus::PROPAGATE_FAIL;
95  m_rePropagateEvent = event;
96 }
97 
98 void
100 {
101  m_propagationStatus = PropagationStatus::NEW;
102  m_rePropagateEvent.cancel();
103 }
104 
105 bool
107 {
108  return PropagationStatus::NEW == m_propagationStatus;
109 }
110 
111 bool
113 {
114  return PropagationStatus::PROPAGATING == m_propagationStatus;
115 }
116 
117 bool
119 {
120  return PropagationStatus::PROPAGATED == m_propagationStatus;
121 }
122 
123 bool
125 {
126  return PropagationStatus::PROPAGATE_FAIL == m_propagationStatus;
127 }
128 
129 } // namespace rib
130 } // namespace nfd
bool isPropagateFail() const
check whether this entry has failed in propagating.
represents an entry for prefix propagation.
void startPropagation()
switch the propagation status to PROPAGATING.
std::ostream & operator<<(std::ostream &os, const FibUpdate &update)
Definition: fib-update.hpp:74
const Name & getSigningIdentity() const
get the signing identity
bool isPropagated() const
check whether this entry has been successfully propagated.
void initialize()
cancel the events of re-sending propagation commands.
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
PropagatedEntry()
void fail(const scheduler::EventId &event)
switch the propagation status to PROPAGATE_FAIL, and then set the rePropagateEvent to event for retry...
void succeed(const scheduler::EventId &event)
switch the propagation status to PROPAGATED, and set the rePropagateEvent to event for refresh...
PropagatedEntry & setSigningIdentity(const Name &identity)
set the signing identity
bool isNew() const
check whether this entry is a new entry.
void cancel()
Cancels the event manually.
Definition: scheduler.cpp:95
Opaque handle for a scheduled event.
has been propagated successfully
bool isPropagating() const
check whether this entry is being propagated.