blob: 40098ee5fe267d6f542051d3f877b0754854c8a6 [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 Shic1e12362014-01-24 20:03:26 -070013namespace 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 */
22typedef std::vector<fib::NextHop> NextHopList;
23
24/** \class Entry
25 * \brief represents a FIB entry
26 */
Junxiao Shi408a7002014-02-12 17:53:47 -070027class Entry : public StrategyInfoHost, noncopyable
Junxiao Shic1e12362014-01-24 20:03:26 -070028{
29public:
Junxiao Shi408a7002014-02-12 17:53:47 -070030 explicit
Junxiao Shic1e12362014-01-24 20:03:26 -070031 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
50private:
51 /// sorts the nexthop list
52 void
53 sortNextHops();
54
55private:
56 Name m_prefix;
57 NextHopList m_nextHops;
58};
59
60
61inline const Name&
62Entry::getPrefix() const
63{
64 return m_prefix;
65}
66
67inline const NextHopList&
68Entry::getNextHops() const
69{
70 return m_nextHops;
71}
72
73
74} // namespace fib
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080075} // namespace nfd
Junxiao Shic1e12362014-01-24 20:03:26 -070076
77#endif // NFD_TABLE_FIB_ENTRY_HPP