NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: 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; -*- */
2 /*
3  * Copyright (c) 2013-2018 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_MGMT_NFD_FACE_TRAITS_HPP
23 #define NDN_MGMT_NFD_FACE_TRAITS_HPP
24 
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  using tlv::Error::Error;
44  };
45 
46  uint64_t
47  getFaceId() const
48  {
49  return m_faceId;
50  }
51 
52  C&
53  setFaceId(uint64_t faceId)
54  {
55  m_wire.reset();
56  m_faceId = faceId;
57  return static_cast<C&>(*this);
58  }
59 
60  const std::string&
61  getRemoteUri() const
62  {
63  return m_remoteUri;
64  }
65 
66  C&
67  setRemoteUri(const std::string& remoteUri)
68  {
69  m_wire.reset();
70  m_remoteUri = remoteUri;
71  return static_cast<C&>(*this);
72  }
73 
74  const std::string&
75  getLocalUri() const
76  {
77  return m_localUri;
78  }
79 
80  C&
81  setLocalUri(const std::string& localUri)
82  {
83  m_wire.reset();
84  m_localUri = localUri;
85  return static_cast<C&>(*this);
86  }
87 
88  FaceScope
89  getFaceScope() const
90  {
91  return m_faceScope;
92  }
93 
94  C&
96  {
97  m_wire.reset();
98  m_faceScope = faceScope;
99  return static_cast<C&>(*this);
100  }
101 
104  {
105  return m_facePersistency;
106  }
107 
108  C&
110  {
111  m_wire.reset();
112  m_facePersistency = facePersistency;
113  return static_cast<C&>(*this);
114  }
115 
116  LinkType
117  getLinkType() const
118  {
119  return m_linkType;
120  }
121 
122  C&
124  {
125  m_wire.reset();
126  m_linkType = linkType;
127  return static_cast<C&>(*this);
128  }
129 
130  uint64_t
131  getFlags() const
132  {
133  return m_flags;
134  }
135 
136  C&
137  setFlags(uint64_t flags)
138  {
139  m_wire.reset();
140  m_flags = flags;
141  return static_cast<C&>(*this);
142  }
143 
144  bool
145  getFlagBit(size_t bit) const
146  {
147  if (bit >= 64) {
148  BOOST_THROW_EXCEPTION(std::out_of_range("bit must be within range [0, 64)"));
149  }
150  return m_flags & (1 << bit);
151  }
152 
153  C&
154  setFlagBit(size_t bit, bool value)
155  {
156  if (bit >= 64) {
157  BOOST_THROW_EXCEPTION(std::out_of_range("bit must be within range [0, 64)"));
158  }
159 
160  m_wire.reset();
161 
162  if (value) {
163  m_flags |= (1 << bit);
164  }
165  else {
166  m_flags &= ~(1 << bit);
167  }
168 
169  return static_cast<C&>(*this);
170  }
171 
172 protected:
178  , m_flags(0)
179  {
180  }
181 
182 protected:
183  uint64_t m_faceId;
184  std::string m_remoteUri;
185  std::string m_localUri;
189  uint64_t m_flags;
190 
191  mutable Block m_wire;
192 };
193 
194 } // namespace nfd
195 } // namespace ndn
196 
197 #endif // NDN_MGMT_NFD_FACE_TRAITS_HPP
const std::string & getLocalUri() const
Definition: face-traits.hpp:75
Copyright (c) 2011-2015 Regents of the University of California.
FacePersistency getFacePersistency() const
std::string m_localUri
std::string m_remoteUri
FacePersistency m_facePersistency
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
FaceScope getFaceScope() const
Definition: face-traits.hpp:89
C & setFaceId(uint64_t faceId)
Definition: face-traits.hpp:53
const std::string & getRemoteUri() const
Definition: face-traits.hpp:61
C & setLocalUri(const std::string &localUri)
Definition: face-traits.hpp:81
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:67
C & setFaceScope(FaceScope faceScope)
Definition: face-traits.hpp:95
void reset()
Reset wire buffer of the element.
Definition: block.cpp:255
uint64_t getFlags() const
provides getters and setters for face information fields
Definition: face-traits.hpp:37
bool getFlagBit(size_t bit) const
C & setLinkType(LinkType linkType)
uint64_t getFaceId() const
Definition: face-traits.hpp:47
C & setFacePersistency(FacePersistency facePersistency)
C & setFlagBit(size_t bit, bool value)
C & setFlags(uint64_t flags)
represents an error in TLV encoding or decoding
Definition: tlv.hpp:52
LinkType getLinkType() const
const uint64_t INVALID_FACE_ID