NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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 
152  static ssize_t
153  findDelegationFromWire(const Block& block, const Name& delegationName);
154 
155  static ssize_t
156  countDelegationsFromWire(const Block& block);
157 
158 protected:
163  template<encoding::Tag TAG>
164  size_t
165  encodeContent(EncodingImpl<TAG>& encoder) const;
166 
167  void
168  encodeContent();
169 
170  void
171  decodeContent();
172 
173 private:
174  bool
175  removeDelegationNoEncode(const Name& name);
176 
177 private:
178  DelegationSet m_delegations;
179 };
180 
181 } // namespace ndn
182 
183 #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:39
const size_t INVALID_SELECTED_DELEGATION_INDEX
Definition: link.hpp:30