represents a Link instance More...
#include <link.hpp>
Classes | |
class | Error |
Public Types | |
typedef std::set< std::pair< uint32_t, Name > > | DelegationSet |
Public Member Functions | |
Link ()=default | |
Create an empty Link object. More... | |
Link (const Block &block) | |
Create a Link object from a Block. More... | |
Link (const Name &name) | |
Create a Link object with the given name. More... | |
Link (const Name &name, std::initializer_list< std::pair< uint32_t, Name >> links) | |
Create a Link object with the given name and pairs of <Preference, Name> More... | |
void | addDelegation (uint32_t preference, const Name &name) |
Add a delegation in the format of <Name, Preference> More... | |
bool | removeDelegation (const Name &name) |
Remove a delegation whose name is name . More... | |
const DelegationSet & | getDelegations () const |
Get the pairs of <Name, Preference> More... | |
void | wireDecode (const Block &wire) |
Decode from the wire format. More... | |
Public Member Functions inherited from ndn::Data | |
Data () | |
Create an empty Data object. More... | |
Data (const Name &name) | |
Create a new Data object with the given name. More... | |
Data (const Block &wire) | |
Create a new Data object from wire encoding. More... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const |
Fast encoding or block size estimation. More... | |
const Block & | wireEncode () const |
Encode to a wire format. More... | |
const Block & | wireEncode (EncodingBuffer &encoder, const Block &signatureValue) const |
Finalize Data packet encoding with the specified SignatureValue. More... | |
void | wireDecode (const Block &wire) |
Decode from the wire format. More... | |
bool | hasWire () const |
Check if Data is already has wire encoding. More... | |
const Name & | getName () const |
Get name of the Data packet. More... | |
Data & | setName (const Name &name) |
Set name to a copy of the given Name. More... | |
const Name & | getFullName () const |
Get full name of Data packet, including the implicit digest. More... | |
const MetaInfo & | getMetaInfo () const |
Get MetaInfo block from Data packet. More... | |
Data & | setMetaInfo (const MetaInfo &metaInfo) |
Set metaInfo to a copy of the given MetaInfo. More... | |
uint32_t | getContentType () const |
Data & | setContentType (uint32_t type) |
const time::milliseconds & | getFreshnessPeriod () const |
Data & | setFreshnessPeriod (const time::milliseconds &freshnessPeriod) |
const name::Component & | getFinalBlockId () const |
Data & | setFinalBlockId (const name::Component &finalBlockId) |
const Block & | getContent () const |
Get content Block. More... | |
Data & | setContent (const uint8_t *buffer, size_t bufferSize) |
Set the content from the buffer (buffer will be copied) More... | |
Data & | setContent (const Block &block) |
Set the content from the block. More... | |
Data & | setContent (const ConstBufferPtr &contentValue) |
Set the content from the pointer to immutable buffer. More... | |
const Signature & | getSignature () const |
Data & | setSignature (const Signature &signature) |
Set the signature to a copy of the given signature. More... | |
Data & | setSignatureValue (const Block &value) |
bool | operator== (const Data &other) const |
bool | operator!= (const Data &other) const |
Public Member Functions inherited from ndn::TagHost | |
template<typename T > | |
shared_ptr< T > | getTag () const |
get a tag item More... | |
template<typename T > | |
void | setTag (shared_ptr< T > tag) const |
set a tag item More... | |
template<typename T > | |
void | removeTag () const |
remove tag item More... | |
Static Public Member Functions | |
static std::tuple< uint32_t, Name > | getDelegationFromWire (const Block &block, size_t index) |
gets the delegation at index from block More... | |
static ssize_t | findDelegationFromWire (const Block &block, const Name &delegationName) |
finds index of a delegation with delegationName from block More... | |
static ssize_t | countDelegationsFromWire (const Block &block) |
Protected Member Functions | |
template<encoding::Tag TAG> | |
size_t | encodeContent (EncodingImpl< TAG > &encoder) const |
prepend Link object as a Content block to the encoder More... | |
void | encodeContent () |
void | decodeContent () |
Protected Member Functions inherited from ndn::Data | |
void | onChanged () |
Clear the wire encoding. More... | |
typedef std::set<std::pair<uint32_t, Name> > ndn::Link::DelegationSet |
|
default |
|
explicit |
Create a Link object from a Block.
Note that in certain contexts that use Link::shared_from_this(), Link must be created using make_shared
:
shared_ptr<Link> linkObject = make_shared<Link>(block);
Otherwise, Link::shared_from_this() will throw std::bad_weak_ptr.
Definition at line 41 of file link.cpp.
References wireDecode().
|
explicit |
Create a Link object with the given name.
name | A reference to the name of the redirected namespace |
Note that in certain contexts that use Link::shared_from_this(), Link must be created using make_shared
:
shared_ptr<Link> link = make_shared<Link>(name);
Otherwise, Link::shared_from_this() will throw std::bad_weak_ptr.
Create a Link object with the given name and pairs of <Preference, Name>
name | A reference to the name of the redirected namespace |
links | A reference to the list of pairs of the redirected namespace along with its priority |
Note that in certain contexts that use Link::shared_from_this(), Link must be created using make_shared
:
shared_ptr<Link> link = make_shared<Link>(name, links);
Otherwise, Link::shared_from_this() will throw std::bad_weak_ptr.
Definition at line 51 of file link.cpp.
References encodeContent().
void ndn::Link::addDelegation | ( | uint32_t | preference, |
const Name & | name | ||
) |
Add a delegation in the format of <Name, Preference>
preference | The preference of the delegation to be added |
name | The name of the delegation to be added |
name
exists, its preference will be updated Definition at line 59 of file link.cpp.
References encodeContent().
bool ndn::Link::removeDelegation | ( | const Name & | name | ) |
Remove a delegation whose name is name
.
name | The name of the delegation to be removed |
Definition at line 67 of file link.cpp.
References encodeContent().
const Link::DelegationSet & ndn::Link::getDelegations | ( | ) | const |
Get the pairs of <Name, Preference>
Definition at line 77 of file link.cpp.
Referenced by nfd::NetworkRegionTable::isInProducerRegion(), and nfd::fw::Strategy::lookupFib().
void ndn::Link::wireDecode | ( | const Block & | wire | ) |
Decode from the wire format.
getDelegationFromWire
method. Definition at line 176 of file link.cpp.
References decodeContent(), and ndn::Data::wireDecode().
Referenced by Link().
|
static |
gets the delegation at index
from block
std::out_of_range | index is out of range |
Definition at line 183 of file link.cpp.
References ndn::tlv::Content, ndn::Block::elements(), ndn::Block::get(), ndn::tlv::LinkDelegation, ndn::tlv::LinkPreference, ns3::ndn::Name, ndn::tlv::Name, ndn::Block::parse(), ndn::encoding::readNonNegativeInteger(), and ndn::Block::type().
Referenced by ndn::Interest::getSelectedDelegation().
|
static |
finds index of a delegation with delegationName
from block
delegationName
, or -1 if no such delegation exists Definition at line 200 of file link.cpp.
References ndn::tlv::Content, ndn::Block::elements(), ndn::Block::get(), ndn::INVALID_SELECTED_DELEGATION_INDEX, ndn::tlv::LinkDelegation, ndn::tlv::Name, and ndn::Block::parse().
Referenced by ndn::Interest::setSelectedDelegation().
|
static |
Definition at line 221 of file link.cpp.
References ndn::tlv::Content, ndn::Block::elements_size(), ndn::Block::get(), and ndn::Block::parse().
Referenced by ndn::Interest::wireDecode().
|
protected |
prepend Link object as a Content block to the encoder
The outermost Content element is not part of Link object structure.
Definition at line 84 of file link.cpp.
References ndn::tlv::Content, ndn::tlv::LinkDelegation, ndn::tlv::LinkPreference, ndn::encoding::prependNonNegativeIntegerBlock(), and ndn::Data::wireEncode().
|
protected |
Definition at line 118 of file link.cpp.
References ndn::tlv::ContentType_Link, ndn::Data::onChanged(), ndn::Data::setContent(), and ndn::Data::setContentType().
Referenced by addDelegation(), Link(), and removeDelegation().
|
protected |
Definition at line 133 of file link.cpp.
References ndn::tlv::ContentType_Link, ndn::Block::elements(), ndn::Data::getContent(), ndn::Data::getContentType(), ndn::Block::parse(), and ndn::encoding::readNonNegativeInteger().
Referenced by wireDecode().