route.hpp
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 #ifndef NFD_RIB_ROUTE_HPP
27 #define NFD_RIB_ROUTE_HPP
28 
29 #include "core/scheduler.hpp"
30 
31 #include <ndn-cxx/encoding/nfd-constants.hpp>
32 #include <ndn-cxx/mgmt/nfd/route-flags-traits.hpp>
33 #include <ndn-cxx/prefix-announcement.hpp>
34 
35 #include <type_traits>
36 
37 namespace nfd {
38 namespace rib {
39 
42 class Route : public ndn::nfd::RouteFlagsTraits<Route>
43 {
44 public:
47  Route() = default;
48 
53  Route(const ndn::PrefixAnnouncement& ann, uint64_t faceId);
54 
55  void
57  {
58  m_expirationEvent = eid;
59  }
60 
61  const scheduler::EventId&
63  {
64  return m_expirationEvent;
65  }
66 
67  std::underlying_type<ndn::nfd::RouteFlags>::type
68  getFlags() const
69  {
70  return flags;
71  }
72 
73 public:
74  uint64_t faceId = 0;
75  ndn::nfd::RouteOrigin origin = ndn::nfd::ROUTE_ORIGIN_APP;
76  uint64_t cost = 0;
77  std::underlying_type<ndn::nfd::RouteFlags>::type flags = ndn::nfd::ROUTE_FLAGS_NONE;
78  optional<time::steady_clock::TimePoint> expires;
79 
84  optional<ndn::PrefixAnnouncement> announcement;
85 
94  time::steady_clock::TimePoint annExpires;
95 
96 private:
97  scheduler::EventId m_expirationEvent;
98 };
99 
100 bool
101 operator==(const Route& lhs, const Route& rhs);
102 
103 inline bool
104 operator!=(const Route& lhs, const Route& rhs)
105 {
106  return !(lhs == rhs);
107 }
108 
109 inline bool
110 compareFaceIdAndOrigin(const Route& lhs, const Route& rhs)
111 {
112  return (lhs.faceId == rhs.faceId && lhs.origin == rhs.origin);
113 }
114 
115 inline bool
116 compareFaceId(const Route& route, const uint64_t faceId)
117 {
118  return (route.faceId == faceId);
119 }
120 
121 std::ostream&
122 operator<<(std::ostream& os, const Route& route);
123 
124 } // namespace rib
125 } // namespace nfd
126 
127 #endif // NFD_RIB_ROUTE_HPP
uint64_t faceId
Definition: route.hpp:74
uint64_t cost
Definition: route.hpp:76
bool operator==(const Route &lhs, const Route &rhs)
Definition: route.cpp:63
std::ostream & operator<<(std::ostream &os, const FibUpdate &update)
Definition: fib-update.hpp:74
optional< ndn::PrefixAnnouncement > announcement
The prefix announcement that caused the creation of this route.
Definition: route.hpp:84
bool compareFaceIdAndOrigin(const Route &lhs, const Route &rhs)
Definition: route.hpp:110
bool operator!=(const Route &lhs, const Route &rhs)
Definition: route.hpp:104
optional< time::steady_clock::TimePoint > expires
Definition: route.hpp:78
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
time::steady_clock::TimePoint annExpires
Expiration time of the prefix announcement.
Definition: route.hpp:94
ndn::nfd::RouteOrigin origin
Definition: route.hpp:75
void setExpirationEvent(const scheduler::EventId eid)
Definition: route.hpp:56
represents a route for a name prefix
Definition: route.hpp:42
const scheduler::EventId & getExpirationEvent() const
Definition: route.hpp:62
Route()=default
default constructor
bool compareFaceId(const Route &route, const uint64_t faceId)
Definition: route.hpp:116
Opaque handle for a scheduled event.
std::underlying_type< ndn::nfd::RouteFlags >::type getFlags() const
Definition: route.hpp:68
std::underlying_type< ndn::nfd::RouteFlags >::type flags
Definition: route.hpp:77