NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
key-locator.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2013-2021 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_CXX_KEY_LOCATOR_HPP
23
#define NDN_CXX_KEY_LOCATOR_HPP
24
25
#include "
ndn-cxx/name.hpp
"
26
#include "
ndn-cxx/util/variant.hpp
"
27
28
namespace
ndn
{
29
30
class
KeyLocator
31
{
32
public
:
33
class
Error
:
public
tlv::Error
34
{
35
public
:
36
using
tlv::Error::Error
;
37
};
38
39
public
:
// constructors
43
KeyLocator
();
44
49
KeyLocator
(
const
Name
&
name
);
50
53
explicit
54
KeyLocator
(
const
Block
& wire);
55
56
public
:
// encode and decode
59
template
<encoding::Tag TAG>
60
size_t
61
wireEncode
(
EncodingImpl<TAG>
& encoder)
const
;
62
63
const
Block
&
64
wireEncode
()
const
;
65
70
void
71
wireDecode
(
const
Block
& wire);
72
73
public
:
// attributes
74
NDN_CXX_NODISCARD
bool
75
empty
()
const
76
{
77
return
holds_alternative<monostate>(m_locator);
78
}
79
80
uint32_t
81
getType
()
const
;
82
88
KeyLocator
&
89
clear
();
90
94
const
Name
&
95
getName
()
const
;
96
101
KeyLocator
&
102
setName
(
const
Name
& name);
103
107
const
Block
&
108
getKeyDigest
()
const
;
109
115
KeyLocator
&
116
setKeyDigest
(
const
Block
& keyDigest);
117
123
KeyLocator
&
124
setKeyDigest
(
const
ConstBufferPtr
& keyDigest);
125
126
private
:
// non-member operators
127
// NOTE: the following "hidden friend" operators are available via
128
// argument-dependent lookup only and must be defined inline.
129
130
friend
bool
131
operator==
(
const
KeyLocator
& lhs,
const
KeyLocator
& rhs)
132
{
133
return
lhs.m_locator == rhs.m_locator;
134
}
135
136
friend
bool
137
operator!=
(
const
KeyLocator
& lhs,
const
KeyLocator
& rhs)
138
{
139
return
lhs.m_locator != rhs.m_locator;
140
}
141
142
private
:
143
// - monostate represents an empty KeyLocator, without any nested TLVs
144
// - Name is used when the nested TLV contains a name
145
// - Block is used when the nested TLV is a KeyDigest
146
// - in all other (unsupported) cases the nested TLV type is stored as uint32_t
147
variant<monostate, Name, Block, uint32_t> m_locator;
148
149
mutable
Block
m_wire;
150
151
friend
std::ostream&
operator<<
(std::ostream&,
const
KeyLocator
&);
152
};
153
154
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS
(
KeyLocator
);
155
156
std::ostream&
157
operator<<
(std::ostream& os,
const
KeyLocator
& keyLocator);
158
159
}
// namespace ndn
160
161
#endif // NDN_CXX_KEY_LOCATOR_HPP
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::KeyLocator::getKeyDigest
const Block & getKeyDigest() const
Get nested KeyDigest element.
Definition:
key-locator.cpp:163
ndn::KeyLocator::setName
KeyLocator & setName(const Name &name)
Set nested Name element.
Definition:
key-locator.cpp:155
ndn::KeyLocator::getName
const Name & getName() const
Get nested Name element.
Definition:
key-locator.cpp:144
ndn::KeyLocator::wireDecode
void wireDecode(const Block &wire)
Decode from wire encoding.
Definition:
key-locator.cpp:91
ndn::KeyLocator::setKeyDigest
KeyLocator & setKeyDigest(const Block &keyDigest)
Set nested KeyDigest element (whole TLV).
Definition:
key-locator.cpp:174
ndn::KeyLocator::operator==
friend bool operator==(const KeyLocator &lhs, const KeyLocator &rhs)
Definition:
key-locator.hpp:131
ndn::Block
Represents a TLV element of the NDN packet format.
Definition:
block.hpp:44
ndn::KeyLocator::KeyLocator
KeyLocator()
Construct an empty KeyLocator.
ndn::KeyLocator::wireEncode
const Block & wireEncode() const
Definition:
key-locator.cpp:75
ndn::KeyLocator::empty
NDN_CXX_NODISCARD bool empty() const
Definition:
key-locator.hpp:75
variant.hpp
NDN_CXX_NODISCARD
#define NDN_CXX_NODISCARD
Definition:
backports.hpp:68
ndn::Name
Represents an absolute name.
Definition:
name.hpp:41
ndn::KeyLocator::Error
Definition:
key-locator.hpp:33
ndn::encoding::EncodingImpl
Definition:
encoding-buffer-fwd.hpp:36
ndn::KeyLocator::clear
KeyLocator & clear()
Reset KeyLocator to its default-constructed state.
Definition:
key-locator.cpp:136
ndn::KeyLocator
Definition:
key-locator.hpp:30
ndn::KeyLocator::operator!=
friend bool operator!=(const KeyLocator &lhs, const KeyLocator &rhs)
Definition:
key-locator.hpp:137
ndn::KeyLocator::operator<<
friend std::ostream & operator<<(std::ostream &, const KeyLocator &)
Definition:
key-locator.cpp:194
name.hpp
ndn::KeyLocator::getType
uint32_t getType() const
Definition:
key-locator.cpp:119
ndn::tlv::Error::Error
Error(const char *expectedType, uint32_t actualType)
Definition:
tlv.cpp:27
ndn::NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Interest)
ndn::name
Definition:
name-component-types.hpp:33
ndn::tlv::Error
represents an error in TLV encoding or decoding
Definition:
tlv.hpp:52
ndn::ConstBufferPtr
shared_ptr< const Buffer > ConstBufferPtr
Definition:
buffer.hpp:139
ndnSIM
ndn-cxx
ndn-cxx
key-locator.hpp
Generated on Fri May 6 2022 12:34:12 for ndnSIM by
1.8.13