42 RibEntry::RouteList::const_iterator
48 std::pair<RibEntry::iterator, bool>
55 m_nRoutesWithCaptureSet++;
58 m_routes.push_back(route);
59 return {std::prev(m_routes.end()),
true};
91 return m_routes.size();
97 BOOST_ASSERT(!child->getParent());
98 child->setParent(this->shared_from_this());
99 m_children.push_back(std::move(child));
105 BOOST_ASSERT(child->getParent().get() ==
this);
106 child->setParent(
nullptr);
107 m_children.remove(child);
113 if (route != m_routes.end()) {
115 m_nRoutesWithCaptureSet--;
119 NFD_LOG_TRACE(
"Cancelling expiration event: " << route->getExpirationEvent());
120 route->cancelExpirationEvent();
122 return m_routes.erase(route);
125 return m_routes.end();
131 m_inheritedRoutes.push_back(route);
140 RibEntry::RouteList::const_iterator
143 return std::find_if(m_inheritedRoutes.begin(), m_inheritedRoutes.end(),
156 return m_nRoutesWithCaptureSet > 0;
162 for (
const Route& route : m_routes) {
174 const Route* candidate =
nullptr;
176 for (
const Route& route : m_routes) {
178 if (route.faceId == faceId) {
180 if (candidate ==
nullptr) {
183 else if (route.cost < candidate->
cost) {
196 std::vector<const Route*> matches;
199 for (
const Route& route : m_routes) {
200 if (route.faceId == faceId) {
201 matches.push_back(&route);
206 if (matches.size() < 2) {
211 std::nth_element(matches.begin(), matches.begin() + 1, matches.end(),
212 [] (
const Route* lhs,
const Route* rhs) {
return lhs->
cost < rhs->cost; });
214 return matches.at(1);
220 const Route* candidate =
nullptr;
222 for (
const Route& route : m_routes) {
224 if (route.faceId == faceId &&
228 if (candidate ==
nullptr) {
231 else if (route.cost < candidate->
cost) {
243 time::milliseconds maxExpiration)
const 245 const Route* bestAnnRoute =
nullptr;
246 auto entryExpiry = time::steady_clock::TimePoint::min();
248 for (
const Route& route : *
this) {
250 entryExpiry = std::max(entryExpiry, *route.
expires);
252 if (bestAnnRoute ==
nullptr || *route.
expires > *bestAnnRoute->
expires) {
253 bestAnnRoute = &route;
258 entryExpiry = time::steady_clock::TimePoint::max();
262 if (bestAnnRoute !=
nullptr) {
270 minExpiration, maxExpiration));
277 os <<
"RibEntry {\n";
278 os <<
" Name: " << entry.
getName() <<
"\n";
280 for (
const Route& route : entry) {
281 os <<
" " << route <<
"\n";
void removeChild(shared_ptr< RibEntry > child)
iterator findRoute(const Route &route)
void addChild(shared_ptr< RibEntry > child)
bool hasFaceId(const uint64_t faceId) const
bool hasRoute(const Route &route)
static time_point now() noexcept
std::ostream & operator<<(std::ostream &os, const FibUpdate &update)
size_t getNRoutes() const
std::underlying_type< ndn::nfd::RouteFlags >::type flags
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
const Route * getRouteWithSecondLowestCostByFaceId(uint64_t faceId) const
bool compareFaceIdAndOrigin(const Route &lhs, const Route &rhs)
optional< time::steady_clock::TimePoint > expires
RouteList::iterator iterator
const Name & getName() const
void removeInheritedRoute(const Route &route)
A prefix announcement object that represents an application's intent of registering a prefix toward i...
ndn::PrefixAnnouncement getPrefixAnnouncement(time::milliseconds minExpiration=15_s, time::milliseconds maxExpiration=1_h) const
Retrieve a prefix announcement suitable for readvertising this route.
Table::const_iterator iterator
optional< ndn::PrefixAnnouncement > announcement
The prefix announcement that caused the creation of this route.
void addInheritedRoute(const Route &route)
Copyright (c) 2011-2015 Regents of the University of California.
PrefixAnnouncement & setExpiration(time::milliseconds expiration)
Set relative expiration period.
const Route * getRouteWithLowestCostAndChildInheritByFaceId(uint64_t faceId) const
Returns the route with the lowest cost that has the passed face ID and its child inherit flag set.
Represents a RIB entry, which contains one or more Routes with the same prefix.
represents a route for a name prefix
bool hasInheritedRoute(const Route &route) const
Determines if the entry has an inherited route with a matching face ID.
RouteList::const_iterator findInheritedRoute(const Route &route) const
Finds an inherited route with a matching face ID.
const_iterator begin() const
PrefixAnnouncement & setAnnouncedName(Name name)
Set announced name.
bool hasChildInheritOnFaceId(uint64_t faceId) const
Determines if the entry has an inherited route with the passed face ID and its child inherit flag set...
std::pair< RibEntry::iterator, bool > insertRoute(const Route &route)
inserts a new route into the entry's route list If another route already exists with the same faceId ...
RouteList::const_iterator const_iterator
void eraseRoute(const Route &route)
erases a Route with the same faceId and origin
bool compareFaceId(const Route &route, const uint64_t faceId)
#define NFD_LOG_INIT(name)
const Route * getRouteWithLowestCostByFaceId(uint64_t faceId) const
Returns the route with the lowest cost that has the passed face ID.
const_iterator end() const