nlsr::NameMap Class Reference

Assigning numbers to router names. More...

#include <name-map.hpp>

Public Member Functions

void addEntry (const ndn::Name &rtrName)
 Insert a router name. More...
 
std::optional< int32_t > getMappingNoByRouterName (const ndn::Name &rtrName) const
 Find mapping number of a router name. More...
 
std::optional< ndn::Name > getRouterNameByMappingNo (int32_t mn) const
 Find router name by its mapping number. More...
 
size_t size () const
 Return number of entries in this container. More...
 

Static Public Member Functions

template<typename IteratorType >
static NameMap createFromAdjLsdb (IteratorType first, IteratorType last)
 Create a NameMap populated with router names in Adjacency LSAs. More...
 
template<typename IteratorType >
static NameMap createFromCoordinateLsdb (IteratorType first, IteratorType last)
 Create a NameMap populated with router names in Coordinate LSAs. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const NameMap &map)
 

Detailed Description

Assigning numbers to router names.

NameMap assigns a "mapping number" to each inserted router name. It then provides bidirectional lookups between router names and their mapping numbers.

These numbers are non-negative integers assigned sequentially, starting from zero. They can support constructing a matrix of routers, where the mapping numbers are used as row and column indices in place of router names.

Definition at line 45 of file name-map.hpp.

Member Function Documentation

◆ addEntry()

void nlsr::NameMap::addEntry ( const ndn::Name &  rtrName)

Insert a router name.

Parameters
rtrNameRouter name.

Definition at line 30 of file name-map.cpp.

◆ createFromAdjLsdb()

template<typename IteratorType >
static NameMap nlsr::NameMap::createFromAdjLsdb ( IteratorType  first,
IteratorType  last 
)
inlinestatic

Create a NameMap populated with router names in Adjacency LSAs.

Template Parameters
IteratorTypeA LegacyInputIterator whose value type is convertible to std::shared_ptr<AdjLsa>.
Parameters
firstRange begin iterator.
lastRange past-end iterator. It must be reachable by incrementing first .
Returns
NameMap populated with origin and adjacent router names.

Definition at line 58 of file name-map.hpp.

◆ createFromCoordinateLsdb()

template<typename IteratorType >
static NameMap nlsr::NameMap::createFromCoordinateLsdb ( IteratorType  first,
IteratorType  last 
)
inlinestatic

Create a NameMap populated with router names in Coordinate LSAs.

Template Parameters
IteratorTypeA LegacyInputIterator whose value type is std::shared_ptr<Lsa>.
Parameters
firstRange begin iterator.
lastRange past-end iterator. It must be reachable by incrementing first .
Returns
NameMap populated with origin router names.

Definition at line 82 of file name-map.hpp.

◆ getMappingNoByRouterName()

std::optional< int32_t > nlsr::NameMap::getMappingNoByRouterName ( const ndn::Name &  rtrName) const

Find mapping number of a router name.

Parameters
rtrNameRouter name.
Returns
Mapping number, or std::nullopt if it does not exist.

Definition at line 47 of file name-map.cpp.

◆ getRouterNameByMappingNo()

std::optional< ndn::Name > nlsr::NameMap::getRouterNameByMappingNo ( int32_t  mn) const

Find router name by its mapping number.

Parameters
mnMapping number.
Returns
Router name, or std::nullopt if it does not exist.

Definition at line 37 of file name-map.cpp.

◆ size()

size_t nlsr::NameMap::size ( ) const
inline

Return number of entries in this container.

Returns
Number of entries in this container.

Definition at line 120 of file name-map.hpp.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const NameMap map 
)
friend

Definition at line 56 of file name-map.cpp.