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