tlv/nexthop.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_TLV_NEXTHOP_HPP
23 #define NLSR_TLV_NEXTHOP_HPP
24 
25 #include <ndn-cxx/util/time.hpp>
26 #include <ndn-cxx/encoding/block.hpp>
27 #include <ndn-cxx/encoding/encoding-buffer.hpp>
28 #include <ndn-cxx/encoding/tlv.hpp>
29 #include <ndn-cxx/name.hpp>
30 #include <boost/throw_exception.hpp>
31 
32 namespace nlsr {
33 namespace tlv {
34 
43 class NextHop
44 {
45 public:
46  class Error : public ndn::tlv::Error
47  {
48  public:
49  explicit
50  Error(const std::string& what)
51  : ndn::tlv::Error(what)
52  {
53  }
54  };
55 
56  NextHop();
57 
58  explicit
59  NextHop(const ndn::Block& block);
60 
61  const std::string&
62  getUri() const
63  {
64  return m_uri;
65  }
66 
67  NextHop&
68  setUri(const std::string& uri)
69  {
70  m_uri = uri;
71  m_wire.reset();
72  return *this;
73  }
74 
75  double
76  getCost() const
77  {
78  return m_cost;
79  }
80 
81  NextHop&
82  setCost(double cost)
83  {
84  m_cost = cost;
85  m_wire.reset();
86  return *this;
87  }
88 
89  template<ndn::encoding::Tag TAG>
90  size_t
91  wireEncode(ndn::EncodingImpl<TAG>& block) const;
92 
93  const ndn::Block&
94  wireEncode() const;
95 
96  void
97  wireDecode(const ndn::Block& wire);
98 
99 private:
100  std::string m_uri;
101  double m_cost;
102 
103  mutable ndn::Block m_wire;
104 };
105 
107 
108 std::ostream&
109 operator<<(std::ostream& os, const NextHop& nexthop);
110 
111 } // namespace tlv
112 } // namespace nlsr
113 
114 #endif // NLSR_TLV_NEXTHOP_HPP
NextHop & setUri(const std::string &uri)
Definition: tlv/nexthop.hpp:68
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
Definition: tlv-nlsr.hpp:27
const std::string & getUri() const
Definition: tlv/nexthop.hpp:62
Data abstraction for Nexthop.
Definition: tlv/nexthop.hpp:43
Error(const std::string &what)
Definition: tlv/nexthop.hpp:50
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
const ndn::Block & wireEncode() const
Definition: tlv/nexthop.cpp:67
void wireDecode(const ndn::Block &wire)
Definition: tlv/nexthop.cpp:85
std::ostream & operator<<(std::ostream &os, const AdjacencyLsa &adjacencyLsa)
NextHop & setCost(double cost)
Definition: tlv/nexthop.hpp:82
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Destination)
double getCost() const
Definition: tlv/nexthop.hpp:76