implements the Content Store More...
#include <cs.hpp>
Public Types | |
using | const_iterator = Table::const_iterator |
Public Member Functions | |
Cs (size_t nMaxPackets=10) | |
void | insert (const Data &data, bool isUnsolicited=false) |
inserts a Data packet More... | |
template<typename AfterEraseCallback > | |
void | erase (const Name &prefix, size_t limit, AfterEraseCallback &&cb) |
asynchronously erases entries under prefix More... | |
template<typename HitCallback , typename MissCallback > | |
void | find (const Interest &interest, HitCallback &&hit, MissCallback &&miss) const |
finds the best matching Data packet More... | |
size_t | size () const |
get number of stored packets More... | |
size_t | getLimit () const |
get capacity (in number of packets) More... | |
void | setLimit (size_t nMaxPackets) |
change capacity (in number of packets) More... | |
Policy * | getPolicy () const |
get replacement policy More... | |
void | setPolicy (unique_ptr< Policy > policy) |
change replacement policy More... | |
bool | shouldAdmit () const |
get CS_ENABLE_ADMIT flag More... | |
void | enableAdmit (bool shouldAdmit) |
set CS_ENABLE_ADMIT flag More... | |
bool | shouldServe () const |
get CS_ENABLE_SERVE flag More... | |
void | enableServe (bool shouldServe) |
set CS_ENABLE_SERVE flag More... | |
const_iterator | begin () const |
const_iterator | end () const |
implements the Content Store
This Content Store implementation consists of a Table and a replacement policy.
The Table is a container ( std::set
) sorted by full Names of stored Data packets. Data packets are wrapped in Entry objects. Each Entry contains the Data packet itself, and a few additional attributes such as when the Data becomes non-fresh.
The replacement policy is implemented in a subclass of Policy
.
using nfd::cs::Cs::const_iterator = Table::const_iterator |
|
explicit |
Definition at line 44 of file cs.cpp.
References nfd::cs::makeDefaultPolicy().
void nfd::cs::Cs::insert | ( | const Data & | data, |
bool | isUnsolicited = false |
||
) |
inserts a Data packet
Definition at line 51 of file cs.cpp.
References nfd::cs::Entry::clearUnsolicited(), ndn::SimpleTag< T, TypeId >::get(), ndn::Data::getName(), ndn::Interest::getName(), ndn::Name::getSuccessor(), ndn::TagHost::getTag(), nfd::cs::Entry::isUnsolicited(), NFD_LOG_DEBUG, NFD_LOG_TRACE, ndn::Name::size(), and nfd::cs::Entry::updateFreshUntil().
Referenced by nfd::Forwarder::onDataUnsolicited(), and nfd::Forwarder::onIncomingData().
|
inline |
asynchronously erases entries under prefix
AfterEraseCallback | void f(size_t nErased) |
prefix | name prefix of entries |
limit | max number of entries to erase |
cb | callback to receive the actual number of erased entries; must not be empty; it may be invoked either before or after erase() returns |
Definition at line 64 of file cs.hpp.
Referenced by nfd::CsManager::CsManager().
|
inline |
finds the best matching Data packet
HitCallback | void f(const Interest&, const Data&) |
MissCallback | void f(const Interest&) |
interest | the Interest for lookup |
hit | a callback if a match is found; must not be empty |
miss | a callback if there's no match; must not be empty |
Definition at line 81 of file cs.hpp.
Referenced by nfd::CsManager::CsManager(), and nfd::Forwarder::Forwarder().
|
inline |
get number of stored packets
Definition at line 94 of file cs.hpp.
Referenced by nfd::CsManager::CsManager(), nfd::TablesConfigSection::ensureConfigured(), and nfd::ForwarderStatusManager::ForwarderStatusManager().
|
inline |
get capacity (in number of packets)
Definition at line 103 of file cs.hpp.
Referenced by nfd::CsManager::CsManager().
|
inline |
change capacity (in number of packets)
Definition at line 111 of file cs.hpp.
Referenced by nfd::CsManager::CsManager(), and nfd::TablesConfigSection::ensureConfigured().
|
inline |
void nfd::cs::Cs::setPolicy | ( | unique_ptr< Policy > | policy | ) |
change replacement policy
Definition at line 144 of file cs.cpp.
References nonstd::optional_lite::std11::move(), and NFD_LOG_DEBUG.
Referenced by nfd::TablesConfigSection::ensureConfigured(), and getPolicy().
|
inline |
get CS_ENABLE_ADMIT flag
Definition at line 134 of file cs.hpp.
References enableAdmit().
Referenced by nfd::CsManager::CsManager(), and enableAdmit().
void nfd::cs::Cs::enableAdmit | ( | bool | shouldAdmit | ) |
set CS_ENABLE_ADMIT flag
Definition at line 165 of file cs.cpp.
References NFD_LOG_INFO, and shouldAdmit().
Referenced by nfd::CsManager::CsManager(), and shouldAdmit().
|
inline |
get CS_ENABLE_SERVE flag
Definition at line 149 of file cs.hpp.
References enableServe().
Referenced by nfd::CsManager::CsManager(), and enableServe().
void nfd::cs::Cs::enableServe | ( | bool | shouldServe | ) |
set CS_ENABLE_SERVE flag
Definition at line 175 of file cs.cpp.
References NFD_LOG_INFO, and shouldServe().
Referenced by nfd::CsManager::CsManager(), and shouldServe().
|
inline |
|
inline |
Definition at line 170 of file cs.hpp.
References NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE.