NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
nfd::strategy_choice::StrategyChoice Class Reference

represents the Strategy Choice table More...

#include <strategy-choice.hpp>

Inheritance diagram for nfd::strategy_choice::StrategyChoice:
Collaboration diagram for nfd::strategy_choice::StrategyChoice:

Public Types

typedef boost::transformed_range< name_tree::GetTableEntry< Entry >, const name_tree::RangeRange
 
typedef boost::range_iterator< Range >::type const_iterator
 

Public Member Functions

 StrategyChoice (NameTree &nameTree, unique_ptr< fw::Strategy > defaultStrategy)
 
size_t size () const
 
bool hasStrategy (const Name &strategyName, bool isExact=false) const
 determines if a strategy is installed More...
 
std::pair< bool, fw::Strategy * > install (unique_ptr< fw::Strategy > strategy)
 install a strategy More...
 
bool insert (const Name &prefix, const Name &strategyName)
 set strategy of prefix to be strategyName More...
 
void erase (const Name &prefix)
 make prefix to inherit strategy from its parent More...
 
std::pair< bool, Nameget (const Name &prefix) const
 get strategy Name of prefix More...
 
fw::StrategyfindEffectiveStrategy (const Name &prefix) const
 get effective strategy for prefix More...
 
fw::StrategyfindEffectiveStrategy (const pit::Entry &pitEntry) const
 get effective strategy for pitEntry More...
 
fw::StrategyfindEffectiveStrategy (const measurements::Entry &measurementsEntry) const
 get effective strategy for measurementsEntry More...
 
const_iterator begin () const
 
const_iterator end () const
 
template<typename K >
StrategyfindEffectiveStrategyImpl (const K &key) const
 

Detailed Description

represents the Strategy Choice table

The Strategy Choice table maintains available Strategy types, and associates Name prefixes with Strategy types.

Each strategy is identified by a strategyName. It's recommended to include a version number as the last component of strategyName.

A Name prefix is owned by a strategy if a longest prefix match on the Strategy Choice table returns that strategy.

Definition at line 48 of file strategy-choice.hpp.

Member Typedef Documentation

◆ Range

Definition at line 124 of file strategy-choice.hpp.

◆ const_iterator

typedef boost::range_iterator<Range>::type nfd::strategy_choice::StrategyChoice::const_iterator

Definition at line 125 of file strategy-choice.hpp.

Constructor & Destructor Documentation

◆ StrategyChoice()

nfd::strategy_choice::StrategyChoice::StrategyChoice ( NameTree nameTree,
unique_ptr< fw::Strategy defaultStrategy 
)

Definition at line 45 of file strategy-choice.cpp.

Member Function Documentation

◆ size()

size_t nfd::strategy_choice::StrategyChoice::size ( ) const
inline

Definition at line 54 of file strategy-choice.hpp.

References erase(), findEffectiveStrategy(), hasStrategy(), insert(), and install().

◆ hasStrategy()

bool nfd::strategy_choice::StrategyChoice::hasStrategy ( const Name strategyName,
bool  isExact = false 
) const

determines if a strategy is installed

Parameters
strategyNamename of the strategy
isExacttrue to require exact match, false to permit unversioned strategyName
Returns
true if strategy is installed

Definition at line 53 of file strategy-choice.cpp.

Referenced by nfd::TablesConfigSection::ensureConfigured(), ns3::ndn::StrategyChoiceHelper::Install(), nfd::fw::installStrategies(), size(), and nfd::StrategyChoiceManager::StrategyChoiceManager().

◆ install()

std::pair< bool, Strategy * > nfd::strategy_choice::StrategyChoice::install ( unique_ptr< fw::Strategy strategy)

install a strategy

Returns
if installed, true, and a pointer to the strategy instance; if not installed due to duplicate strategyName, false, and a pointer to the existing strategy instance

Definition at line 64 of file strategy-choice.cpp.

References ndn::Name::isPrefixOf(), NFD_LOG_ERROR, and ndn::Name::size().

Referenced by findEffectiveStrategy(), ns3::ndn::StrategyChoiceHelper::Install(), nfd::fw::installStrategies(), and size().

◆ insert()

bool nfd::strategy_choice::StrategyChoice::insert ( const Name prefix,
const Name strategyName 
)

set strategy of prefix to be strategyName

Parameters
prefixthe name prefix for which strategyName should be used
strategyNamethe strategy to be used
Returns
true on success

This method set a strategy onto a Name prefix. The strategy must have been installed. The strategyName can either be exact (contains version component), or omit the version component to pick the latest version.

Definition at line 98 of file strategy-choice.cpp.

References findEffectiveStrategy(), nfd::fw::Strategy::getName(), nfd::strategy_choice::Entry::getStrategy(), nfd::name_tree::Entry::getStrategyChoiceEntry(), nfd::name_tree::NameTree::lookup(), NFD_LOG_ERROR, NFD_LOG_TRACE, nfd::strategy_choice::Entry::setStrategy(), and nfd::name_tree::Entry::setStrategyChoiceEntry().

Referenced by nfd::TablesConfigSection::ensureConfigured(), size(), and nfd::StrategyChoiceManager::StrategyChoiceManager().

◆ erase()

void nfd::strategy_choice::StrategyChoice::erase ( const Name prefix)

◆ get()

std::pair< bool, Name > nfd::strategy_choice::StrategyChoice::get ( const Name prefix) const

◆ findEffectiveStrategy() [1/3]

Strategy & nfd::strategy_choice::StrategyChoice::findEffectiveStrategy ( const Name prefix) const

get effective strategy for prefix

Definition at line 184 of file strategy-choice.cpp.

Referenced by erase(), insert(), size(), and nfd::measurements::MeasurementsAccessor::~MeasurementsAccessor().

◆ findEffectiveStrategy() [2/3]

Strategy & nfd::strategy_choice::StrategyChoice::findEffectiveStrategy ( const pit::Entry pitEntry) const

get effective strategy for pitEntry

This is equivalent to .findEffectiveStrategy(pitEntry.getName())

Definition at line 190 of file strategy-choice.cpp.

◆ findEffectiveStrategy() [3/3]

Strategy & nfd::strategy_choice::StrategyChoice::findEffectiveStrategy ( const measurements::Entry measurementsEntry) const

get effective strategy for measurementsEntry

This is equivalent to .findEffectiveStrategy(measurementsEntry.getName())

Definition at line 196 of file strategy-choice.cpp.

References nfd::fw::Strategy::getName(), install(), nfd::name_tree::NameTree::lookup(), ns3::ndn::Name, NFD_LOG_INFO, and nfd::name_tree::Entry::setStrategyChoiceEntry().

◆ begin()

const_iterator nfd::strategy_choice::StrategyChoice::begin ( ) const
inline
Returns
an iterator to the beginning
Note
Iteration order is implementation-defined.
Warning
Undefined behavior may occur if a FIB/PIT/Measurements/StrategyChoice entry is inserted or erased during enumeration.

Definition at line 133 of file strategy-choice.hpp.

◆ end()

const_iterator nfd::strategy_choice::StrategyChoice::end ( ) const
inline
Returns
an iterator to the end
See also
begin()

Definition at line 142 of file strategy-choice.hpp.

References nfd::strategy_choice::StrategyChoice.

◆ findEffectiveStrategyImpl()

template<typename K >
Strategy& nfd::strategy_choice::StrategyChoice::findEffectiveStrategyImpl ( const K &  key) const

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