30 #include <ndn-cxx/mgmt/nfd/control-command.hpp> 43 RibEntry::RouteList::const_iterator
49 std::pair<RibEntry::iterator, bool>
56 m_nRoutesWithCaptureSet++;
59 m_routes.push_back(route);
61 return std::make_pair(std::prev(m_routes.end()),
true);
64 return std::make_pair(it,
false);
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<const Route*> matches;
206 for (
const Route& route : m_routes) {
207 if (route.faceId == faceId) {
208 matches.push_back(&route);
213 if (matches.size() < 2) {
218 std::nth_element(matches.begin(), matches.begin() + 1, matches.end(),
219 [] (
const Route* lhs,
const Route* rhs) {
return lhs->
cost < rhs->cost; });
221 return matches.at(1);
227 const Route* candidate =
nullptr;
229 for (
const Route& route : m_routes) {
231 if (route.faceId == faceId &&
235 if (candidate ==
nullptr) {
238 else if (route.cost < candidate->
cost) {
251 os <<
"RibEntry {\n";
252 os <<
"\tName: " << entry.
getName() <<
"\n";
254 for (
const Route& route : entry) {
255 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
#define NFD_LOG_TRACE(expression)
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...
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