ndn::Interest Class Reference

represents an Interest packet More...

#include <interest.hpp>

Inheritance diagram for ndn::Interest:
[legend]
Collaboration diagram for ndn::Interest:
[legend]

Data Structures

class  Error
 

Public Member Functions

 Interest ()
 Create a new Interest with an empty name (ndn:/) More...
 
 Interest (const Name &name)
 Create a new Interest with the given name. More...
 
 Interest (const Name &name, const time::milliseconds &interestLifetime)
 Create a new Interest with the given name and interest lifetime. More...
 
 Interest (const Block &wire)
 Create from wire encoding. More...
 
template<encoding::Tag TAG>
size_t wireEncode (EncodingImpl< TAG > &encoder) const
 Fast encoding or block size estimation. More...
 
const BlockwireEncode () const
 Encode to a wire format. More...
 
void wireDecode (const Block &wire)
 Decode from the wire format. More...
 
bool hasWire () const
 Check if already has wire. More...
 
std::string toUri () const
 Encode the name according to the NDN URI Scheme. More...
 
bool hasLink () const
 Check whether the Interest contains a Link object. More...
 
const LinkgetLink () const
 Get the link object for this interest. More...
 
void setLink (const Block &link)
 Set the link object for this interest. More...
 
void unsetLink ()
 Delete the link object for this interest. More...
 
bool hasSelectedDelegation () const
 Check whether the Interest includes a selected delegation. More...
 
Name getSelectedDelegation () const
 Get the name of the selected delegation. More...
 
void setSelectedDelegation (const Name &delegationName)
 Set the selected delegation. More...
 
void setSelectedDelegation (size_t delegationIndex)
 Set the selected delegation. More...
 
void unsetSelectedDelegation ()
 Unset the selected delegation. More...
 
bool matchesName (const Name &name) const
 Check if Interest, including selectors, matches the given name. More...
 
bool matchesData (const Data &data) const
 Check if Interest can be satisfied by data. More...
 
bool matchesInterest (const Interest &other) const
 Check if Interest matches other interest. More...
 
const NamegetName () const
 
InterestsetName (const Name &name)
 
const time::milliseconds & getInterestLifetime () const
 
InterestsetInterestLifetime (const time::milliseconds &interestLifetime)
 
bool hasNonce () const
 Check if Nonce set. More...
 
uint32_t getNonce () const
 Get Interest's nonce. More...
 
InterestsetNonce (uint32_t nonce)
 Set Interest's nonce. More...
 
void refreshNonce ()
 Refresh nonce. More...
 
bool hasSelectors () const
 
const SelectorsgetSelectors () const
 
InterestsetSelectors (const Selectors &selectors)
 
int getMinSuffixComponents () const
 
InterestsetMinSuffixComponents (int minSuffixComponents)
 
int getMaxSuffixComponents () const
 
InterestsetMaxSuffixComponents (int maxSuffixComponents)
 
const KeyLocatorgetPublisherPublicKeyLocator () const
 
InterestsetPublisherPublicKeyLocator (const KeyLocator &keyLocator)
 
const ExcludegetExclude () const
 
InterestsetExclude (const Exclude &exclude)
 
int getChildSelector () const
 
InterestsetChildSelector (int childSelector)
 
int getMustBeFresh () const
 
InterestsetMustBeFresh (bool mustBeFresh)
 
bool operator== (const Interest &other) const
 
bool operator!= (const Interest &other) const
 
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...
 

Detailed Description

represents an Interest packet

Definition at line 42 of file interest.hpp.

Constructor & Destructor Documentation

ndn::Interest::Interest ( )

Create a new Interest with an empty name (ndn:/)

Warning
In certain contexts that use Interest::shared_from_this(), Interest must be created using make_shared. Otherwise, .shared_from_this() will throw an exception.

Definition at line 36 of file interest.cpp.

ndn::Interest::Interest ( const Name name)

Create a new Interest with the given name.

Parameters
nameThe name for the interest.
Note
This constructor allows implicit conversion from Name.
Warning
In certain contexts that use Interest::shared_from_this(), Interest must be created using make_shared. Otherwise, .shared_from_this() will throw an exception.

