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
25
#include "
ndn-cxx/encoding/block.hpp
"
26
#include "
ndn-cxx/encoding/nfd-constants.hpp
"
27
28
namespace
ndn
{
29
namespace
nfd
{
30
36
template
<
class
C>
37
class
FaceTraits
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&
95
setFaceScope
(
FaceScope
faceScope)
96
{
97
m_wire
.
reset
();
98
m_faceScope
= faceScope;
99
return
static_cast<C&>(*
this
);
100
}
101
102
FacePersistency
103
getFacePersistency
()
const
104
{
105
return
m_facePersistency
;
106
}
107
108
C&
109
setFacePersistency
(
FacePersistency
facePersistency)
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&
123
setLinkType
(
LinkType
linkType)
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
:
173
FaceTraits
()
174
:
m_faceId
(
INVALID_FACE_ID
)
175
,
m_faceScope
(
FACE_SCOPE_NON_LOCAL
)
176
,
m_facePersistency
(
FACE_PERSISTENCY_PERSISTENT
)
177
,
m_linkType
(
LINK_TYPE_POINT_TO_POINT
)
178
,
m_flags
(0)
179
{
180
}
181
182
protected
:
183
uint64_t
m_faceId
;
184
std::string
m_remoteUri
;
185
std::string
m_localUri
;
186
FaceScope
m_faceScope
;
187
FacePersistency
m_facePersistency
;
188
LinkType
m_linkType
;
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
ndn::nfd::FaceTraits::getLocalUri
const std::string & getLocalUri() const
Definition:
face-traits.hpp:75
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::nfd::LinkType
LinkType
Definition:
nfd-constants.hpp:57
ndn::nfd::FaceTraits::getFacePersistency
FacePersistency getFacePersistency() const
Definition:
face-traits.hpp:103
ndn::nfd::FACE_SCOPE_NON_LOCAL
face is non-local
Definition:
nfd-constants.hpp:36
ndn::nfd::FaceTraits::m_localUri
std::string m_localUri
Definition:
face-traits.hpp:185
ndn::nfd::FaceTraits::m_remoteUri
std::string m_remoteUri
Definition:
face-traits.hpp:184
ndn::nfd::LINK_TYPE_POINT_TO_POINT
link is point-to-point
Definition:
nfd-constants.hpp:59
ndn::nfd::FaceTraits::m_flags
uint64_t m_flags
Definition:
face-traits.hpp:189
ndn::nfd::FaceTraits::m_facePersistency
FacePersistency m_facePersistency
Definition:
face-traits.hpp:187
ndn::Block
Represents a TLV element of NDN packet format.
Definition:
block.hpp:42
ndn::nfd::FaceTraits::getFaceScope
FaceScope getFaceScope() const
Definition:
face-traits.hpp:89
ndn::nfd::FaceTraits::setFaceId
C & setFaceId(uint64_t faceId)
Definition:
face-traits.hpp:53
ndn::nfd::FaceTraits::getRemoteUri
const std::string & getRemoteUri() const
Definition:
face-traits.hpp:61
nfd-constants.hpp
ndn::nfd::FacePersistency
FacePersistency
Definition:
nfd-constants.hpp:45
ndn::nfd::FaceScope
FaceScope
Definition:
nfd-constants.hpp:34
ndn::nfd::FaceTraits::setLocalUri
C & setLocalUri(const std::string &localUri)
Definition:
face-traits.hpp:81
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
ndn::nfd::FaceTraits::m_wire
Block m_wire
Definition:
face-traits.hpp:191
ndn::nfd::FaceTraits::setRemoteUri
C & setRemoteUri(const std::string &remoteUri)
Definition:
face-traits.hpp:67
ndn::nfd::FaceTraits::m_linkType
LinkType m_linkType
Definition:
face-traits.hpp:188
ndn::nfd::FaceTraits::setFaceScope
C & setFaceScope(FaceScope faceScope)
Definition:
face-traits.hpp:95
ndn::nfd::FaceTraits::m_faceId
uint64_t m_faceId
Definition:
face-traits.hpp:183
ndn::Block::reset
void reset()
Reset wire buffer of the element.
Definition:
block.cpp:255
block.hpp
ndn::nfd::FaceTraits::FaceTraits
FaceTraits()
Definition:
face-traits.hpp:173
ndn::nfd::FaceTraits::getFlags
uint64_t getFlags() const
Definition:
face-traits.hpp:131
ndn::nfd::FaceTraits
provides getters and setters for face information fields
Definition:
face-traits.hpp:37
ndn::nfd::FaceTraits::Error
Definition:
face-traits.hpp:40
ndn::nfd::FaceTraits::getFlagBit
bool getFlagBit(size_t bit) const
Definition:
face-traits.hpp:145
ndn::nfd::FaceTraits::setLinkType
C & setLinkType(LinkType linkType)
Definition:
face-traits.hpp:123
ndn::nfd::FaceTraits::getFaceId
uint64_t getFaceId() const
Definition:
face-traits.hpp:47
ndn::nfd::FaceTraits::m_faceScope
FaceScope m_faceScope
Definition:
face-traits.hpp:186
ndn::nfd::FaceTraits::setFacePersistency
C & setFacePersistency(FacePersistency facePersistency)
Definition:
face-traits.hpp:109
ndn::nfd::FaceTraits::setFlagBit
C & setFlagBit(size_t bit, bool value)
Definition:
face-traits.hpp:154
ndn::nfd::FaceTraits::setFlags
C & setFlags(uint64_t flags)
Definition:
face-traits.hpp:137
ndn::nfd::FACE_PERSISTENCY_PERSISTENT
face is persistent
Definition:
nfd-constants.hpp:47
ndn::tlv::Error
represents an error in TLV encoding or decoding
Definition:
tlv.hpp:52
ndn::nfd::FaceTraits::getLinkType
LinkType getLinkType() const
Definition:
face-traits.hpp:117
ndn::nfd::INVALID_FACE_ID
const uint64_t INVALID_FACE_ID
Definition:
nfd-constants.hpp:30
ndnSIM
ndn-cxx
ndn-cxx
mgmt
nfd
face-traits.hpp
Generated on Sun Feb 24 2019 22:16:06 for ndnSIM by
1.8.15