blob: aac8fc5766c9b34fc0b8d88bd93c908baad173c8 [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
Junxiao Shic1e12362014-01-24 20:03:26 -070014namespace 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 */
23typedef std::vector<fib::NextHop> NextHopList;
24
25/** \class Entry
26 * \brief represents a FIB entry
27 */
Junxiao Shi408a7002014-02-12 17:53:47 -070028class Entry : public StrategyInfoHost, noncopyable
Junxiao Shic1e12362014-01-24 20:03:26 -070029{
30public:
Junxiao Shi408a7002014-02-12 17:53:47 -070031 explicit
Junxiao Shic1e12362014-01-24 20:03:26 -070032 Entry(const Name& prefix);
Junxiao Shi7bb01512014-03-05 21:34:09 -070033
Junxiao Shic1e12362014-01-24 20:03:26 -070034 const Name&
35 getPrefix() const;
Junxiao Shi7bb01512014-03-05 21:34:09 -070036
Junxiao Shic1e12362014-01-24 20:03:26 -070037 const NextHopList&
38 getNextHops() const;
Junxiao Shi7bb01512014-03-05 21:34:09 -070039
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070040 bool
41 hasNextHop(shared_ptr<Face> face) const;
Junxiao Shi7bb01512014-03-05 21:34:09 -070042
Junxiao Shic1e12362014-01-24 20:03:26 -070043 /// adds a nexthop
44 void
45 addNextHop(shared_ptr<Face> face, int32_t cost);
Junxiao Shi7bb01512014-03-05 21:34:09 -070046
Junxiao Shic1e12362014-01-24 20:03:26 -070047 /// removes a nexthop
48 void
49 removeNextHop(shared_ptr<Face> face);
50
51private:
52 /// sorts the nexthop list
53 void
54 sortNextHops();
55
56private:
57 Name m_prefix;
58 NextHopList m_nextHops;
59};
60
61
62inline const Name&
63Entry::getPrefix() const
64{
65 return m_prefix;
66}
67
68inline const NextHopList&
69Entry::getNextHops() const
70{
71 return m_nextHops;
72}
73
Junxiao Shic1e12362014-01-24 20:03:26 -070074} // 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