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 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 12 | namespace nfd { |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 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 | */ |
Junxiao Shi | 408a700 | 2014-02-12 17:53:47 -0700 | [diff] [blame^] | 27 | class Entry : public StrategyInfoHost, noncopyable |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 28 | { |
| 29 | public: |
Junxiao Shi | 408a700 | 2014-02-12 17:53:47 -0700 | [diff] [blame^] | 30 | explicit |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 31 | Entry(const Name& prefix); |
| 32 | |
| 33 | const Name& |
| 34 | getPrefix() const; |
| 35 | |
| 36 | /** \brief gives the nexthops explicitly defined on this entry |
| 37 | * This list does not include inherited nexthops. |
| 38 | */ |
| 39 | const NextHopList& |
| 40 | getNextHops() const; |
| 41 | |
| 42 | /// adds a nexthop |
| 43 | void |
| 44 | addNextHop(shared_ptr<Face> face, int32_t cost); |
| 45 | |
| 46 | /// removes a nexthop |
| 47 | void |
| 48 | removeNextHop(shared_ptr<Face> face); |
| 49 | |
| 50 | private: |
| 51 | /// sorts the nexthop list |
| 52 | void |
| 53 | sortNextHops(); |
| 54 | |
| 55 | private: |
| 56 | Name m_prefix; |
| 57 | NextHopList m_nextHops; |
| 58 | }; |
| 59 | |
| 60 | |
| 61 | inline const Name& |
| 62 | Entry::getPrefix() const |
| 63 | { |
| 64 | return m_prefix; |
| 65 | } |
| 66 | |
| 67 | inline const NextHopList& |
| 68 | Entry::getNextHops() const |
| 69 | { |
| 70 | return m_nextHops; |
| 71 | } |
| 72 | |
| 73 | |
| 74 | } // namespace fib |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 75 | } // namespace nfd |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 76 | |
| 77 | #endif // NFD_TABLE_FIB_ENTRY_HPP |