blob: 6adddd857a98357e612754d5576006dce73a42d1 [file] [log] [blame]
Junxiao Shic1e12362014-01-24 20:03:26 -07001/* -*- 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 Afanasyev18bbf812014-01-29 01:40:23 -080012namespace nfd {
Junxiao Shidbe71732014-02-21 22:23:28 -070013
14namespace fw {
15class Strategy;
16}
17
Junxiao Shic1e12362014-01-24 20:03:26 -070018namespace fib {
19
20/** \class NextHopList
21 * \brief represents a collection of nexthops
22 * This type has these methods:
23 * iterator<NextHop> begin()
24 * iterator<NextHop> end()
25 * size_t size()
26 */
27typedef std::vector<fib::NextHop> NextHopList;
28
29/** \class Entry
30 * \brief represents a FIB entry
31 */
Junxiao Shi408a7002014-02-12 17:53:47 -070032class Entry : public StrategyInfoHost, noncopyable
Junxiao Shic1e12362014-01-24 20:03:26 -070033{
34public:
Junxiao Shi408a7002014-02-12 17:53:47 -070035 explicit
Junxiao Shic1e12362014-01-24 20:03:26 -070036 Entry(const Name& prefix);
37
38 const Name&
39 getPrefix() const;
40
41 /** \brief gives the nexthops explicitly defined on this entry
42 * This list does not include inherited nexthops.
43 */
44 const NextHopList&
45 getNextHops() const;
46
47 /// adds a nexthop
48 void
49 addNextHop(shared_ptr<Face> face, int32_t cost);
50
51 /// removes a nexthop
52 void
53 removeNextHop(shared_ptr<Face> face);
Junxiao Shidbe71732014-02-21 22:23:28 -070054
55 const fw::Strategy&
56 getStrategy() const;
57
58 void
59 setStrategy(shared_ptr<fw::Strategy> strategy);
Junxiao Shic1e12362014-01-24 20:03:26 -070060
61private:
62 /// sorts the nexthop list
63 void
64 sortNextHops();
65
66private:
67 Name m_prefix;
68 NextHopList m_nextHops;
Junxiao Shidbe71732014-02-21 22:23:28 -070069 shared_ptr<fw::Strategy> m_strategy;
Junxiao Shic1e12362014-01-24 20:03:26 -070070};
71
72
73inline const Name&
74Entry::getPrefix() const
75{
76 return m_prefix;
77}
78
79inline const NextHopList&
80Entry::getNextHops() const
81{
82 return m_nextHops;
83}
84
Junxiao Shidbe71732014-02-21 22:23:28 -070085inline const fw::Strategy&
86Entry::getStrategy() const
87{
88 BOOST_ASSERT(static_cast<bool>(m_strategy));
89 return *m_strategy;
90}
Junxiao Shic1e12362014-01-24 20:03:26 -070091
92} // namespace fib
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080093} // namespace nfd
Junxiao Shic1e12362014-01-24 20:03:26 -070094
95#endif // NFD_TABLE_FIB_ENTRY_HPP