tlv/routing-table-entry.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_TLV_ROUTING_TABLE_ENTRY_HPP
23 #define NLSR_TLV_ROUTING_TABLE_ENTRY_HPP
24 
25 #include "destination.hpp"
26 #include "nexthop.hpp"
27 
28 #include <ndn-cxx/util/time.hpp>
29 #include <ndn-cxx/encoding/block.hpp>
30 #include <ndn-cxx/encoding/encoding-buffer.hpp>
31 #include <ndn-cxx/encoding/tlv.hpp>
32 #include <ndn-cxx/name.hpp>
33 
34 #include <list>
35 
36 namespace nlsr {
37 namespace tlv {
38 
48 {
49 public:
50  class Error : public ndn::tlv::Error
51  {
52  public:
53  explicit
54  Error(const std::string& what)
55  : ndn::tlv::Error(what)
56  {
57  }
58  };
59 
60  typedef std::list<NextHop> HopList;
61  typedef HopList::const_iterator const_iterator;
62 
63  RoutingTable();
64 
65  explicit
66  RoutingTable(const ndn::Block& block);
67 
68  const Destination&
70  {
71  return m_des;
72  }
73 
76  {
77  m_des = des;
78  m_wire.reset();
79  return *this;
80  }
81 
82  uint64_t
83  getRtSize() const
84  {
85  return m_size;
86  }
87 
89  setRtSize(uint64_t size)
90  {
91  m_size = size;
92  m_wire.reset();
93  return *this;
94  }
95 
96  bool
97  hasNexthops() const;
98 
99  const std::list<NextHop>&
100  getNextHops() const
101  {
102  return m_nexthops;
103  }
104 
105  RoutingTable&
106  addNexthops(const NextHop& nexthop);
107 
108  RoutingTable&
109  clearNexthops();
110 
111  template<ndn::encoding::Tag TAG>
112  size_t
113  wireEncode(ndn::EncodingImpl<TAG>& block) const;
114 
115  const ndn::Block&
116  wireEncode() const;
117 
118  void
119  wireDecode(const ndn::Block& wire);
120 
121  const_iterator
122  begin() const;
123 
124  const_iterator
125  end() const;
126 
127 private:
128  Destination m_des;
129  uint64_t m_size;
130  bool m_hasNexthops;
131  HopList m_nexthops;
132 
133  mutable ndn::Block m_wire;
134 };
135 
137 
140 {
141  return m_nexthops.begin();
142 }
143 
146 {
147  return m_nexthops.end();
148 }
149 
150 std::ostream&
151 operator<<(std::ostream& os, const RoutingTable& routetable);
152 
153 } // namespace tlv
154 } // namespace nlsr
155 
156 #endif // NLSR_TLV_ROUTING_TABLE_ENTRY_HPP
void wireDecode(const ndn::Block &wire)
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
Definition: tlv-nlsr.hpp:27
Data abstraction for Destination.
Definition: destination.hpp:46
Data abstraction for Nexthop.
Definition: tlv/nexthop.hpp:43
const Destination & getDestination() const
const std::list< NextHop > & getNextHops() const
Data abstraction for RouteTableInfo.
RoutingTable & setDestination(const Destination &des)
HopList::const_iterator const_iterator
const ndn::Block & wireEncode() const
RoutingTable & setRtSize(uint64_t size)
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
std::ostream & operator<<(std::ostream &os, const AdjacencyLsa &adjacencyLsa)
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Destination)
const_iterator begin() const
RoutingTable & addNexthops(const NextHop &nexthop)