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>
36
class
FaceTraits
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
49
FaceTraits
()
50
:
m_faceId
(0)
51
,
m_faceScope
(
FACE_SCOPE_NON_LOCAL
)
52
,
m_facePersistency
(
FACE_PERSISTENCY_PERSISTENT
)
53
,
m_linkType
(
LINK_TYPE_POINT_TO_POINT
)
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&
107
setFaceScope
(
FaceScope
faceScope)
108
{
109
wireReset
();
110
m_faceScope
= faceScope;
111
return
static_cast<
C&
>
(*this);
112
}
113
114
FacePersistency
115
getFacePersistency
()
const
116
{
117
return
m_facePersistency
;
118
}
119
120
C&
121
setFacePersistency
(
FacePersistency
facePersistency)
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&
135
setLinkType
(
LinkType
linkType)
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
;
193
FaceScope
m_faceScope
;
194
FacePersistency
m_facePersistency
;
195
LinkType
m_linkType
;
196
uint64_t
m_flags
;
197
};
198
199
}
// namespace nfd
200
}
// namespace ndn
201
202
#endif // NDN_MGMT_NFD_FACE_TRAITS_HPP
ndn::nfd::FaceTraits::getLocalUri
const std::string & getLocalUri() const
Definition:
face-traits.hpp:87
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:75
ndn::nfd::FaceTraits::getFacePersistency
FacePersistency getFacePersistency() const
Definition:
face-traits.hpp:115
ndn::nfd::FACE_SCOPE_NON_LOCAL
face is non-local
Definition:
nfd-constants.hpp:38
ndn::nfd::FaceTraits::m_localUri
std::string m_localUri
Definition:
face-traits.hpp:192
ndn::nfd::FaceTraits::m_remoteUri
std::string m_remoteUri
Definition:
face-traits.hpp:191
ndn::nfd::LINK_TYPE_POINT_TO_POINT
link is point-to-point
Definition:
nfd-constants.hpp:79
ndn::nfd::FaceTraits::m_flags
uint64_t m_flags
Definition:
face-traits.hpp:196
ndn::nfd::FaceTraits::m_facePersistency
FacePersistency m_facePersistency
Definition:
face-traits.hpp:194
ndn::nfd::FaceTraits::getFaceScope
FaceScope getFaceScope() const
Definition:
face-traits.hpp:101
ndn::nfd::FaceTraits::setFaceId
C & setFaceId(uint64_t faceId)
Definition:
face-traits.hpp:65
ndn::nfd::FaceTraits::getRemoteUri
const std::string & getRemoteUri() const
Definition:
face-traits.hpp:73
ndn::nfd::FacePersistency
FacePersistency
Definition:
nfd-constants.hpp:49
ndn::nfd::FaceScope
FaceScope
Definition:
nfd-constants.hpp:34
ndn::nfd::FaceTraits::setLocalUri
C & setLocalUri(const std::string &localUri)
Definition:
face-traits.hpp:93
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
ndn::nfd::FaceTraits::wireReset
virtual void wireReset() const =0
ndn::nfd::FaceTraits::setRemoteUri
C & setRemoteUri(const std::string &remoteUri)
Definition:
face-traits.hpp:79
ndn::nfd::FaceTraits::m_linkType
LinkType m_linkType
Definition:
face-traits.hpp:195
ndn::nfd::FaceTraits::setFaceScope
C & setFaceScope(FaceScope faceScope)
Definition:
face-traits.hpp:107
ndn::nfd::FaceTraits::m_faceId
uint64_t m_faceId
Definition:
face-traits.hpp:190
ndn::nfd::FaceTraits::FaceTraits
FaceTraits()
Definition:
face-traits.hpp:49
ndn::nfd::FaceTraits::getFlags
uint64_t getFlags() const
Definition:
face-traits.hpp:143
ndn::nfd::FaceTraits
providers getters and setters of face information fields
Definition:
face-traits.hpp:36
ndn::nfd::FaceTraits::Error
Definition:
face-traits.hpp:39
ndn::nfd::FaceTraits::getFlagBit
bool getFlagBit(size_t bit) const
Definition:
face-traits.hpp:157
ndn::nfd::FaceTraits::setLinkType
C & setLinkType(LinkType linkType)
Definition:
face-traits.hpp:135
ndn::nfd::FaceTraits::getFaceId
uint64_t getFaceId() const
Definition:
face-traits.hpp:59
ndn::nfd::FaceTraits::m_faceScope
FaceScope m_faceScope
Definition:
face-traits.hpp:193
ndn::nfd::FaceTraits::setFacePersistency
C & setFacePersistency(FacePersistency facePersistency)
Definition:
face-traits.hpp:121
ndn::nfd::FaceTraits::setFlagBit
C & setFlagBit(size_t bit, bool value)
Definition:
face-traits.hpp:167
ndn::nfd::FaceTraits::Error::Error
Error(const std::string &what)
Definition:
face-traits.hpp:43
ndn::nfd::FaceTraits::setFlags
C & setFlags(uint64_t flags)
Definition:
face-traits.hpp:149
ndn::nfd::FACE_PERSISTENCY_PERSISTENT
face is persistent
Definition:
nfd-constants.hpp:53
ndn::tlv::Error
represents an error in TLV encoding or decoding
Definition:
tlv.hpp:50
ndn::nfd::FaceTraits::getLinkType
LinkType getLinkType() const
Definition:
face-traits.hpp:129
ndnSIM
ndn-cxx
src
mgmt
nfd
face-traits.hpp
Generated on Wed Jan 11 2017 18:17:14 for ndnSIM by
1.8.13