NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
face-traits.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_MGMT_NFD_FACE_TRAITS_HPP
23 #define NDN_MGMT_NFD_FACE_TRAITS_HPP
24 
25 #include "../../encoding/block.hpp"
26 #include "../../encoding/nfd-constants.hpp"
27 
28 namespace ndn {
29 namespace nfd {
30 
36 template<class C>
38 {
39 public:
40  class Error : public tlv::Error
41  {
42  public:
43  explicit
44  Error(const std::string& what)
45  : tlv::Error(what)
46  {
47  }
48  };
49 
50  uint64_t
51  getFaceId() const
52  {
53  return m_faceId;
54  }
55 
56  C&
57  setFaceId(uint64_t faceId)
58  {
59  m_wire.reset();
60  m_faceId = faceId;
61  return static_cast<C&>(*this);
62  }
63 
64  const std::string&
65  getRemoteUri() const
66  {
67  return m_remoteUri;
68  }
69 
70  C&
71  setRemoteUri(const std::string& remoteUri)
72  {
73  m_wire.reset();
74  m_remoteUri = remoteUri;
75  return static_cast<C&>(*this);
76  }
77 
78  const std::string&
79  getLocalUri() const
80  {
81  return m_localUri;
82  }
83 
84  C&
85  setLocalUri(const std::string& localUri)
86  {
87  m_wire.reset();
88  m_localUri = localUri;
89  return static_cast<C&>(*this);
90  }
91 
92  FaceScope
93  getFaceScope() const
94  {
95  return m_faceScope;
96  }
97 
98  C&
100  {
101  m_wire.reset();
102  m_faceScope = faceScope;
103  return static_cast<C&>(*this);
104  }
105 
108  {
109  return m_facePersistency;
110  }
111 
112  C&
114  {
115  m_wire.reset();
116  m_facePersistency = facePersistency;
117  return static_cast<C&>(*this);
118  }
119 
120  LinkType
121  getLinkType() const
122  {
123  return m_linkType;
124  }
125 
126  C&
128  {
129  m_wire.reset();
130  m_linkType = linkType;
131  return static_cast<C&>(*this);
132  }
133 
134  uint64_t
135  getFlags() const
136  {
137  return m_flags;
138  }
139 
140  C&
141  setFlags(uint64_t flags)
142  {
143  m_wire.reset();
144  m_flags = flags;
145  return static_cast<C&>(*this);
146  }
147 
148  bool
149  getFlagBit(size_t bit) const
150  {
151  if (bit >= 64) {
152  BOOST_THROW_EXCEPTION(std::out_of_range("bit must be within range [0, 64)"));
153  }
154  return m_flags & (1 << bit);
155  }
156 
157  C&
158  setFlagBit(size_t bit, bool value)
159  {
160  if (bit >= 64) {
161  BOOST_THROW_EXCEPTION(std::out_of_range("bit must be within range [0, 64)"));
162  }
163 
164  m_wire.reset();
165 
166  if (value) {
167  m_flags |= (1 << bit);
168  }
169  else {
170  m_flags &= ~(1 << bit);
171  }
172 
173  return static_cast<C&>(*this);
174  }
175 
176 protected:
182  , m_flags(0)
183  {
184  }
185 
186 protected:
187  uint64_t m_faceId;
188  std::string m_remoteUri;
189  std::string m_localUri;
193  uint64_t m_flags;
194 
195  mutable Block m_wire;
196 };
197 
198 } // namespace nfd
199 } // namespace ndn
200 
201 #endif // NDN_MGMT_NFD_FACE_TRAITS_HPP
LinkType getLinkType() const
Copyright (c) 2011-2015 Regents of the University of California.
uint64_t getFlags() const
std::string m_localUri
std::string m_remoteUri
FaceScope getFaceScope() const
Definition: face-traits.hpp:93
FacePersistency m_facePersistency
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
C & setFaceId(uint64_t faceId)
Definition: face-traits.hpp:57
bool getFlagBit(size_t bit) const
C & setLocalUri(const std::string &localUri)
Definition: face-traits.hpp:85
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
C & setRemoteUri(const std::string &remoteUri)
Definition: face-traits.hpp:71
uint64_t getFaceId() const
Definition: face-traits.hpp:51
C & setFaceScope(FaceScope faceScope)
Definition: face-traits.hpp:99
void reset()
Reset wire buffer of the element.
Definition: block.cpp:256
const std::string & getLocalUri() const
Definition: face-traits.hpp:79
const std::string & getRemoteUri() const
Definition: face-traits.hpp:65
FacePersistency getFacePersistency() const
provides getters and setters for face information fields
Definition: face-traits.hpp:37
C & setLinkType(LinkType linkType)
C & setFacePersistency(FacePersistency facePersistency)
C & setFlagBit(size_t bit, bool value)
Error(const std::string &what)
Definition: face-traits.hpp:44
C & setFlags(uint64_t flags)
represents an error in TLV encoding or decoding
Definition: tlv.hpp:50
const uint64_t INVALID_FACE_ID