nfd::cs::Cs Class Reference

Implements the Content Store. More...

#include <daemon/table/cs.hpp>

+ Inheritance diagram for nfd::cs::Cs:
+ Collaboration diagram for nfd::cs::Cs:

Public Types

using const_iterator = Table::const_iterator
 

Public Member Functions

 Cs (size_t nMaxPackets=10)
 
const_iterator begin () const
 
void enableAdmit (bool shouldAdmit) noexcept
 Set CS_ENABLE_ADMIT flag. More...
 
void enableServe (bool shouldServe) noexcept
 Set CS_ENABLE_SERVE flag. More...
 
const_iterator end () const
 
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 getLimit () const noexcept
 Get capacity (in number of packets). More...
 
PolicygetPolicy () const noexcept
 Get replacement policy. More...
 
void insert (const Data &data, bool isUnsolicited=false)
 Inserts a Data packet. More...
 
void setLimit (size_t nMaxPackets)
 Change capacity (in number of packets). More...
 
void setPolicy (unique_ptr< Policy > policy)
 Change replacement policy. More...
 
bool shouldAdmit () const noexcept
 Get CS_ENABLE_ADMIT flag. More...
 
bool shouldServe () const noexcept
 Get CS_ENABLE_SERVE flag. More...
 
size_t size () const
 Get number of stored packets. More...
 

Detailed Description

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.

Definition at line 44 of file cs.hpp.

Member Typedef Documentation

◆ const_iterator

using nfd::cs::Cs::const_iterator = Table::const_iterator

Definition at line 161 of file cs.hpp.

Constructor & Destructor Documentation

◆ Cs()

nfd::cs::Cs::Cs ( size_t  nMaxPackets = 10)
explicit

Definition at line 42 of file cs.cpp.

Member Function Documentation

◆ begin()

const_iterator nfd::cs::Cs::begin ( ) const
inline

Definition at line 164 of file cs.hpp.

◆ enableAdmit()

void nfd::cs::Cs::enableAdmit ( bool  shouldAdmit)
noexcept

Set CS_ENABLE_ADMIT flag.

See also
https://redmine.named-data.net/projects/nfd/wiki/CsMgmt#Update-config

Definition at line 160 of file cs.cpp.

◆ enableServe()

void nfd::cs::Cs::enableServe ( bool  shouldServe)
noexcept

Set CS_ENABLE_SERVE flag.

See also
https://redmine.named-data.net/projects/nfd/wiki/CsMgmt#Update-config

Definition at line 170 of file cs.cpp.

◆ end()

const_iterator nfd::cs::Cs::end ( ) const
inline

Definition at line 170 of file cs.hpp.

◆ erase()

template<typename AfterEraseCallback >
void nfd::cs::Cs::erase ( const Name &  prefix,
size_t  limit,
AfterEraseCallback &&  cb 
)
inline

Asynchronously erases entries under prefix.

Template Parameters
AfterEraseCallbackvoid f(size_t nErased)
Parameters
prefixname prefix of entries
limitmax number of entries to erase
cbcallback 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.

◆ find()

template<typename HitCallback , typename MissCallback >
void nfd::cs::Cs::find ( const Interest &  interest,
HitCallback &&  hit,
MissCallback &&  miss 
) const
inline

Finds the best matching Data packet.

Template Parameters
HitCallbackvoid f(const Interest&, const Data&)
MissCallbackvoid f(const Interest&)
Parameters
interestthe Interest for lookup
hita callback if a match is found; must not be empty
missa callback if there's no match; must not be empty
Note
A lookup invokes either callback exactly once. The callback may be invoked either before or after find() returns

Definition at line 81 of file cs.hpp.

◆ getLimit()

size_t nfd::cs::Cs::getLimit ( ) const
inlinenoexcept

Get capacity (in number of packets).

Definition at line 103 of file cs.hpp.

◆ getPolicy()

Policy* nfd::cs::Cs::getPolicy ( ) const
inlinenoexcept

Get replacement policy.

Definition at line 119 of file cs.hpp.

◆ insert()

void nfd::cs::Cs::insert ( const Data &  data,
bool  isUnsolicited = false 
)

Inserts a Data packet.

Definition at line 49 of file cs.cpp.

◆ setLimit()

void nfd::cs::Cs::setLimit ( size_t  nMaxPackets)
inline

Change capacity (in number of packets).

Definition at line 111 of file cs.hpp.

◆ setPolicy()

void nfd::cs::Cs::setPolicy ( unique_ptr< Policy policy)

Change replacement policy.

Precondition
size() == 0

Definition at line 139 of file cs.cpp.

◆ shouldAdmit()

bool nfd::cs::Cs::shouldAdmit ( ) const
inlinenoexcept

Get CS_ENABLE_ADMIT flag.

See also
https://redmine.named-data.net/projects/nfd/wiki/CsMgmt#Update-config

Definition at line 134 of file cs.hpp.

◆ shouldServe()

bool nfd::cs::Cs::shouldServe ( ) const
inlinenoexcept

Get CS_ENABLE_SERVE flag.

See also
https://redmine.named-data.net/projects/nfd/wiki/CsMgmt#Update-config

Definition at line 149 of file cs.hpp.

◆ size()

size_t nfd::cs::Cs::size ( ) const
inline

Get number of stored packets.

Definition at line 94 of file cs.hpp.