blob: dae3934e7d50af441b85901a63fa8d24134fbcf6 [file] [log] [blame]
Yanbiao Lid7c96362015-01-30 23:58:24 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventoa3148082018-04-12 18:21:54 -04002/*
3 * Copyright (c) 2014-2018, Regents of the University of California,
Yanbiao Lid7c96362015-01-30 23:58:24 -08004 * 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 Lid7c96362015-01-30 23:58:24 -080026#include "propagated-entry.hpp"
27
28namespace nfd {
29namespace rib {
30
31void
32operator<<(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
53PropagatedEntry::PropagatedEntry()
54 : m_propagationStatus(PropagationStatus::NEW)
55{
56}
57
58PropagatedEntry::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
65PropagatedEntry&
66PropagatedEntry::setSigningIdentity(const Name& identity)
67{
68 m_signingIdentity = identity;
69 return *this;
70}
71
72const Name&
73PropagatedEntry::getSigningIdentity() const
74{
75 return m_signingIdentity;
76}
77
78void
79PropagatedEntry::startPropagation()
80{
81 m_propagationStatus = PropagationStatus::PROPAGATING;
82}
83
84void
85PropagatedEntry::succeed(const scheduler::EventId& event)
86{
87 m_propagationStatus = PropagationStatus::PROPAGATED;
88 m_rePropagateEvent = event;
89}
90
91void
92PropagatedEntry::fail(const scheduler::EventId& event)
93{
94 m_propagationStatus = PropagationStatus::PROPAGATE_FAIL;
95 m_rePropagateEvent = event;
96}
97
98void
99PropagatedEntry::initialize()
100{
101 m_propagationStatus = PropagationStatus::NEW;
102 m_rePropagateEvent.cancel();
103}
104
105bool
106PropagatedEntry::isNew() const
107{
108 return PropagationStatus::NEW == m_propagationStatus;
109}
110
111bool
112PropagatedEntry::isPropagating() const
113{
114 return PropagationStatus::PROPAGATING == m_propagationStatus;
115}
116
117bool
118PropagatedEntry::isPropagated() const
119{
120 return PropagationStatus::PROPAGATED == m_propagationStatus;
121}
122
123bool
124PropagatedEntry::isPropagateFail() const
125{
126 return PropagationStatus::PROPAGATE_FAIL == m_propagationStatus;
127}
128
129} // namespace rib
130} // namespace nfd