Definition at line 42 of file interest.cpp.

ndn::Interest::Interest ( const Name name,
const time::milliseconds &  interestLifetime 
)

Create a new Interest with the given name and interest lifetime.

Parameters
nameThe name for the interest.
interestLifetimeThe interest lifetime in time::milliseconds, or -1 for none.
Warning
In certain contexts that use Interest::shared_from_this(), Interest must be created using make_shared. Otherwise, .shared_from_this() will throw an exception.

Definition at line 49 of file interest.cpp.

ndn::Interest::Interest ( const Block wire)
explicit

Create from wire encoding.

Warning
In certain contexts that use Interest::shared_from_this(), Interest must be created using make_shared. Otherwise, .shared_from_this() will throw an exception.

Definition at line 56 of file interest.cpp.

Member Function Documentation

int ndn::Interest::getChildSelector ( ) const
inline

Definition at line 367 of file interest.hpp.

const Exclude& ndn::Interest::getExclude ( ) const
inline

Definition at line 353 of file interest.hpp.

const time::milliseconds& ndn::Interest::getInterestLifetime ( ) const
inline

Definition at line 240 of file interest.hpp.

const Link & ndn::Interest::getLink ( ) const

Get the link object for this interest.

Returns
The link object if there is one contained in this interest
Exceptions
Interest::Errorif there is no link object contained in the interest
tlv::Errorif the incorporated link object is malformed

Definition at line 378 of file interest.cpp.

int ndn::Interest::getMaxSuffixComponents ( ) const
inline

Definition at line 325 of file interest.hpp.

int ndn::Interest::getMinSuffixComponents ( ) const
inline

Definition at line 311 of file interest.hpp.

int ndn::Interest::getMustBeFresh ( ) const
inline

Definition at line 381 of file interest.hpp.

const Name& ndn::Interest::getName ( ) const
inline

Definition at line 226 of file interest.hpp.

uint32_t ndn::Interest::getNonce ( ) const

Get Interest's nonce.

If nonce was not set before this call, it will be automatically assigned to a random value

Definition at line 62 of file interest.cpp.

const KeyLocator& ndn::Interest::getPublisherPublicKeyLocator ( ) const
inline

Definition at line 339 of file interest.hpp.

Name ndn::Interest::getSelectedDelegation ( ) const

Get the name of the selected delegation.

Returns
The name of the selected delegation
Exceptions
ErrorSelectedDelegation is not set.

Definition at line 417 of file interest.cpp.

const Selectors& ndn::Interest::getSelectors ( ) const
inline

Definition at line 297 of file interest.hpp.

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

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 67 of file tag-host.hpp.

bool ndn::Interest::hasLink ( ) const

Check whether the Interest contains a Link object.

Returns
True if there is a link object, otherwise false

Definition at line 372 of file interest.cpp.

bool ndn::Interest::hasNonce ( ) const
inline

Check if Nonce set.

Definition at line 256 of file interest.hpp.

bool ndn::Interest::hasSelectedDelegation ( ) const

Check whether the Interest includes a selected delegation.

Returns
True if there is a selected delegation, otherwise false

Definition at line 411 of file interest.cpp.

bool ndn::Interest::hasSelectors ( ) const
inline
Returns
true if Interest has any selector present

Definition at line 291 of file interest.hpp.

bool ndn::Interest::hasWire ( ) const
inline

Check if already has wire.

Definition at line 107 of file interest.hpp.

bool ndn::Interest::matchesData ( const Data data) const

Check if Interest can be satisfied by data.

This method considers Name, MinSuffixComponents, MaxSuffixComponents, PublisherPublicKeyLocator, and Exclude. This method does not consider ChildSelector and MustBeFresh.

Todo:
recognize implicit digest component

Definition at line 132 of file interest.cpp.

bool ndn::Interest::matchesInterest ( const Interest other) const

Check if Interest matches other interest.

Interest matches other if both have the same name, selectors, and link. Other fields (e.g., Nonce) may be different.

