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/tlv-nfd.hpp"
26 
27 namespace ndn {
28 namespace nfd {
29 
35 template<class C>
37 {
38 public:
39  class Error : public tlv::Error
40  {
41  public:
42  explicit
43  Error(const std::string& what)
44  : tlv::Error(what)
45  {
46  }
47  };
48 
50  : m_faceId(0)
54  , m_flags(0x0)
55  {
56  }
57 
58  uint64_t
59  getFaceId() const
60  {
61  return m_faceId;
62  }
63 
64  C&
65  setFaceId(uint64_t faceId)
66  {
67  wireReset();
68  m_faceId = faceId;
69  return static_cast<C&>(*this);
70  }
71 
72  const std::string&
73  getRemoteUri() const
74  {
75  return m_remoteUri;
76  }
77 
78  C&
79  setRemoteUri(const std::string& remoteUri)
80  {
81  wireReset();
82  m_remoteUri = remoteUri;
83  return static_cast<C&>(*this);
84  }
85 
86  const std::string&
87  getLocalUri() const
88  {
89  return m_localUri;
90  }
91 
92  C&
93  setLocalUri(const std::string& localUri)
94  {
95  wireReset();
96  m_localUri = localUri;
97  return static_cast<C&>(*this);
98  }
99 
100  FaceScope
101  getFaceScope() const
102  {
103  return m_faceScope;
104  }
105 
106  C&
108  {
109  wireReset();
110  m_faceScope = faceScope;
111  return static_cast<C&>(*this);
112  }
113 
116  {
117  return m_facePersistency;
118  }
119 
120  C&
122  {
123  wireReset();
124  m_facePersistency = facePersistency;
125  return static_cast<C&>(*this);
126  }
127 
128  LinkType
129  getLinkType() const
130  {
131  return m_linkType;
132  }
133 
134  C&
136  {
137  wireReset();
138  m_linkType = linkType;
139  return static_cast<C&>(*this);
140  }
141 
142  uint64_t
143  getFlags() const
144  {
145  return m_flags;
146  }
147 
148  C&
149  setFlags(uint64_t flags)
150  {
151  wireReset();
152  m_flags = flags;
153  return static_cast<C&>(*this);
154  }
155 
156  bool
157  getFlagBit(size_t bit) const
158  {
159  if (bit >= 64) {
160  BOOST_THROW_EXCEPTION(std::out_of_range("bit must be within range [0, 64)"));
161  }
162 
163  return m_flags & (1 << bit);
164  }
165 
166  C&
167  setFlagBit(size_t bit, bool value)
168  {
169  if (bit >= 64) {
170  BOOST_THROW_EXCEPTION(std::out_of_range("bit must be within range [0, 64)"));
171  }
172 
173  wireReset();
174 
175  if (value) {
176  m_flags |= (1 << bit);
177  }
178  else {
179  m_flags &= ~(1 << bit);
180  }
181 
182  return static_cast<C&>(*this);
183  }
184 
185 protected:
186  virtual void
187  wireReset() const = 0;
188 
189 protected:
190  uint64_t m_faceId;
191  std::string m_remoteUri;
192  std::string m_localUri;
196  uint64_t m_flags;
197 };
198 
199 } // namespace nfd
200 } // namespace ndn
201 
202 #endif // NDN_MGMT_NFD_FACE_TRAITS_HPP
const std::string & getLocalUri() const
Definition: face-traits.hpp:87
Copyright (c) 2011-2015 Regents of the University of California.
FacePersistency getFacePersistency() const
std::string m_localUri
std::string m_remoteUri
FacePersistency m_facePersistency
FaceScope getFaceScope() const
C & setFaceId(uint64_t faceId)
Definition: face-traits.hpp:65
const std::string & getRemoteUri() const
Definition: face-traits.hpp:73
C & setLocalUri(const std::string &localUri)
Definition: face-traits.hpp:93
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
virtual void wireReset() const =0
C & setRemoteUri(const std::string &remoteUri)
Definition: face-traits.hpp:79
C & setFaceScope(FaceScope faceScope)
uint64_t getFlags() const
providers getters and setters of face information fields
Definition: face-traits.hpp:36
bool getFlagBit(size_t bit) const
C & setLinkType(LinkType linkType)
uint64_t getFaceId() const
Definition: face-traits.hpp:59
C & setFacePersistency(FacePersistency facePersistency)
C & setFlagBit(size_t bit, bool value)
Error(const std::string &what)
Definition: face-traits.hpp:43
C & setFlags(uint64_t flags)
represents an error in TLV encoding or decoding
Definition: tlv.hpp:50
LinkType getLinkType() const