represents a list of Delegations More...
#include <delegation-list.hpp>
Classes | |
class | Error |
Public Types | |
enum | InsertConflictResolution { INS_REPLACE, INS_APPEND, INS_SKIP } |
what to do when inserting a duplicate name More... | |
using | const_iterator = std::vector< Delegation >::const_iterator |
Public Member Functions | |
DelegationList () | |
construct an empty DelegationList More... | |
DelegationList (std::initializer_list< Delegation > dels) | |
construct a sorted DelegationList with specified delegations More... | |
DelegationList (const Block &block, bool wantSort=true) | |
decode a DelegationList More... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder, uint32_t type=tlv::ForwardingHint) const |
encode into wire format More... | |
void | wireDecode (const Block &block, bool wantSort=true) |
decode a DelegationList More... | |
bool | isSorted () const noexcept |
const_iterator | begin () const noexcept |
const_iterator | end () const noexcept |
NDN_CXX_NODISCARD bool | empty () const noexcept |
size_t | size () const noexcept |
const Delegation & | operator[] (size_t i) const |
get the i-th delegation More... | |
const Delegation & | at (size_t i) const |
get the i-th delegation More... | |
void | sort () |
sort the delegation list More... | |
bool | insert (uint64_t preference, const Name &name, InsertConflictResolution onConflict=INS_REPLACE) |
insert Delegation More... | |
bool | insert (const Delegation &del, InsertConflictResolution onConflict=INS_REPLACE) |
insert Delegation More... | |
size_t | erase (uint64_t preference, const Name &name) |
delete Delegation(s) with specified preference and name More... | |
size_t | erase (const Delegation &del) |
delete Delegation(s) with matching preference and name More... | |
size_t | erase (const Name &name) |
erase Delegation(s) with specified name More... | |
Friends | |
bool | operator== (const DelegationList &lhs, const DelegationList &rhs) |
Compare whether two DelegationLists are equal. More... | |
bool | operator!= (const DelegationList &lhs, const DelegationList &rhs) |
represents a list of Delegations
Delegations are stored in an std::vector, under the assumption that there is usually only a small number of Delegations, so that copying is acceptable when they are modified.
Definition at line 37 of file delegation-list.hpp.
using ndn::DelegationList::const_iterator = std::vector<Delegation>::const_iterator |
Definition at line 87 of file delegation-list.hpp.
what to do when inserting a duplicate name
Enumerator | |
---|---|
INS_REPLACE | existing delegation(s) with the same name are replaced with the new delegation |
INS_APPEND | multiple delegations with the same name are kept in the DelegationList
|
INS_SKIP | new delegation is not inserted if an existing delegation has the same name |
Definition at line 150 of file delegation-list.hpp.
ndn::DelegationList::DelegationList | ( | ) |
construct an empty DelegationList
Definition at line 31 of file delegation-list.cpp.
ndn::DelegationList::DelegationList | ( | std::initializer_list< Delegation > | dels | ) |
construct a sorted DelegationList with specified delegations
This is equivalent to inserting each delegation into an empty DelegationList with INS_REPLACE conflict resolution.
Definition at line 36 of file delegation-list.cpp.
References INS_REPLACE, and insert().
|
explicit |
decode a DelegationList
Definition at line 44 of file delegation-list.cpp.
References wireDecode().
size_t ndn::DelegationList::wireEncode | ( | EncodingImpl< TAG > & | encoder, |
uint32_t | type = tlv::ForwardingHint |
||
) | const |
encode into wire format
encoder | either an EncodingBuffer or an EncodingEstimator |
type | TLV-TYPE number, either Content (for Link ) or ForwardingHint |
std::invalid_argument | type is invalid |
Error | there is no Delegation |
Definition at line 63 of file delegation-list.cpp.
References ndn::tlv::LinkDelegation, ndn::tlv::LinkPreference, NDN_THROW, ndn::encoding::prependNonNegativeIntegerBlock(), size(), and ndn::to_string().
Referenced by ndn::Interest::wireEncode().
void ndn::DelegationList::wireDecode | ( | const Block & | block, |
bool | wantSort = true |
||
) |
decode a DelegationList
block | either a Content block (from Link ) or a ForwardingHint block |
wantSort | if true, delegations are sorted |
Error | the block cannot be parsed as a list of Delegations |
Definition at line 105 of file delegation-list.cpp.
References ndn::Block::elements(), ndn::tlv::LinkDelegation, ndn::tlv::LinkPreference, ndn::tlv::Name, NDN_THROW, NDN_THROW_NESTED, ndn::Block::parse(), ndn::encoding::readNonNegativeInteger(), size(), ndn::to_string(), and ndn::Block::type().
Referenced by DelegationList(), ndn::Link::wireDecode(), and ndn::Interest::wireDecode().
|
inlinenoexcept |
Definition at line 82 of file delegation-list.hpp.
|
inlinenoexcept |
Definition at line 90 of file delegation-list.hpp.
Referenced by ndn::operator<<().
|
inlinenoexcept |
Definition at line 96 of file delegation-list.hpp.
Referenced by ndn::operator<<().
|
inlinenoexcept |
Definition at line 102 of file delegation-list.hpp.
Referenced by nfd::fw::Strategy::lookupFib().
|
inlinenoexcept |
Definition at line 108 of file delegation-list.hpp.
Referenced by operator[](), wireDecode(), and wireEncode().
|
inline |
get the i-th delegation
Definition at line 117 of file delegation-list.hpp.
References size().
|
inline |
get the i-th delegation
std::out_of_range | i >= size() |
Definition at line 127 of file delegation-list.hpp.
void ndn::DelegationList::sort | ( | ) |
sort the delegation list
A DelegationList can be constructed as sorted or unsorted. In most cases, it is recommended to use a sorted DelegationList. An unsorted DelegationList is useful for extracting the i-th delegation from a received ForwardingHint or Link object.
This method turns an unsorted DelegationList into a sorted DelegationList. If access to unsorted DelegationList is not needed, it is more efficient to sort the DelegationList in wireDecode.
Definition at line 154 of file delegation-list.cpp.
bool ndn::DelegationList::insert | ( | uint64_t | preference, |
const Name & | name, | ||
InsertConflictResolution | onConflict = INS_REPLACE |
||
) |
insert Delegation
Definition at line 170 of file delegation-list.cpp.
References INS_APPEND, INS_REPLACE, INS_SKIP, NDN_THROW, and nonstd::optional_lite::nullopt.
Referenced by ndn::Link::addDelegation(), DelegationList(), and insert().
|
inline |
insert Delegation
Definition at line 176 of file delegation-list.hpp.
References insert(), ndn::Delegation::name, and ndn::Delegation::preference.
|
inline |
delete Delegation(s) with specified preference and name
Definition at line 185 of file delegation-list.hpp.
Referenced by ndn::Link::removeDelegation().
|
inline |
delete Delegation(s) with matching preference and name
Definition at line 194 of file delegation-list.hpp.
References ndn::Delegation::name, and ndn::Delegation::preference.
|
inline |
erase Delegation(s) with specified name
Definition at line 203 of file delegation-list.hpp.
References nonstd::optional_lite::nullopt.
|
friend |
Compare whether two DelegationLists are equal.
Definition at line 227 of file delegation-list.hpp.
|
friend |
Definition at line 233 of file delegation-list.hpp.