ndn::PrefixAnnouncement Class Reference

A prefix announcement object that represents an application's intent of registering a prefix toward itself. More...

#include <ndn-cxx/prefix-announcement.hpp>

+ Inheritance diagram for ndn::PrefixAnnouncement:
+ Collaboration diagram for ndn::PrefixAnnouncement:

Classes

class  Error
 

Public Member Functions

 PrefixAnnouncement ()
 Construct an empty prefix announcement. More...
 
 PrefixAnnouncement (Data data)
 Decode a prefix announcement from Data. More...
 
const NamegetAnnouncedName () const
 Return announced name. More...
 
const std::optional< Data > & getData () const
 Get the Data representing the prefix announcement, if available. More...
 
time::milliseconds getExpiration () const
 Return relative expiration period. More...
 
std::optional< security::ValidityPeriodgetValidityPeriod () const
 Return absolute validity period. More...
 
PrefixAnnouncementsetAnnouncedName (Name name)
 Set announced name. More...
 
PrefixAnnouncementsetExpiration (time::milliseconds expiration)
 Set relative expiration period. More...
 
PrefixAnnouncementsetValidityPeriod (std::optional< security::ValidityPeriod > validity)
 Set absolute validity period. More...
 
const DatatoData (KeyChain &keyChain, const ndn::security::SigningInfo &si=security::SigningInfo(), std::optional< uint64_t > version=std::nullopt) const
 Create a Data packet representing the prefix announcement, if it does not exist. More...
 

Static Public Member Functions

static const name::ComponentgetKeywordComponent ()
 Returns the well-known keyword name component used for prefix announcements (32=PA) More...
 

Friends

bool operator== (const PrefixAnnouncement &lhs, const PrefixAnnouncement &rhs)
 Test whether two prefix announcements have the same name, expiration period, and validity period. More...
 

Detailed Description

A prefix announcement object that represents an application's intent of registering a prefix toward itself.

See also
https://redmine.named-data.net/projects/nfd/wiki/PrefixAnnouncement

Definition at line 36 of file prefix-announcement.hpp.

Constructor & Destructor Documentation

◆ PrefixAnnouncement() [1/2]

ndn::PrefixAnnouncement::PrefixAnnouncement ( )
default

Construct an empty prefix announcement.

Postcondition
getData() == nullopt
getAnnouncedName() == "/"
getExpiration() == 0_ms

◆ PrefixAnnouncement() [2/2]

ndn::PrefixAnnouncement::PrefixAnnouncement ( Data  data)
explicit

Decode a prefix announcement from Data.

Exceptions
tlv::Errorthe Data is not a prefix announcement.
Postcondition
getData() == data

Definition at line 29 of file prefix-announcement.cpp.

Member Function Documentation

◆ getAnnouncedName()

const Name& ndn::PrefixAnnouncement::getAnnouncedName ( ) const
inline

Return announced name.

Definition at line 82 of file prefix-announcement.hpp.

◆ getData()

const std::optional<Data>& ndn::PrefixAnnouncement::getData ( ) const
inline

Get the Data representing the prefix announcement, if available.

Definition at line 62 of file prefix-announcement.hpp.

◆ getExpiration()

time::milliseconds ndn::PrefixAnnouncement::getExpiration ( ) const
inline

Return relative expiration period.

Definition at line 96 of file prefix-announcement.hpp.

◆ getKeywordComponent()

const name::Component & ndn::PrefixAnnouncement::getKeywordComponent ( )
static

Returns the well-known keyword name component used for prefix announcements (32=PA)

Definition at line 120 of file prefix-announcement.cpp.

◆ getValidityPeriod()

std::optional<security::ValidityPeriod> ndn::PrefixAnnouncement::getValidityPeriod ( ) const
inline

Return absolute validity period.

Definition at line 111 of file prefix-announcement.hpp.

◆ setAnnouncedName()

PrefixAnnouncement & ndn::PrefixAnnouncement::setAnnouncedName ( Name  name)

Set announced name.

Postcondition
getData() == nullopt

Definition at line 93 of file prefix-announcement.cpp.

◆ setExpiration()

PrefixAnnouncement & ndn::PrefixAnnouncement::setExpiration ( time::milliseconds  expiration)

Set relative expiration period.

Exceptions
std::invalid_argumentexpiration period is negative.
Postcondition
getData() == nullopt

Definition at line 101 of file prefix-announcement.cpp.

◆ setValidityPeriod()

PrefixAnnouncement & ndn::PrefixAnnouncement::setValidityPeriod ( std::optional< security::ValidityPeriod validity)

Set absolute validity period.

Postcondition
getData() == nullopt

Definition at line 112 of file prefix-announcement.cpp.

◆ toData()

const Data & ndn::PrefixAnnouncement::toData ( KeyChain keyChain,
const ndn::security::SigningInfo si = security::SigningInfo(),
std::optional< uint64_t >  version = std::nullopt 
) const

Create a Data packet representing the prefix announcement, if it does not exist.

Parameters
keyChainKeyChain to sign the Data.
sisigning parameters.
versionversion number in Data name; if nullopt, use current Unix timestamp (in milliseconds) as the version number.
Postcondition
getData() == the returned Data

Definition at line 67 of file prefix-announcement.cpp.

Friends And Related Function Documentation

◆ operator==

bool operator== ( const PrefixAnnouncement lhs,
const PrefixAnnouncement rhs 
)
friend

Test whether two prefix announcements have the same name, expiration period, and validity period.

Definition at line 139 of file prefix-announcement.hpp.