ndn::Link Class Reference

represents a Link object More...

#include <ndn-cxx/link.hpp>

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

Classes

class  Error
 

Public Member Functions

 Link ()
 Create an empty Link object. More...
 
 Link (const Block &wire, bool wantSort=true)
 Decode a Link object from a Block. More...
 
 Link (const Name &name, std::initializer_list< Delegation > dels={})
 Create a Link object with the given name and delegations. More...
 
void addDelegation (uint32_t preference, const Name &name)
 Add a delegation in the format of <Name, Preference> More...
 
uint64_t getCongestionMark () const
 get the value of the CongestionMark tag More...
 
const BlockgetContent () const
 Get Content. More...
 
uint32_t getContentType () const
 
const DelegationListgetDelegationList () const
 Get the delegations. More...
 
const optional< name::Component > & getFinalBlock () const
 
time::milliseconds getFreshnessPeriod () const
 
const NamegetFullName () const
 Get full name including implicit digest. More...
 
const MetaInfogetMetaInfo () const
 Get MetaInfo. More...
 
const NamegetName () const
 Get name. More...
 
const SignaturegetSignature () const
 Get Signature. More...
 
template<typename T >
shared_ptr< T > getTag () const
 get a tag item More...
 
bool hasWire () const
 Check if this instance has cached wire encoding. More...
 
bool removeDelegation (const Name &name)
 Remove a delegation whose name is name. More...
 
template<typename T >
void removeTag () const
 remove tag item More...
 
void setCongestionMark (uint64_t mark)
 set the CongestionMark tag to the specified value More...
 
DatasetContent (const Block &block)
 Set Content from a block. More...
 
DatasetContent (const uint8_t *value, size_t valueSize)
 Copy Content value from raw buffer. More...
 
DatasetContent (ConstBufferPtr value)
 Set Content from wire buffer. More...
 
DatasetContentType (uint32_t type)
 
void setDelegationList (const DelegationList &dels)
 Set the delegations. More...
 
DatasetFinalBlock (optional< name::Component > finalBlockId)
 
DatasetFreshnessPeriod (time::milliseconds freshnessPeriod)
 
DatasetMetaInfo (const MetaInfo &metaInfo)
 Set MetaInfo. More...
 
DatasetName (const Name &name)
 Set name. More...
 
DatasetSignature (const Signature &signature)
 Set Signature. More...
 
DatasetSignatureValue (const Block &value)
 Set SignatureValue. More...
 
template<typename T >
void setTag (shared_ptr< T > tag) const
 set a tag item More...
 
void wireDecode (const Block &wire, bool wantSort=true)
 Decode from the wire format. More...
 
void wireDecode (const Block &wire)
 Decode from wire in NDN Packet Format v0.2 or v0.3. More...
 
template<encoding::Tag TAG>
size_t wireEncode (EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const
 Prepend wire encoding to encoder in NDN Packet Format v0.2. More...
 
const BlockwireEncode (EncodingBuffer &encoder, const Block &signatureValue) const
 Finalize Data packet encoding with the specified SignatureValue. More...
 
const BlockwireEncode () const
 Encode to a Block. More...
 

Protected Member Functions

void resetWire ()
 Clear wire encoding and cached FullName. More...
 

Detailed Description

represents a Link object

Definition at line 32 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>();
ndn::Link::Link ( const Block wire,
bool  wantSort = true 
)
explicit

Decode a Link object from a Block.

Parameters
wirea TLV block
wantSortif false, relative order among delegations is preserved

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

Definition at line 35 of file link.cpp.

ndn::Link::Link ( const Name name,
std::initializer_list< Delegation dels = {} 
)
explicit

Create a Link object with the given name and delegations.

Parameters
nameA reference to the name of the redirected namespace
delsDelegations in payload

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, dels);

Definition at line 40 of file link.cpp.

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 86 of file link.cpp.

uint64_t ndn::PacketBase::getCongestionMark ( ) const
inherited

get the value of the CongestionMark tag

Definition at line 28 of file packet-base.cpp.

const Block & ndn::Data::getContent ( ) const
inherited

Get Content.

The Content value is accessible through value()/value_size() or value_begin()/value_end() methods of the Block class.

Definition at line 232 of file data.cpp.

uint32_t ndn::Data::getContentType ( ) const
inlineinherited

Definition at line 204 of file data.hpp.

const DelegationList& ndn::Link::getDelegationList ( ) const
inline

Get the delegations.

Definition at line 84 of file link.hpp.

const optional<name::Component>& ndn::Data::getFinalBlock ( ) const
inlineinherited

Definition at line 222 of file data.hpp.

time::milliseconds ndn::Data::getFreshnessPeriod ( ) const
inlineinherited

Definition at line 213 of file data.hpp.

const Name & ndn::Data::getFullName ( ) const
inherited

Get full name including implicit digest.

Precondition
hasWire() == true; i.e. wireEncode() must have been called
Exceptions
ErrorData has no wire encoding

Definition at line 195 of file data.cpp.

const MetaInfo& ndn::Data::getMetaInfo ( ) const
inlineinherited

Get MetaInfo.

Definition at line 138 of file data.hpp.

const Name& ndn::Data::getName ( ) const
inlineinherited

Get name.

Definition at line 124 of file data.hpp.

const Signature& ndn::Data::getSignature ( ) const
inlineinherited

Get Signature.

Definition at line 185 of file data.hpp.

template<typename T >
shared_ptr< T > ndn::TagHost::getTag ( ) const
inherited

get a tag item

