NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::Link Class Reference

represents a Link instance More...

#include <link.hpp>

Inheritance diagram for ndn::Link:
Collaboration diagram for ndn::Link:

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 DelegationSetgetDelegations () 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 BlockwireEncode () const
 Encode to a wire format. More...
 
const BlockwireEncode (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 NamegetName () const
 Get name of the Data packet. More...
 
DatasetName (const Name &name)
 Set name to a copy of the given Name. More...
 
const NamegetFullName () const
 Get full name of Data packet, including the implicit digest. More...
 
const MetaInfogetMetaInfo () const
 Get MetaInfo block from Data packet. More...
 
DatasetMetaInfo (const MetaInfo &metaInfo)
 Set metaInfo to a copy of the given MetaInfo. More...
 
uint32_t getContentType () const
 
DatasetContentType (uint32_t type)
 
const time::milliseconds & getFreshnessPeriod () const
 
DatasetFreshnessPeriod (const time::milliseconds &freshnessPeriod)
 
const name::ComponentgetFinalBlockId () const
 
DatasetFinalBlockId (const name::Component &finalBlockId)
 
const BlockgetContent () const
 Get content Block. More...
 
DatasetContent (const uint8_t *buffer, size_t bufferSize)
 Set the content from the buffer (buffer will be copied) More...
 
DatasetContent (const Block &block)
 Set the content from the block. More...
 
DatasetContent (const ConstBufferPtr &contentValue)
 Set the content from the pointer to immutable buffer. More...
 
const SignaturegetSignature () const
 
DatasetSignature (const Signature &signature)
 Set the signature to a copy of the given signature. More...
 
DatasetSignatureValue (const Block &value)
 
nfd::LocalControlHeadergetLocalControlHeader ()
 
const nfd::LocalControlHeadergetLocalControlHeader () const
 
uint64_t getIncomingFaceId () const
 
DatasetIncomingFaceId (uint64_t incomingFaceId)
 
nfd::LocalControlHeader::CachingPolicy getCachingPolicy () const
 
DatasetCachingPolicy (nfd::LocalControlHeader::CachingPolicy cachingPolicy)
 
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, NamegetDelegationFromWire (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...
 

Detailed Description

represents a Link instance

Definition at line 34 of file link.hpp.

Member Typedef Documentation

typedef std::set<std::pair<uint32_t, Name> > ndn::Link::DelegationSet

Definition at line 48 of file link.hpp.

Constructor & Destructor Documentation

ndn::Link::Link ( )
default

Create an empty Link object.

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>();

Otherwise, Link::shared_from_this() will throw std::bad_weak_ptr.

ndn::Link::Link ( const Block block)
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().

ndn::Link::Link ( const Name name)
explicit

Create a Link object with the given name.

Parameters
nameA 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.

Definition at line 46 of file link.cpp.

ndn::Link::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>

Parameters
nameA reference to the name of the redirected namespace
linksA 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().

Member Function Documentation

void ndn::Link::addDelegation ( uint32_t  preference,
const Name name 
)

Add a delegation in the format of <Name, Preference>

Parameters
preferenceThe preference of the delegation to be added
nameThe name of the delegation to be added
Note
If a delegation with 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.

Parameters
nameThe name of the delegation to be removed
Returns
true if delegation is removed, otherwise false

Definition at line 67 of file link.cpp.

References encodeContent().

const Link::DelegationSet & ndn::Link::getDelegations ( ) const

Get the pairs of <Name, Preference>

Returns
a set of delegations

Definition at line 77 of file link.cpp.

void ndn::Link::wireDecode ( const Block wire)

Decode from the wire format.

Warning
This method does not preserve the relative order between delegations. To get a delegation by index, use getDelegationFromWire method.

Definition at line 176 of file link.cpp.

References decodeContent(), and ndn::Data::wireDecode().

Referenced by Link().

std::tuple< uint32_t, Name > ndn::Link::getDelegationFromWire ( const Block block,
size_t  index 
)
static

gets the delegation at index from block

Parameters
blockwire format of a Link object
index0-based index of a delegation in the Link object
Returns
delegation preference and name
Exceptions
std::out_of_rangeindex 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().

ssize_t ndn::Link::findDelegationFromWire ( const Block block,
const Name delegationName 
)
static

finds index of a delegation with delegationName from block

Parameters
blockwire format of a Link object
Returns
0-based index of the first delegation with 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().

ssize_t ndn::Link::countDelegationsFromWire ( const Block block)
static
template<encoding::Tag TAG>
size_t ndn::Link::encodeContent ( EncodingImpl< TAG > &  encoder) const
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().

void ndn::Link::encodeContent ( )
protected

The documentation for this class was generated from the following files: