NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
link.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_LINK_HPP
23 #define NDN_LINK_HPP
24 
25 #include "data.hpp"
26 #include <set>
27 
28 namespace ndn {
29 
30 const size_t INVALID_SELECTED_DELEGATION_INDEX = std::numeric_limits<size_t>::max();
31 
34 class Link : public Data
35 {
36 public:
37  class Error : public Data::Error
38  {
39  public:
40  explicit
41  Error(const std::string& what)
42  : Data::Error(what)
43  {
44  }
45  };
46 
47  // The ordering is based on the preference number and needs to be preserved
48  typedef std::set<std::pair<uint32_t, Name>> DelegationSet;
49 
60  Link() = default;
61 
72  explicit
73  Link(const Block& block);
74 
87  explicit
88  Link(const Name& name);
89 
104  Link(const Name& name, std::initializer_list<std::pair<uint32_t, Name>> links);
105 
112  void
113  addDelegation(uint32_t preference, const Name& name);
114 
120  bool
121  removeDelegation(const Name& name);
122 
127  const DelegationSet&
128  getDelegations() const;
129 
135  void
136  wireDecode(const Block& wire);
137 
144  static std::tuple<uint32_t, Name>
145  getDelegationFromWire(const Block& block, size_t index);
146 
153  static ssize_t
154  findDelegationFromWire(const Block& block, const Name& delegationName);
155 
156  static ssize_t
157  countDelegationsFromWire(const Block& block);
158 
159 protected:
164  template<encoding::Tag TAG>
165  size_t
166  encodeContent(EncodingImpl<TAG>& encoder) const;
167 
168  void
169  encodeContent();
170 
171  void
172  decodeContent();
173 
174 private:
175  bool
176  removeDelegationNoEncode(const Name& name);
177 
178 private:
179  DelegationSet m_delegations;
180 };
181 
182 } // namespace ndn
183 
184 #endif // NDN_LINK_HPP
Copyright (c) 2011-2015 Regents of the University of California.
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
Name abstraction to represent an absolute name.
Definition: name.hpp:46
represents a Data packet
Definition: data.hpp:37
const size_t INVALID_SELECTED_DELEGATION_INDEX
Definition: link.hpp:30