42 RibEntry::RouteList::iterator
49 RibEntry::RouteList::const_iterator
56 std::pair<RibEntry::iterator, bool>
63 m_nRoutesWithCaptureSet++;
66 m_routes.push_back(route);
67 return {std::prev(m_routes.end()),
true};
90 auto it = std::find_if(
begin(),
end(), [faceId] (
const auto& r) {
return r.faceId == faceId; });
97 return m_routes.size();
103 BOOST_ASSERT(!child->getParent());
104 child->setParent(this->shared_from_this());
111 BOOST_ASSERT(child->getParent().get() ==
this);
112 child->setParent(
nullptr);
113 m_children.remove(child);
116 RibEntry::RouteList::iterator
119 if (route != m_routes.end()) {
121 m_nRoutesWithCaptureSet--;
125 NFD_LOG_TRACE(
"Cancelling expiration event: " << route->getExpirationEvent());
126 route->cancelExpirationEvent();
128 return m_routes.erase(route);
131 return m_routes.end();
137 m_inheritedRoutes.push_back(route);
143 m_inheritedRoutes.remove_if([
id = route.
faceId] (
const auto& r) { return r.faceId == id; });
146 RibEntry::RouteList::const_iterator
149 return std::find_if(m_inheritedRoutes.begin(), m_inheritedRoutes.end(),
150 [
id = route.
faceId] (
const auto& r) {
return r.faceId == id; });
162 return m_nRoutesWithCaptureSet > 0;
168 for (
const Route& route : m_routes) {
180 const Route* candidate =
nullptr;
182 for (
const Route& route : m_routes) {
184 if (route.faceId == faceId) {
186 if (candidate ==
nullptr) {
189 else if (route.cost < candidate->
cost) {
202 std::vector<const Route*> matches;
205 for (
const Route& route : m_routes) {
206 if (route.faceId == faceId) {
207 matches.push_back(&route);
212 if (matches.size() < 2) {
217 std::nth_element(matches.begin(), matches.begin() + 1, matches.end(),
218 [] (
const Route* lhs,
const Route* rhs) {
return lhs->
cost < rhs->cost; });
220 return matches.at(1);
226 const Route* candidate =
nullptr;
228 for (
const Route& route : m_routes) {
230 if (route.faceId == faceId &&
234 if (candidate ==
nullptr) {
237 else if (route.cost < candidate->
cost) {
251 const Route* bestAnnRoute =
nullptr;
252 auto entryExpiry = time::steady_clock::time_point::min();
254 for (
const Route& route : *
this) {
256 entryExpiry = std::max(entryExpiry, *route.
expires);
258 if (bestAnnRoute ==
nullptr || *route.
expires > *bestAnnRoute->
expires) {
259 bestAnnRoute = &route;
264 entryExpiry = time::steady_clock::time_point::max();
268 if (bestAnnRoute !=
nullptr) {
276 minExpiration, maxExpiration));
283 os <<
"RibEntry {\n";
284 os <<
" Name: " << entry.
getName() <<
"\n";
286 for (
const Route& route : entry) {
287 os <<
" " << route <<
"\n";
bool hasFaceId(uint64_t faceId) const
std::underlying_type_t< ndn::nfd::RouteFlags > flags
#define NFD_LOG_INIT(name)
static bool compareFaceIdAndOrigin(const Route &lhs, const Route &rhs)
void removeChild(shared_ptr< RibEntry > child)
iterator findRoute(const Route &route)
void addChild(shared_ptr< RibEntry > child)
bool hasRoute(const Route &route)
static time_point now() noexcept
std::ostream & operator<<(std::ostream &os, const FibUpdate &update)
size_t getNRoutes() const
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
const Route * getRouteWithSecondLowestCostByFaceId(uint64_t faceId) const
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.
optional< ndn::PrefixAnnouncement > announcement
The prefix announcement that caused the creation of this route.
optional< time::steady_clock::time_point > expires
ndn::nfd::RouteOrigin origin
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 ...
void eraseRoute(const Route &route)
erases a Route with the same faceId and origin
const Route * getRouteWithLowestCostByFaceId(uint64_t faceId) const
Returns the route with the lowest cost that has the passed face ID.
const_iterator end() const
boost::chrono::milliseconds milliseconds