From f26d1ae36e5cb2f7da982f1ba70e1d297a412d54 Mon Sep 17 00:00:00 2001 From: "Klaus (Laptop)" Date: Mon, 25 May 2015 02:03:33 +0200 Subject: [PATCH] Added strategy parameters and the BroadcastNewNonceStrategy as simple example how to use them. --- .gitignore | 4 +- NFD/daemon/fw/available-strategies.cpp | 19 +-- NFD/daemon/fw/broadcast-newnonce-strategy.cpp | 84 ++++++++++ NFD/daemon/fw/broadcast-newnonce-strategy.hpp | 38 +++++ NFD/daemon/fw/strategy-helper.cpp | 39 +++++ NFD/daemon/fw/strategy-helper.hpp | 20 +++ NFD/daemon/table/strategy-choice-entry.cpp | 9 +- NFD/daemon/table/strategy-choice-entry.hpp | 26 ++- NFD/daemon/table/strategy-choice.cpp | 157 ++++++++++-------- NFD/daemon/table/strategy-choice.hpp | 55 +++--- 10 files changed, 330 insertions(+), 121 deletions(-) create mode 100644 NFD/daemon/fw/broadcast-newnonce-strategy.cpp create mode 100644 NFD/daemon/fw/broadcast-newnonce-strategy.hpp create mode 100644 NFD/daemon/fw/strategy-helper.cpp create mode 100644 NFD/daemon/fw/strategy-helper.hpp diff --git a/.gitignore b/.gitignore index 8cc655a65..4a313cbc0 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ *~ .DS_Store docs/doxygen.warnings.log - +test.cc +.*project +helper diff --git a/NFD/daemon/fw/available-strategies.cpp b/NFD/daemon/fw/available-strategies.cpp index 45be270a6..d907b4ee2 100644 --- a/NFD/daemon/fw/available-strategies.cpp +++ b/NFD/daemon/fw/available-strategies.cpp @@ -28,35 +28,34 @@ #include "client-control-strategy.hpp" #include "ncc-strategy.hpp" #include "best-route-strategy2.hpp" +#include "broadcast-newnonce-strategy.hpp" namespace nfd { namespace fw { -shared_ptr -makeDefaultStrategy(Forwarder& forwarder) +shared_ptr makeDefaultStrategy(Forwarder& forwarder) { - return make_shared(ref(forwarder)); + return make_shared < BestRouteStrategy2 > (ref(forwarder)); } template -inline void -installStrategy(Forwarder& forwarder) +inline void installStrategy(Forwarder& forwarder) { StrategyChoice& strategyChoice = forwarder.getStrategyChoice(); if (!strategyChoice.hasStrategy(S::STRATEGY_NAME)) { - strategyChoice.install(make_shared(ref(forwarder))); + strategyChoice.install(make_shared < S > (ref(forwarder))); } } -void -installStrategies(Forwarder& forwarder) +void installStrategies(Forwarder& forwarder) { installStrategy(forwarder); installStrategy(forwarder); installStrategy(forwarder); installStrategy(forwarder); installStrategy(forwarder); + installStrategy(forwarder); } -} // namespace fw -} // namespace nfd +} // namespace fw +} // namespace nfd diff --git a/NFD/daemon/fw/broadcast-newnonce-strategy.cpp b/NFD/daemon/fw/broadcast-newnonce-strategy.cpp new file mode 100644 index 000000000..50673f717 --- /dev/null +++ b/NFD/daemon/fw/broadcast-newnonce-strategy.cpp @@ -0,0 +1,84 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/** + * Copyright (c) 2014, Regents of the University of California, + * Arizona Board of Regents, + * Colorado State University, + * University Pierre & Marie Curie, Sorbonne University, + * Washington University in St. Louis, + * Beijing Institute of Technology, + * The University of Memphis + * + * This file is part of NFD (Named Data Networking Forwarding Daemon). + * See AUTHORS.md for complete list of NFD authors and contributors. + * + * NFD is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Foundation, + * either version 3 of the License, or (at your option) any later version. + * + * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * NFD, e.g., in COPYING.md file. If not, see . + */ + +#include "broadcast-newnonce-strategy.hpp" +#include "strategy-helper.hpp" +#include +#include "core/logger.hpp" + +namespace nfd { +namespace fw { + +NFD_LOG_INIT("BroadcastNewNonceStrategy"); + +const Name BroadcastNewNonceStrategy::STRATEGY_NAME( + "ndn:/localhost/nfd/strategy/broadcast-newnonce/%FD%01"); + +BroadcastNewNonceStrategy::BroadcastNewNonceStrategy(Forwarder& forwarder, const Name& name) : + Strategy(forwarder, name), ownStrategyChoice(forwarder.getStrategyChoice()) +{ + NFD_LOG_INFO("BroadcastNewNonceStrategy initialized!"); +} + +BroadcastNewNonceStrategy::~BroadcastNewNonceStrategy() +{ +} + +void BroadcastNewNonceStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest, + shared_ptr fibEntry, shared_ptr pitEntry) +{ + + bool useNonce = true; + // Getting nonce value from parameters; + std::string parameterString = ownStrategyChoice.findEffectiveParameters( + interest.getName().toUri()); + std::map < std::string, std::string > parameterMap = StrategyHelper::getParameterMap( + parameterString); + + std::map::const_iterator it = parameterMap.find("nonce"); + if (it != parameterMap.end()) { + if (it->second == "false") { + useNonce = false; + } + } + + const fib::NextHopList& nexthops = fibEntry->getNextHops(); + + for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) { + shared_ptr < Face > outFace = it->getFace(); + if (pitEntry->canForwardTo(*outFace)) { + NFD_LOG_TRACE("New Nonce? " << useNonce); + // If nonce == true, change interest nonce for each new packet + this->sendInterest(pitEntry, outFace, useNonce); + } + } + + if (!pitEntry->hasUnexpiredOutRecords()) { + this->rejectPendingInterest(pitEntry); + } +} + +} // namespace fw +} // namespace nfd diff --git a/NFD/daemon/fw/broadcast-newnonce-strategy.hpp b/NFD/daemon/fw/broadcast-newnonce-strategy.hpp new file mode 100644 index 000000000..97070094c --- /dev/null +++ b/NFD/daemon/fw/broadcast-newnonce-strategy.hpp @@ -0,0 +1,38 @@ +#ifndef NFD_DAEMON_FW_OWNSTRATEGY_HPP +#define NFD_DAEMON_FW_OWNSTRATEGY_HPP + +#include "strategy.hpp" + +namespace nfd { +namespace fw { + +/** \class BroadcastNewNonceStrategy + * \brief Forwards interests to all nexthops using a new nonce. + * + * The parameter "nonce" denotes if a new nonce should be used (nonce=true) or not (nonce=false). + * The default is to use a new nonce. + */ +class BroadcastNewNonceStrategy : public Strategy +{ +public: + BroadcastNewNonceStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME); + + virtual + ~BroadcastNewNonceStrategy(); + + virtual void + afterReceiveInterest(const Face& inFace, const Interest& interest, + shared_ptr fibEntry, shared_ptr pitEntry) + DECL_OVERRIDE; + +public: + static const Name STRATEGY_NAME; + +private: + StrategyChoice& ownStrategyChoice; +}; + +} // namespace fw +} // namespace nfd + +#endif diff --git a/NFD/daemon/fw/strategy-helper.cpp b/NFD/daemon/fw/strategy-helper.cpp new file mode 100644 index 000000000..888098e55 --- /dev/null +++ b/NFD/daemon/fw/strategy-helper.cpp @@ -0,0 +1,39 @@ +#include "strategy-helper.hpp" +#include "core/logger.hpp" +#include +#include +#include +#include + +namespace nfd { +namespace fw { + +NFD_LOG_INIT("StrategyHelper"); + +std::map StrategyHelper::getParameterMap(std::string parameters) +{ + NFD_LOG_INFO("Parsing parameters!"); + + std::map < std::string, std::string > outputMap; + +// Replace ASCII elements + boost::replace_all(parameters, "%2C", ","); + boost::replace_all(parameters, "%3D", "="); + + std::vector < std::string > paramVector; + boost::split(paramVector, parameters, boost::is_any_of(",")); + + for (auto substring : paramVector) { + std::vector < std::string > substringVector; + boost::split(substringVector, substring, boost::is_any_of("=")); + + std::string key = substringVector.front(); + std::string value = substringVector.back(); + outputMap[substringVector.front()] = substringVector.back(); + } + + return outputMap; +} + +} // namespace nfd +} // namespace fw diff --git a/NFD/daemon/fw/strategy-helper.hpp b/NFD/daemon/fw/strategy-helper.hpp new file mode 100644 index 000000000..5446c3955 --- /dev/null +++ b/NFD/daemon/fw/strategy-helper.hpp @@ -0,0 +1,20 @@ +#ifndef NFD_DAEMON_FW_STRATEGY_HELPER_HPP +#define NFD_DAEMON_FW_STRATEGY_HELPER_HPP + +#include +#include + +namespace nfd { +namespace fw { + +class StrategyHelper +{ + +public: + static std::map getParameterMap(std::string parameters); +}; + +} // namespace fw +} // namespace nfd + +#endif diff --git a/NFD/daemon/table/strategy-choice-entry.cpp b/NFD/daemon/table/strategy-choice-entry.cpp index 2b7a2579b..46e815cd5 100644 --- a/NFD/daemon/table/strategy-choice-entry.cpp +++ b/NFD/daemon/table/strategy-choice-entry.cpp @@ -30,9 +30,8 @@ namespace nfd { namespace strategy_choice { -Entry::Entry(const Name& prefix) - : m_prefix(prefix) - , m_strategy(nullptr) +Entry::Entry(const Name& prefix) : + m_prefix(prefix), m_strategy(nullptr) { } @@ -42,5 +41,5 @@ Entry::getStrategyName() const return m_strategy->getName(); } -} // namespace strategy_choice -} // namespace nfd +} // namespace strategy_choice +} // namespace nfd diff --git a/NFD/daemon/table/strategy-choice-entry.hpp b/NFD/daemon/table/strategy-choice-entry.hpp index 857a3132b..daee02c89 100644 --- a/NFD/daemon/table/strategy-choice-entry.hpp +++ b/NFD/daemon/table/strategy-choice-entry.hpp @@ -59,16 +59,22 @@ class Entry : noncopyable void setStrategy(fw::Strategy& strategy); + std::string + getParameters() const; + + void + setParameters(std::string parameters); + private: Name m_prefix; fw::Strategy* m_strategy; + std::string m_parameters; shared_ptr m_nameTreeEntry; friend class nfd::NameTree; friend class nfd::name_tree::Entry; }; - inline const Name& Entry::getPrefix() const { @@ -82,13 +88,23 @@ Entry::getStrategy() const return *m_strategy; } -inline void -Entry::setStrategy(fw::Strategy& strategy) +inline void Entry::setStrategy(fw::Strategy& strategy) { m_strategy = &strategy; } -} // namespace strategy_choice -} // namespace nfd +inline std::string Entry::getParameters() const +{ +// BOOST_ASSERT(m_parameters.size() != 0); + return m_parameters; +} + +inline void Entry::setParameters(std::string parameters) +{ + m_parameters = parameters; +} + +} // namespace strategy_choice +} // namespace nfd #endif // NFD_DAEMON_TABLE_STRATEGY_CHOICE_ENTRY_HPP diff --git a/NFD/daemon/table/strategy-choice.cpp b/NFD/daemon/table/strategy-choice.cpp index 85aade610..cc50bcd3a 100644 --- a/NFD/daemon/table/strategy-choice.cpp +++ b/NFD/daemon/table/strategy-choice.cpp @@ -36,16 +36,15 @@ using fw::Strategy; NFD_LOG_INIT("StrategyChoice"); -StrategyChoice::StrategyChoice(NameTree& nameTree, shared_ptr defaultStrategy) - : m_nameTree(nameTree) - , m_nItems(0) +StrategyChoice::StrategyChoice(NameTree& nameTree, shared_ptr defaultStrategy) : + m_nameTree(nameTree), m_nItems(0) { this->setDefaultStrategy(defaultStrategy); } -bool -StrategyChoice::hasStrategy(const Name& strategyName, bool isExact) const +bool StrategyChoice::hasStrategy(const Name& strategyName, bool isExact) const { + NFD_LOG_INFO("Has strategy: " << strategyName.toUri()); if (isExact) { return m_strategyInstances.count(strategyName) > 0; } @@ -54,9 +53,9 @@ StrategyChoice::hasStrategy(const Name& strategyName, bool isExact) const } } -bool -StrategyChoice::install(shared_ptr strategy) +bool StrategyChoice::install(shared_ptr strategy) { + NFD_LOG_INFO("Install strategy: " << strategy->getName().toUri()); BOOST_ASSERT(static_cast(strategy)); const Name& strategyName = strategy->getName(); @@ -73,30 +72,34 @@ fw::Strategy* StrategyChoice::getStrategy(const Name& strategyName) const { fw::Strategy* candidate = nullptr; - for (auto it = m_strategyInstances.lower_bound(strategyName); - it != m_strategyInstances.end() && strategyName.isPrefixOf(it->first); ++it) { - switch (it->first.size() - strategyName.size()) { - case 0: // exact match - return it->second.get(); - case 1: // unversioned strategyName matches versioned strategy - candidate = it->second.get(); - break; + for (auto n : m_strategyInstances) { + // Include longer strategy names (with parameters) + if (strategyName.isPrefixOf(n.first) || n.first.isPrefixOf(strategyName)) { + switch (n.first.size() + 1 - strategyName.size()) { + case 0: // Strategy with parameters (one element longer than exact match) + return n.second.get(); + case 1: // exact match + return n.second.get(); + case 2: // unversioned strategy name (one element shorter) + candidate = n.second.get(); + break; + } } } return candidate; } -bool -StrategyChoice::insert(const Name& prefix, const Name& strategyName) +bool StrategyChoice::insert(const Name& prefix, const Name& strategyName) { + NFD_LOG_INFO("Insert strategy : " << strategyName << " to " << prefix); Strategy* strategy = this->getStrategy(strategyName); if (strategy == nullptr) { NFD_LOG_ERROR("insert(" << prefix << "," << strategyName << ") strategy not installed"); return false; } - shared_ptr nte = m_nameTree.lookup(prefix); - shared_ptr entry = nte->getStrategyChoiceEntry(); + shared_ptr < name_tree::Entry > nte = m_nameTree.lookup(prefix); + shared_ptr < Entry > entry = nte->getStrategyChoiceEntry(); Strategy* oldStrategy = nullptr; if (static_cast(entry)) { if (entry->getStrategy().getName() == strategy->getName()) { @@ -104,34 +107,41 @@ StrategyChoice::insert(const Name& prefix, const Name& strategyName) return true; } oldStrategy = &entry->getStrategy(); - NFD_LOG_TRACE("insert(" << prefix << ") changing from " << oldStrategy->getName() << - " to " << strategy->getName()); + NFD_LOG_TRACE( + "insert(" << prefix << ") changing from " << oldStrategy->getName() << " to " + << strategy->getName()); } if (!static_cast(entry)) { oldStrategy = &this->findEffectiveStrategy(prefix); - entry = make_shared(prefix); + entry = make_shared < Entry > (prefix); nte->setStrategyChoiceEntry(entry); ++m_nItems; NFD_LOG_TRACE("insert(" << prefix << ") new entry " << strategy->getName()); } this->changeStrategy(*entry, *oldStrategy, *strategy); + + // Also set strategy parameters + std::string strName = strategyName.toUri(); + std::vector < std::string > strVector; + boost::split(strVector, strName, boost::is_any_of("/")); entry->setStrategy(*strategy); + // Use last element after "/" as parameter string + entry->setParameters(strVector.back()); return true; } -void -StrategyChoice::erase(const Name& prefix) +void StrategyChoice::erase(const Name& prefix) { BOOST_ASSERT(prefix.size() > 0); - shared_ptr nte = m_nameTree.findExactMatch(prefix); + shared_ptr < name_tree::Entry > nte = m_nameTree.findExactMatch(prefix); if (!static_cast(nte)) { return; } - shared_ptr entry = nte->getStrategyChoiceEntry(); + shared_ptr < Entry > entry = nte->getStrategyChoiceEntry(); if (!static_cast(entry)) { return; } @@ -146,45 +156,54 @@ StrategyChoice::erase(const Name& prefix) --m_nItems; } -std::pair -StrategyChoice::get(const Name& prefix) const +std::pair StrategyChoice::get(const Name& prefix) const { - shared_ptr nte = m_nameTree.findExactMatch(prefix); + shared_ptr < name_tree::Entry > nte = m_nameTree.findExactMatch(prefix); if (!static_cast(nte)) { - return { false, Name() }; + return {false, Name()}; } - shared_ptr entry = nte->getStrategyChoiceEntry(); + shared_ptr < Entry > entry = nte->getStrategyChoiceEntry(); if (!static_cast(entry)) { - return { false, Name() }; + return {false, Name()}; } - return { true, entry->getStrategy().getName() }; + return {true, entry->getStrategy().getName()}; } Strategy& StrategyChoice::findEffectiveStrategy(const Name& prefix) const { - shared_ptr nte = m_nameTree.findLongestPrefixMatch(prefix, - [] (const name_tree::Entry& entry) { - return static_cast(entry.getStrategyChoiceEntry()); - }); + shared_ptr < name_tree::Entry > nte = m_nameTree.findLongestPrefixMatch(prefix, + [] (const name_tree::Entry& entry) { + return static_cast(entry.getStrategyChoiceEntry()); + }); BOOST_ASSERT(static_cast(nte)); return nte->getStrategyChoiceEntry()->getStrategy(); } +std::string StrategyChoice::findEffectiveParameters(const Name& prefix) const +{ + shared_ptr < name_tree::Entry > nte = m_nameTree.findLongestPrefixMatch(prefix, + [] (const name_tree::Entry& entry) { + return static_cast(entry.getStrategyChoiceEntry()); + }); + + BOOST_ASSERT(static_cast(nte)); + return nte->getStrategyChoiceEntry()->getParameters(); +} + Strategy& StrategyChoice::findEffectiveStrategy(shared_ptr nte) const { - shared_ptr entry = nte->getStrategyChoiceEntry(); + shared_ptr < strategy_choice::Entry > entry = nte->getStrategyChoiceEntry(); if (static_cast(entry)) return entry->getStrategy(); - nte = m_nameTree.findLongestPrefixMatch(nte, - [] (const name_tree::Entry& entry) { - return static_cast(entry.getStrategyChoiceEntry()); - }); + nte = m_nameTree.findLongestPrefixMatch(nte, [] (const name_tree::Entry& entry) { + return static_cast(entry.getStrategyChoiceEntry()); + }); BOOST_ASSERT(static_cast(nte)); return nte->getStrategyChoiceEntry()->getStrategy(); @@ -193,7 +212,7 @@ StrategyChoice::findEffectiveStrategy(shared_ptr nte) const Strategy& StrategyChoice::findEffectiveStrategy(const pit::Entry& pitEntry) const { - shared_ptr nte = m_nameTree.get(pitEntry); + shared_ptr < name_tree::Entry > nte = m_nameTree.get(pitEntry); BOOST_ASSERT(static_cast(nte)); return this->findEffectiveStrategy(nte); @@ -202,21 +221,20 @@ StrategyChoice::findEffectiveStrategy(const pit::Entry& pitEntry) const Strategy& StrategyChoice::findEffectiveStrategy(const measurements::Entry& measurementsEntry) const { - shared_ptr nte = m_nameTree.get(measurementsEntry); + shared_ptr < name_tree::Entry > nte = m_nameTree.get(measurementsEntry); BOOST_ASSERT(static_cast(nte)); return this->findEffectiveStrategy(nte); } -void -StrategyChoice::setDefaultStrategy(shared_ptr strategy) +void StrategyChoice::setDefaultStrategy(shared_ptr strategy) { this->install(strategy); // don't use .insert here, because it will invoke findEffectiveStrategy // which expects an existing root entry - shared_ptr nte = m_nameTree.lookup(Name()); - shared_ptr entry = make_shared(Name()); + shared_ptr < name_tree::Entry > nte = m_nameTree.lookup(Name()); + shared_ptr < Entry > entry = make_shared < Entry > (Name()); nte->setStrategyChoiceEntry(entry); ++m_nItems; NFD_LOG_INFO("setDefaultStrategy " << strategy->getName()); @@ -224,8 +242,7 @@ StrategyChoice::setDefaultStrategy(shared_ptr strategy) entry->setStrategy(*strategy); } -static inline void -clearStrategyInfo(const name_tree::Entry& nte) +static inline void clearStrategyInfo(const name_tree::Entry& nte) { NFD_LOG_TRACE("clearStrategyInfo " << nte.getPrefix()); @@ -243,45 +260,41 @@ clearStrategyInfo(const name_tree::Entry& nte) } } -void -StrategyChoice::changeStrategy(strategy_choice::Entry& entry, - fw::Strategy& oldStrategy, - fw::Strategy& newStrategy) +void StrategyChoice::changeStrategy(strategy_choice::Entry& entry, fw::Strategy& oldStrategy, + fw::Strategy& newStrategy) { if (&oldStrategy == &newStrategy) { return; } - NFD_LOG_INFO("changeStrategy(" << entry.getPrefix() << ")" - << " from " << oldStrategy.getName() - << " to " << newStrategy.getName()); + NFD_LOG_INFO( + "changeStrategy(" << entry.getPrefix() << ")" << " from " << oldStrategy.getName() << " to " + << newStrategy.getName()); // reset StrategyInfo on a portion of NameTree, // where entry's effective strategy is covered by the changing StrategyChoice entry const name_tree::Entry* rootNte = m_nameTree.get(entry).get(); auto&& ntChanged = m_nameTree.partialEnumerate(entry.getPrefix(), - [&rootNte] (const name_tree::Entry& nte) -> std::pair { - if (&nte == rootNte) { + [&rootNte] (const name_tree::Entry& nte) -> std::pair { + if (&nte == rootNte) { + return {true, true}; + } + if (static_cast(nte.getStrategyChoiceEntry())) { + return {false, false}; + } return {true, true}; - } - if (static_cast(nte.getStrategyChoiceEntry())) { - return {false, false}; - } - return {true, true}; - }); + }); for (const name_tree::Entry& nte : ntChanged) { clearStrategyInfo(nte); } } -StrategyChoice::const_iterator -StrategyChoice::begin() const +StrategyChoice::const_iterator StrategyChoice::begin() const { - auto&& enumerable = m_nameTree.fullEnumerate( - [] (const name_tree::Entry& entry) { - return static_cast(entry.getStrategyChoiceEntry()); - }); + auto&& enumerable = m_nameTree.fullEnumerate([] (const name_tree::Entry& entry) { + return static_cast(entry.getStrategyChoiceEntry()); + }); return const_iterator(enumerable.begin()); } -} // namespace nfd +} // namespace nfd diff --git a/NFD/daemon/table/strategy-choice.hpp b/NFD/daemon/table/strategy-choice.hpp index fdff3ab5f..395e247ea 100644 --- a/NFD/daemon/table/strategy-choice.hpp +++ b/NFD/daemon/table/strategy-choice.hpp @@ -47,7 +47,8 @@ class StrategyChoice : noncopyable public: StrategyChoice(NameTree& nameTree, shared_ptr defaultStrategy); -public: // available Strategy types +public: + // available Strategy types /** \brief determines if a strategy is installed * \param isExact true to require exact match, false to permit unversioned strategyName * \return true if strategy is installed @@ -62,7 +63,8 @@ class StrategyChoice : noncopyable bool install(shared_ptr strategy); -public: // Strategy Choice table +public: + // Strategy Choice table /** \brief set strategy of prefix to be strategyName * \param strategyName the strategy to be used * \return true on success @@ -88,7 +90,8 @@ class StrategyChoice : noncopyable std::pair get(const Name& prefix) const; -public: // effective strategy +public: + // effective strategy /// get effective strategy for prefix fw::Strategy& findEffectiveStrategy(const Name& prefix) const; @@ -101,9 +104,13 @@ class StrategyChoice : noncopyable fw::Strategy& findEffectiveStrategy(const measurements::Entry& measurementsEntry) const; -public: // enumeration - class const_iterator - : public std::iterator + // find effective strategy parameters for prefix + std::string findEffectiveParameters(const Name& prefix) const; + +public: + // enumeration + class const_iterator : public std::iterator { public: explicit @@ -154,9 +161,8 @@ class StrategyChoice : noncopyable setDefaultStrategy(shared_ptr strategy); void - changeStrategy(strategy_choice::Entry& entry, - fw::Strategy& oldStrategy, - fw::Strategy& newStrategy); + changeStrategy(strategy_choice::Entry& entry, fw::Strategy& oldStrategy, + fw::Strategy& newStrategy); fw::Strategy& findEffectiveStrategy(shared_ptr nte) const; @@ -169,32 +175,26 @@ class StrategyChoice : noncopyable StrategyInstanceTable m_strategyInstances; }; -inline size_t -StrategyChoice::size() const +inline size_t StrategyChoice::size() const { return m_nItems; } -inline StrategyChoice::const_iterator -StrategyChoice::end() const +inline StrategyChoice::const_iterator StrategyChoice::end() const { return const_iterator(m_nameTree.end()); } -inline -StrategyChoice::const_iterator::const_iterator(const NameTree::const_iterator& it) - : m_nameTreeIterator(it) +inline StrategyChoice::const_iterator::const_iterator(const NameTree::const_iterator& it) : + m_nameTreeIterator(it) { } -inline -StrategyChoice::const_iterator::~const_iterator() +inline StrategyChoice::const_iterator::~const_iterator() { } -inline -StrategyChoice::const_iterator -StrategyChoice::const_iterator::operator++(int) +inline StrategyChoice::const_iterator StrategyChoice::const_iterator::operator++(int) { StrategyChoice::const_iterator temp(*this); ++(*this); @@ -214,24 +214,23 @@ StrategyChoice::const_iterator::operator*() const return *(m_nameTreeIterator->getStrategyChoiceEntry()); } -inline shared_ptr -StrategyChoice::const_iterator::operator->() const +inline shared_ptr StrategyChoice::const_iterator::operator->() const { return m_nameTreeIterator->getStrategyChoiceEntry(); } -inline bool -StrategyChoice::const_iterator::operator==(const StrategyChoice::const_iterator& other) const +inline bool StrategyChoice::const_iterator::operator==( + const StrategyChoice::const_iterator& other) const { return m_nameTreeIterator == other.m_nameTreeIterator; } -inline bool -StrategyChoice::const_iterator::operator!=(const StrategyChoice::const_iterator& other) const +inline bool StrategyChoice::const_iterator::operator!=( + const StrategyChoice::const_iterator& other) const { return m_nameTreeIterator != other.m_nameTreeIterator; } -} // namespace nfd +} // namespace nfd #endif // NFD_DAEMON_TABLE_STRATEGY_CHOICE_HPP