adjacency.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_TLV_ADJACENCY_HPP
23 #define NLSR_TLV_ADJACENCY_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 
31 namespace nlsr {
32 namespace tlv {
33 
44 class Adjacency
45 {
46 public:
47  class Error : public ndn::tlv::Error
48  {
49  public:
50  explicit
51  Error(const std::string& what)
52  : ndn::tlv::Error(what)
53  {
54  }
55  };
56 
57  Adjacency();
58 
59  explicit
60  Adjacency(const ndn::Block& block);
61 
62  const ndn::Name&
63  getName() const
64  {
65  return m_name;
66  }
67 
68  Adjacency&
69  setName(const ndn::Name& name)
70  {
71  m_name = name;
72  m_wire.reset();
73  return *this;
74  }
75 
76  const std::string&
77  getUri() const
78  {
79  return m_uri;
80  }
81 
82  Adjacency&
83  setUri(const std::string& uri)
84  {
85  m_uri = uri;
86  m_wire.reset();
87  return *this;
88  }
89 
90  uint64_t
91  getCost() const
92  {
93  return m_cost;
94  }
95 
96  Adjacency&
97  setCost(uint64_t cost)
98  {
99  m_cost = cost;
100  m_wire.reset();
101  return *this;
102  }
103 
112  template<ndn::encoding::Tag TAG>
113  size_t
114  wireEncode(ndn::EncodingImpl<TAG>& block) const;
115 
123  const ndn::Block&
124  wireEncode() const;
125 
129  void
130  wireDecode(const ndn::Block& wire);
131 
132 private:
133  ndn::Name m_name;
134  std::string m_uri;
135  uint64_t m_cost;
136 
137  mutable ndn::Block m_wire;
138 };
139 
140 std::ostream&
141 operator<<(std::ostream& os, const Adjacency& adjacency);
142 
143 } // namespace tlv
144 } // namespace nlsr
145 
146 #endif // NLSR_TLV_ADJACENCY_HPP
void wireDecode(const ndn::Block &wire)
Populate this object by decoding the object contained in the given block.
Definition: adjacency.cpp:90
Adjacency & setCost(uint64_t cost)
Definition: adjacency.hpp:97
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
Definition: tlv-nlsr.hpp:27
const ndn::Block & wireEncode() const
Create a TLV encoding of this object.
Definition: adjacency.cpp:72
const std::string & getUri() const
Definition: adjacency.hpp:77
Adjacency & setUri(const std::string &uri)
Definition: adjacency.hpp:83
Error(const std::string &what)
Definition: adjacency.hpp:51
uint64_t getCost() const
Definition: adjacency.hpp:91
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
const ndn::Name & getName() const
Definition: adjacency.hpp:63
std::ostream & operator<<(std::ostream &os, const AdjacencyLsa &adjacencyLsa)
Data abstraction for Adjacency.
Definition: adjacency.hpp:44
Adjacency & setName(const ndn::Name &name)
Definition: adjacency.hpp:69