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:

Classes

struct  EntryFromEntryImpl
 

Public Types

using AfterEraseCallback = std::function< void(size_t nErased)>
 
typedef boost::transform_iterator< EntryFromEntryImpl, iterator, const Entry & > const_iterator
 ContentStore iterator (public API) More...
 
using HitCallback = std::function< void(const Interest &, const Data &)>
 
using MissCallback = std::function< void(const Interest &)>
 

Public Member Functions

 Cs (size_t nMaxPackets=10)
 
const_iterator begin () const
 
void enableAdmit (bool shouldAdmit)
 set CS_ENABLE_ADMIT flag More...
 
void enableServe (bool shouldServe)
 set CS_ENABLE_SERVE flag More...
 
const_iterator end () const
 
void erase (const Name &prefix, size_t limit, const AfterEraseCallback &cb)
 asynchronously erases entries under prefix More...
 
void find (const Interest &interest, const HitCallback &hitCallback, const MissCallback &missCallback) const
 finds the best matching Data packet More...
 
size_t getLimit () const
 get capacity (in number of packets) More...
 
PolicygetPolicy () const
 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
 get CS_ENABLE_ADMIT flag More...
 
bool shouldServe () const
 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 48 of file cs.hpp.

Member Typedef Documentation

using nfd::cs::Cs::AfterEraseCallback = std::function<void(size_t nErased)>

Definition at line 59 of file cs.hpp.

typedef boost::transform_iterator<EntryFromEntryImpl, iterator, const Entry&> nfd::cs::Cs::const_iterator

ContentStore iterator (public API)

Definition at line 168 of file cs.hpp.

using nfd::cs::Cs::HitCallback = std::function<void(const Interest&, const Data&)>

Definition at line 70 of file cs.hpp.

using nfd::cs::Cs::MissCallback = std::function<void(const Interest&)>

Definition at line 71 of file cs.hpp.

Constructor & Destructor Documentation

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

Definition at line 46 of file cs.cpp.

Member Function Documentation

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

Definition at line 171 of file cs.hpp.

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

set CS_ENABLE_ADMIT flag

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

Definition at line 231 of file cs.cpp.

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

set CS_ENABLE_SERVE flag

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

Definition at line 241 of file cs.cpp.

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

Definition at line 177 of file cs.hpp.

void nfd::cs::Cs::erase ( const Name &  prefix,
size_t  limit,
const AfterEraseCallback cb 
)

asynchronously erases entries under prefix

Parameters
prefixname prefix of entries
limitmax number of entries to erase
cbcallback to receive the actual number of erased entries; it may be empty; it may be invoked either before or after erase() returns

Definition at line 92 of file cs.cpp.

void nfd::cs::Cs::find ( const Interest &  interest,
const HitCallback hitCallback,
const MissCallback missCallback 
) const

finds the best matching Data packet

Parameters
interestthe Interest for lookup
hitCallbacka callback if a match is found; must not be empty
missCallbacka 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 115 of file cs.cpp.

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

get capacity (in number of packets)

Definition at line 97 of file cs.hpp.

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

get replacement policy

Definition at line 113 of file cs.hpp.

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

inserts a Data packet

Definition at line 55 of file cs.cpp.

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

change capacity (in number of packets)

Definition at line 105 of file cs.hpp.

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

change replacement policy

Precondition
size() == 0

Definition at line 208 of file cs.cpp.

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

get CS_ENABLE_ADMIT flag

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

Definition at line 128 of file cs.hpp.

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

get CS_ENABLE_SERVE flag

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

Definition at line 143 of file cs.hpp.

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

get number of stored packets

Definition at line 88 of file cs.hpp.