34 namespace strategy_choice {
    49   : m_forwarder(forwarder)
    50   , m_nameTree(m_forwarder.getNameTree())
    58   auto entry = make_unique<Entry>(
Name());
    59   entry->setStrategy(Strategy::create(strategyName, m_forwarder));
    60   NFD_LOG_INFO(
"setDefaultStrategy " << entry->getStrategyInstanceName());
    65   nte.setStrategyChoiceEntry(std::move(entry));
    72   if (prefix.
size() > NameTree::getMaxDepth()) {
    73     return InsertResult::DEPTH_EXCEEDED;
    76   unique_ptr<Strategy> strategy;
    78     strategy = Strategy::create(strategyName, m_forwarder);
    80   catch (
const std::invalid_argument& e) {
    81     NFD_LOG_ERROR(
"insert(" << prefix << 
"," << strategyName << 
") cannot create strategy: " << e.what());
    85   if (strategy == 
nullptr) {
    86     NFD_LOG_ERROR(
"insert(" << prefix << 
"," << strategyName << 
") strategy not registered");
    87     return InsertResult::NOT_REGISTERED;
    93   if (entry != 
nullptr) {
    95       NFD_LOG_TRACE(
"insert(" << prefix << 
") not changing " << strategy->getInstanceName());
    96       return InsertResult::OK;
    99     NFD_LOG_TRACE(
"insert(" << prefix << 
") changing from " << oldStrategy->getInstanceName() <<
   100                   " to " << strategy->getInstanceName());
   104     auto newEntry = make_unique<Entry>(prefix);
   105     entry = newEntry.get();
   108     NFD_LOG_TRACE(
"insert(" << prefix << 
") new entry " << strategy->getInstanceName());
   111   this->changeStrategy(*entry, *oldStrategy, *strategy);
   113   return InsertResult::OK;
   116 StrategyChoice::InsertResult::InsertResult(Status status, 
const std::string& exceptionMessage)
   118   , m_exceptionMessage(exceptionMessage)
   125   switch (res.m_status) {
   126     case StrategyChoice::InsertResult::OK:
   128     case StrategyChoice::InsertResult::NOT_REGISTERED:
   129       return os << 
"Strategy not registered";
   130     case StrategyChoice::InsertResult::EXCEPTION:
   131       return os << 
"Error instantiating strategy: " << res.m_exceptionMessage;
   132     case StrategyChoice::InsertResult::DEPTH_EXCEEDED:
   133       return os << 
"Prefix has too many components (limit is "   134                  << 
to_string(NameTree::getMaxDepth()) << 
")";
   142   BOOST_ASSERT(prefix.
size() > 0);
   145   if (nte == 
nullptr) {
   149   Entry* entry = nte->getStrategyChoiceEntry();
   150   if (entry == 
nullptr) {
   157   this->changeStrategy(*entry, oldStrategy, parentStrategy);
   159   nte->setStrategyChoiceEntry(
nullptr);
   160   m_nameTree.eraseIfEmpty(nte);
   164 std::pair<bool, Name>
   168   if (nte == 
nullptr) {
   169     return {
false, 
Name()};
   173   if (entry == 
nullptr) {
   174     return {
false, 
Name()};
   182 StrategyChoice::findEffectiveStrategyImpl(
const K& key)
 const   185   BOOST_ASSERT(nte != 
nullptr);
   192   return this->findEffectiveStrategyImpl(prefix);
   198   return this->findEffectiveStrategyImpl(pitEntry);
   204   return this->findEffectiveStrategyImpl(measurementsEntry);
   212   for (
const shared_ptr<pit::Entry>& pitEntry : nte.
getPitEntries()) {
   213     pitEntry->clearStrategyInfo();
   214     for (
const pit::InRecord& inRecord : pitEntry->getInRecords()) {
   217     for (
const pit::OutRecord& outRecord : pitEntry->getOutRecords()) {
   229   const Name& oldInstanceName = oldStrategy.getInstanceName();
   230   const Name& newInstanceName = newStrategy.getInstanceName();
   231   if (Strategy::areSameType(oldInstanceName, newInstanceName)) {
   234                  << oldInstanceName << 
" -> " << newInstanceName
   240                << oldInstanceName << 
" -> " << newInstanceName);
   245   BOOST_ASSERT(rootNte != 
nullptr);
   246   auto&& ntChanged = m_nameTree.partialEnumerate(entry.
getPrefix(),
   248       if (&nte == rootNte) {
   251       if (nte.getStrategyChoiceEntry() != 
nullptr) {
   252         return {
false, 
false};
   262 StrategyChoice::getRange()
 const boost::range_iterator< Range >::type const_iterator
 
static void clearStrategyInfo(const name_tree::Entry &nte)
 
fw::Strategy & findEffectiveStrategy(const Name &prefix) const 
get effective strategy for prefix 
 
const Name & getStrategyInstanceName() const 
 
contains information about an Interest from an incoming face 
 
void erase(const Name &prefix)
make prefix to inherit strategy from its parent 
 
const std::vector< shared_ptr< pit::Entry > > & getPitEntries() const 
 
const Name & getName() const 
 
StrategyChoice(Forwarder &forwarder)
 
#define NFD_LOG_INFO(expression)
 
strategy_choice::Entry * getStrategyChoiceEntry() const 
 
InsertResult insert(const Name &prefix, const Name &strategyName)
set strategy of prefix to be strategyName 
 
represents a Measurements entry 
 
std::ostream & operator<<(std::ostream &os, const StrategyChoice::InsertResult &res)
 
#define NFD_LOG_TRACE(expression)
 
#define NFD_LOG_ERROR(expression)
 
fw::Strategy & getStrategy() const 
 
Copyright (c) 2011-2015 Regents of the University of California. 
 
NFD_ASSERT_FORWARD_ITERATOR(StrategyChoice::const_iterator)
 
size_t size() const 
Get number of components. 
 
void clearStrategyInfo()
clear all StrategyInfo items 
 
Represents an absolute name. 
 
void setDefaultStrategy(const Name &strategyName)
set the default strategy 
 
represents a Strategy Choice entry 
 
const Name & getPrefix() const 
 
std::pair< bool, Name > get(const Name &prefix) const 
get strategy Name of prefix 
 
boost::transformed_range< name_tree::GetTableEntry< Entry >, const name_tree::Range > Range
 
void setStrategy(unique_ptr< fw::Strategy > strategy)
 
contains information about an Interest toward an outgoing face 
 
PartialName getPrefix(ssize_t nComponents) const 
Extract a prefix of the name. 
 
std::string to_string(const V &v)
 
measurements::Entry * getMeasurementsEntry() const 
 
#define NFD_LOG_INIT(name)
 
a functor to get a table entry from a name tree entry 
 
static bool nteHasStrategyChoiceEntry(const name_tree::Entry &nte)
 
void setStrategyChoiceEntry(unique_ptr< strategy_choice::Entry > strategyChoiceEntry)
 
an entry in the name tree