30 #include <ndn-cxx/management/nfd-control-command.hpp> 43 RibEntry::RouteList::const_iterator
56 m_nRoutesWithCaptureSet++;
59 m_routes.push_back(route);
94 return m_routes.size();
100 BOOST_ASSERT(!static_cast<bool>(child->getParent()));
101 child->setParent(this->shared_from_this());
102 m_children.push_back(child);
108 BOOST_ASSERT(child->getParent().get() ==
this);
109 child->setParent(shared_ptr<RibEntry>());
110 m_children.remove(child);
116 if (route != m_routes.end()) {
118 m_nRoutesWithCaptureSet--;
122 NFD_LOG_TRACE(
"Cancelling expiration eventId: " << route->getExpirationEvent());
125 return m_routes.erase(route);
128 return m_routes.end();
134 m_inheritedRoutes.push_back(route);
142 m_inheritedRoutes.erase(it);
145 RibEntry::RouteList::const_iterator
148 return std::find_if(m_inheritedRoutes.begin(), m_inheritedRoutes.end(),
157 return (it != m_inheritedRoutes.end());
163 return m_nRoutesWithCaptureSet > 0;
169 for (
const Route& route : m_routes) {
181 const Route* candidate =
nullptr;
183 for (
const Route& route : m_routes) {
185 if (route.faceId == faceId) {
187 if (candidate ==
nullptr) {
190 else if (route.cost < candidate->
cost) {
203 std::vector<Route> matches;
206 std::copy_if(m_routes.begin(), m_routes.end(), std::back_inserter(matches),
207 [faceId] (
const Route& route) {
return route.faceId == faceId; });
210 if (matches.size() < 2) {
215 std::nth_element(matches.begin(), matches.begin() + 1, matches.end(),
216 [] (
const Route& lhs,
const Route& rhs) {
return lhs.
cost < rhs.cost; });
218 return &matches.at(1);
224 const Route* candidate =
nullptr;
226 for (
const Route& route : m_routes) {
228 if (route.faceId == faceId &&
232 if (candidate ==
nullptr) {
235 else if (route.cost < candidate->
cost) {
248 os <<
"RibEntry {\n";
249 os <<
"\tName: " << entry.
getName() <<
"\n";
251 for (
const Route& route : entry) {
252 os <<
"\t" << 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)
void cancel(const EventId &eventId)
cancel a scheduled event
std::ostream & operator<<(std::ostream &os, const FibUpdate &update)
size_t getNRoutes() const
const Route * getRouteWithSecondLowestCostByFaceId(uint64_t faceId) const
bool compareFaceIdAndOrigin(const Route &lhs, const Route &rhs)
RouteList::iterator iterator
const Name & getName() const
void removeInheritedRoute(const Route &route)
Table::const_iterator iterator
void addInheritedRoute(const Route &route)
Copyright (c) 2011-2015 Regents of the University of California.
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
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...
#define NFD_LOG_INIT(name)
#define NFD_LOG_TRACE(expression)
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)
bool insertRoute(const Route &route)
inserts a new route into the entry's route list If another route already exists with the same faceId ...
const Route * getRouteWithLowestCostByFaceId(uint64_t faceId) const
Returns the route with the lowest cost that has the passed face ID.
const_iterator end() const