Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NFD_TABLE_FIB_ENTRY_HPP |
| 8 | #define NFD_TABLE_FIB_ENTRY_HPP |
| 9 | |
| 10 | #include "fib-nexthop.hpp" |
| 11 | |
| 12 | namespace ndn { |
| 13 | namespace fib { |
| 14 | |
| 15 | /** \class NextHopList |
| 16 | * \brief represents a collection of nexthops |
| 17 | * This type has these methods: |
| 18 | * iterator<NextHop> begin() |
| 19 | * iterator<NextHop> end() |
| 20 | * size_t size() |
| 21 | */ |
| 22 | typedef std::vector<fib::NextHop> NextHopList; |
| 23 | |
| 24 | /** \class Entry |
| 25 | * \brief represents a FIB entry |
| 26 | */ |
| 27 | class Entry : noncopyable |
| 28 | { |
| 29 | public: |
| 30 | Entry(const Name& prefix); |
| 31 | |
| 32 | const Name& |
| 33 | getPrefix() const; |
| 34 | |
| 35 | /** \brief gives the nexthops explicitly defined on this entry |
| 36 | * This list does not include inherited nexthops. |
| 37 | */ |
| 38 | const NextHopList& |
| 39 | getNextHops() const; |
| 40 | |
| 41 | /// adds a nexthop |
| 42 | void |
| 43 | addNextHop(shared_ptr<Face> face, int32_t cost); |
| 44 | |
| 45 | /// removes a nexthop |
| 46 | void |
| 47 | removeNextHop(shared_ptr<Face> face); |
| 48 | |
| 49 | private: |
| 50 | /// sorts the nexthop list |
| 51 | void |
| 52 | sortNextHops(); |
| 53 | |
| 54 | private: |
| 55 | Name m_prefix; |
| 56 | NextHopList m_nextHops; |
| 57 | }; |
| 58 | |
| 59 | |
| 60 | inline const Name& |
| 61 | Entry::getPrefix() const |
| 62 | { |
| 63 | return m_prefix; |
| 64 | } |
| 65 | |
| 66 | inline const NextHopList& |
| 67 | Entry::getNextHops() const |
| 68 | { |
| 69 | return m_nextHops; |
| 70 | } |
| 71 | |
| 72 | |
| 73 | } // namespace fib |
| 74 | } // namespace ndn |
| 75 | |
| 76 | #endif // NFD_TABLE_FIB_ENTRY_HPP |