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 | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 13 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 14 | namespace fib { |
| 15 | |
| 16 | /** \class NextHopList |
| 17 | * \brief represents a collection of nexthops |
| 18 | * This type has these methods: |
| 19 | * iterator<NextHop> begin() |
| 20 | * iterator<NextHop> end() |
| 21 | * size_t size() |
| 22 | */ |
| 23 | typedef std::vector<fib::NextHop> NextHopList; |
| 24 | |
| 25 | /** \class Entry |
| 26 | * \brief represents a FIB entry |
| 27 | */ |
Junxiao Shi | 408a700 | 2014-02-12 17:53:47 -0700 | [diff] [blame] | 28 | class Entry : public StrategyInfoHost, noncopyable |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 29 | { |
| 30 | public: |
Junxiao Shi | 408a700 | 2014-02-12 17:53:47 -0700 | [diff] [blame] | 31 | explicit |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 32 | Entry(const Name& prefix); |
Junxiao Shi | 7bb0151 | 2014-03-05 21:34:09 -0700 | [diff] [blame] | 33 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 34 | const Name& |
| 35 | getPrefix() const; |
Junxiao Shi | 7bb0151 | 2014-03-05 21:34:09 -0700 | [diff] [blame] | 36 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 37 | const NextHopList& |
| 38 | getNextHops() const; |
Junxiao Shi | 7bb0151 | 2014-03-05 21:34:09 -0700 | [diff] [blame] | 39 | |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 40 | bool |
| 41 | hasNextHop(shared_ptr<Face> face) const; |
Junxiao Shi | 7bb0151 | 2014-03-05 21:34:09 -0700 | [diff] [blame] | 42 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 43 | /// adds a nexthop |
| 44 | void |
| 45 | addNextHop(shared_ptr<Face> face, int32_t cost); |
Junxiao Shi | 7bb0151 | 2014-03-05 21:34:09 -0700 | [diff] [blame] | 46 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 47 | /// removes a nexthop |
| 48 | void |
| 49 | removeNextHop(shared_ptr<Face> face); |
| 50 | |
| 51 | private: |
| 52 | /// sorts the nexthop list |
| 53 | void |
| 54 | sortNextHops(); |
| 55 | |
| 56 | private: |
| 57 | Name m_prefix; |
| 58 | NextHopList m_nextHops; |
| 59 | }; |
| 60 | |
| 61 | |
| 62 | inline const Name& |
| 63 | Entry::getPrefix() const |
| 64 | { |
| 65 | return m_prefix; |
| 66 | } |
| 67 | |
| 68 | inline const NextHopList& |
| 69 | Entry::getNextHops() const |
| 70 | { |
| 71 | return m_nextHops; |
| 72 | } |
| 73 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 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 |