Template Parameters
Ttype of the tag, which must be a subclass of ndn::Tag
Return values
nullptrif no Tag of type T is stored

Definition at line 66 of file tag-host.hpp.

bool ndn::Data::hasWire ( ) const
inlineinherited

Check if this instance has cached wire encoding.

Definition at line 108 of file data.hpp.

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 93 of file link.cpp.

template<typename T >
void ndn::TagHost::removeTag ( ) const
inherited

remove tag item

Note
Tag can be removed even on a const tag host instance

Definition at line 93 of file tag-host.hpp.

void ndn::Data::resetWire ( )
protectedinherited

Clear wire encoding and cached FullName.

Note
This does not clear the SignatureValue.

Definition at line 209 of file data.cpp.

void ndn::PacketBase::setCongestionMark ( uint64_t  mark)
inherited

set the CongestionMark tag to the specified value

Definition at line 41 of file packet-base.cpp.

Data & ndn::Data::setContent ( const Block block)
inherited

Set Content from a block.

If block's TLV-TYPE is Content, it will be used directly as Data's Content element. If block's TLV-TYPE is not Content, it will be nested into a Content element.

Returns
a reference to this Data, to allow chaining

Definition at line 241 of file data.cpp.

Data & ndn::Data::setContent ( const uint8_t *  value,
size_t  valueSize 
)
inherited

Copy Content value from raw buffer.

Parameters
valuepointer to the first octet of the value
valueSizesize of the raw buffer
Returns
a reference to this Data, to allow chaining

Definition at line 256 of file data.cpp.

Data & ndn::Data::setContent ( ConstBufferPtr  value)
inherited

Set Content from wire buffer.

Parameters
valueContent value, which does not need to be a TLV element
Returns
a reference to this Data, to allow chaining

Definition at line 264 of file data.cpp.

Data & ndn::Data::setContentType ( uint32_t  type)
inherited

Definition at line 288 of file data.cpp.

void ndn::Link::setDelegationList ( const DelegationList dels)

Set the delegations.

Note
This is more efficient than multiple addDelegation and removeDelegation invocations.

Definition at line 79 of file link.cpp.

Data & ndn::Data::setFinalBlock ( optional< name::Component finalBlockId)
inherited

Definition at line 304 of file data.cpp.

Data & ndn::Data::setFreshnessPeriod ( time::milliseconds  freshnessPeriod)
inherited

Definition at line 296 of file data.cpp.

Data & ndn::Data::setMetaInfo ( const MetaInfo metaInfo)
inherited

Set MetaInfo.

Returns
a reference to this Data, to allow chaining

Definition at line 224 of file data.cpp.

Data & ndn::Data::setName ( const Name name)
inherited

Set name.

Returns
a reference to this Data, to allow chaining

Definition at line 216 of file data.cpp.

Data & ndn::Data::setSignature ( const Signature signature)
inherited

Set Signature.

Returns
a reference to this Data, to allow chaining

Definition at line 272 of file data.cpp.

Data & ndn::Data::setSignatureValue ( const Block value)
inherited

Set SignatureValue.

Returns
a reference to this Data, to allow chaining

Definition at line 280 of file data.cpp.

template<typename T >
void ndn::TagHost::setTag ( shared_ptr< T >  tag) const
inherited

set a tag item

Template Parameters
Ttype of the tag, which must be a subclass of ndn::Tag
Note
Tag can be set even on a const tag host instance

Definition at line 79 of file tag-host.hpp.

void ndn::Link::wireDecode ( const Block wire,
bool  wantSort = true 
)

Decode from the wire format.

Parameters
wirea TLV block
wantSortif false, relative order among delegations is preserved

Definition at line 67 of file link.cpp.

void ndn::Data::wireDecode ( const Block wire)
inherited

Decode from wire in NDN Packet Format v0.2 or v0.3.

Definition at line 122 of file data.cpp.

template<encoding::Tag TAG>
size_t ndn::Data::wireEncode ( EncodingImpl< TAG > &  encoder,
bool  wantUnsignedPortionOnly = false 
) const
inherited

Prepend wire encoding to encoder in NDN Packet Format v0.2.

Parameters
encoderEncodingEstimator or EncodingBuffer instance
wantUnsignedPortionOnlyIf true, only prepends Name, MetaInfo, Content, and SignatureInfo to encoder, but omit SignatureValue and outmost Type-Length of Data element. This is intended to be used with wireEncode(encoder, signatureValue).
Exceptions
ErrorSignatureBits are not provided and wantUnsignedPortionOnly is false.

Definition at line 48 of file data.cpp.

const Block & ndn::Data::wireEncode ( EncodingBuffer &  encoder,
const Block signatureValue 
) const
inherited

Finalize Data packet encoding with the specified SignatureValue.

Parameters
encoderEncodingBuffer containing Name, MetaInfo, Content, and SignatureInfo, but without SignatureValue or outmost Type-Length of Data element
signatureValueSignatureValue element

This method is intended to be used in concert with Data::wireEncode(encoder, true)

Data data;
...
EncodingBuffer encoder;
data.wireEncode(encoder, true);
...
Block signatureValue = <sign_over_unsigned_portion>(encoder.buf(), encoder.size());
data.wireEncode(encoder, signatureValue)

Definition at line 93 of file data.cpp.

const Block & ndn::Data::wireEncode ( ) const
inherited

Encode to a Block.

Precondition
Data is signed.

Normally, this function encodes to NDN Packet Format v0.2. However, if this instance has cached wire encoding (hasWire() is true), the cached encoding is returned and it might be in v0.3 format.

Definition at line 106 of file data.cpp.