Todo:
Implement distinguishing interests by link. The current implementation checks only name+selectors (Issue #3162).
Todo:
#3162 match Link field

Definition at line 216 of file interest.cpp.

bool ndn::Interest::matchesName ( const Name name) const

Check if Interest, including selectors, matches the given name.

Parameters
nameThe name to be matched. If this is a Data name, it shall contain the implicit digest component

Definition at line 105 of file interest.cpp.

bool ndn::Interest::operator!= ( const Interest other) const
inline

Definition at line 402 of file interest.hpp.

bool ndn::Interest::operator== ( const Interest other) const
inline

Definition at line 396 of file interest.hpp.

void ndn::Interest::refreshNonce ( )

Refresh nonce.

It's guaranteed that new nonce value differs from the existing one.

If nonce is already set, it will be updated to a different random value. If nonce is not set, this method does nothing.

Definition at line 91 of file interest.cpp.

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

remove tag item

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

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

Interest& ndn::Interest::setChildSelector ( int  childSelector)
inline

Definition at line 373 of file interest.hpp.

Interest& ndn::Interest::setExclude ( const Exclude exclude)
inline

Definition at line 359 of file interest.hpp.

Interest& ndn::Interest::setInterestLifetime ( const time::milliseconds &  interestLifetime)
inline

Definition at line 246 of file interest.hpp.

void ndn::Interest::setLink ( const Block link)

Set the link object for this interest.

Parameters
linkThe link object that will be included in this interest (in wire format)
Postcondition
!hasSelectedDelegation()

Definition at line 390 of file interest.cpp.

Interest& ndn::Interest::setMaxSuffixComponents ( int  maxSuffixComponents)
inline

Definition at line 331 of file interest.hpp.

Interest& ndn::Interest::setMinSuffixComponents ( int  minSuffixComponents)
inline

Definition at line 317 of file interest.hpp.

Interest& ndn::Interest::setMustBeFresh ( bool  mustBeFresh)
inline

Definition at line 387 of file interest.hpp.

Interest& ndn::Interest::setName ( const Name name)
inline

Definition at line 232 of file interest.hpp.

Interest & ndn::Interest::setNonce ( uint32_t  nonce)

Set Interest's nonce.

If wire format already exists, this call simply replaces nonce in the existing wire format, without resetting and recreating it.

Definition at line 76 of file interest.cpp.

Interest& ndn::Interest::setPublisherPublicKeyLocator ( const KeyLocator keyLocator)
inline

Definition at line 345 of file interest.hpp.

void ndn::Interest::setSelectedDelegation ( const Name delegationName)

Set the selected delegation.

Parameters
delegationNameThe name of the selected delegation
Exceptions
ErrorLink is not set.
std::invalid_argumentdelegationName does not exist in Link.

Definition at line 426 of file interest.cpp.

void ndn::Interest::setSelectedDelegation ( size_t  delegationIndex)

Set the selected delegation.

Parameters
delegationIndexThe index of the selected delegation
Exceptions
ErrorLink is not set.
std::out_of_rangedelegationIndex is out of bound in Link.

Definition at line 439 of file interest.cpp.

Interest& ndn::Interest::setSelectors ( const Selectors selectors)
inline

Definition at line 303 of file interest.hpp.

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

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 80 of file tag-host.hpp.

std::string ndn::Interest::toUri ( ) const
inline

Encode the name according to the NDN URI Scheme.

If there are interest selectors, this method will append "?" and add the selectors as a query string. For example, "/test/name?ndn.ChildSelector=1"

Definition at line 423 of file interest.hpp.

void ndn::Interest::unsetLink ( )

Delete the link object for this interest.

Postcondition
!hasLink()

Definition at line 402 of file interest.cpp.

void ndn::Interest::unsetSelectedDelegation ( )

Unset the selected delegation.

Definition at line 449 of file interest.cpp.

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

Decode from the wire format.

Definition at line 303 of file interest.cpp.

template<encoding::Tag TAG>
size_t ndn::Interest::wireEncode ( EncodingImpl< TAG > &  encoder) const

Fast encoding or block size estimation.

Definition at line 225 of file interest.cpp.

const Block & ndn::Interest::wireEncode ( ) const

Encode to a wire format.

Definition at line 285 of file interest.cpp.