NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
nfd::cs::Policy Class Referenceabstract

represents a CS replacement policy More...

#include <cs-policy.hpp>

Inheritance diagram for nfd::cs::Policy:
Collaboration diagram for nfd::cs::Policy:

Public Member Functions

 Policy (const std::string &policyName)
 
virtual ~Policy ()=default
 
const std::string & getName () const
 
CsgetCs () const
 gets cs More...
 
void setCs (Cs *cs)
 sets cs More...
 
size_t getLimit () const
 gets hard limit (in number of entries) More...
 
void setLimit (size_t nMaxEntries)
 sets hard limit (in number of entries) More...
 
void afterInsert (iterator i)
 invoked by CS after a new entry is inserted More...
 
void afterRefresh (iterator i)
 invoked by CS after an existing entry is refreshed by same Data More...
 
void beforeErase (iterator i)
 invoked by CS before an entry is erased due to management command More...
 
void beforeUse (iterator i)
 invoked by CS before an entry is used to match a lookup More...
 

Static Public Member Functions

template<typename P >
static void registerPolicy ()
 
static unique_ptr< Policycreate (const std::string &key)
 

Public Attributes

signal::Signal< Policy, iteratorbeforeEvict
 emits when an entry is being evicted More...
 

Protected Member Functions

virtual void doAfterInsert (iterator i)=0
 invoked after a new entry is created in CS More...
 
virtual void doAfterRefresh (iterator i)=0
 invoked after an existing entry is refreshed by same Data More...
 
virtual void doBeforeErase (iterator i)=0
 invoked before an entry is erased due to management command More...
 
virtual void doBeforeUse (iterator i)=0
 invoked before an entry is used to match a lookup More...
 
virtual void evictEntries ()=0
 evicts zero or more entries More...
 

Detailed Description

represents a CS replacement policy

Definition at line 39 of file cs-policy.hpp.

Constructor & Destructor Documentation

◆ Policy()

nfd::cs::Policy::Policy ( const std::string &  policyName)
explicit

Definition at line 50 of file cs-policy.cpp.

Referenced by registerPolicy().

◆ ~Policy()

virtual nfd::cs::Policy::~Policy ( )
virtualdefault

Referenced by registerPolicy().

Member Function Documentation

◆ registerPolicy()

template<typename P >
static void nfd::cs::Policy::registerPolicy ( )
inlinestatic

Definition at line 44 of file cs-policy.hpp.

References create(), getCs(), getLimit(), getName(), Policy(), setCs(), setLimit(), and ~Policy().

◆ create()

unique_ptr< Policy > nfd::cs::Policy::create ( const std::string &  key)
static
Returns
a Policy identified by key, or nullptr if key is unknown

Definition at line 43 of file cs-policy.cpp.

Referenced by nfd::cs::makeDefaultPolicy(), and registerPolicy().

◆ getName()

const std::string & nfd::cs::Policy::getName ( ) const
inline

Definition at line 188 of file cs-policy.hpp.

Referenced by registerPolicy().

◆ getCs()

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

◆ setCs()

void nfd::cs::Policy::setCs ( Cs cs)
inline

sets cs

Definition at line 200 of file cs-policy.hpp.

Referenced by registerPolicy().

◆ getLimit()

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

gets hard limit (in number of entries)

Definition at line 206 of file cs-policy.hpp.

Referenced by nfd::cs::lru::LruPolicy::LruPolicy(), registerPolicy(), and nfd::cs::priority_fifo::PriorityFifoPolicy::~PriorityFifoPolicy().

◆ setLimit()

void nfd::cs::Policy::setLimit ( size_t  nMaxEntries)

sets hard limit (in number of entries)

Postcondition
getLimit() == nMaxEntries
cs.size() <= getLimit()

The policy may evict entries if necessary.

Definition at line 56 of file cs-policy.cpp.

References evictEntries(), and NFD_LOG_INFO.

Referenced by registerPolicy().

◆ afterInsert()

void nfd::cs::Policy::afterInsert ( iterator  i)

invoked by CS after a new entry is inserted

Postcondition
cs.size() <= getLimit()

The policy may evict entries if necessary. During this process, i might be evicted.

Definition at line 64 of file cs-policy.cpp.

References doAfterInsert().

◆ afterRefresh()

void nfd::cs::Policy::afterRefresh ( iterator  i)

invoked by CS after an existing entry is refreshed by same Data

The policy may witness this refresh to make better eviction decisions in the future.

Definition at line 71 of file cs-policy.cpp.

References doAfterRefresh().

◆ beforeErase()

void nfd::cs::Policy::beforeErase ( iterator  i)

invoked by CS before an entry is erased due to management command

Warning
CS must not invoke this method if an entry is erased due to eviction.

Definition at line 78 of file cs-policy.cpp.

References doBeforeErase().

◆ beforeUse()

void nfd::cs::Policy::beforeUse ( iterator  i)

invoked by CS before an entry is used to match a lookup

The policy may witness this usage to make better eviction decisions in the future.

Definition at line 85 of file cs-policy.cpp.

References doBeforeUse().

◆ doAfterInsert()

virtual void nfd::cs::Policy::doAfterInsert ( iterator  i)
protectedpure virtual

invoked after a new entry is created in CS

When overridden in a subclass, a policy implementation should decide whether to accept i. If i is accepted, it should be inserted into a cleanup index. Otherwise, beforeEvict signal should be emitted with i to inform CS to erase the entry. A policy implementation may decide to evict other entries by emitting beforeEvict signal, in order to keep CS size under limit.

Referenced by afterInsert().

◆ doAfterRefresh()

virtual void nfd::cs::Policy::doAfterRefresh ( iterator  i)
protectedpure virtual

invoked after an existing entry is refreshed by same Data

When overridden in a subclass, a policy implementation may witness this operation and adjust its cleanup index.

Referenced by afterRefresh().

◆ doBeforeErase()

virtual void nfd::cs::Policy::doBeforeErase ( iterator  i)
protectedpure virtual

invoked before an entry is erased due to management command

Note
This will not be invoked for an entry being evicted by policy.

When overridden in a subclass, a policy implementation should erase i from its cleanup index without emitted afterErase signal.

Referenced by beforeErase().

◆ doBeforeUse()

virtual void nfd::cs::Policy::doBeforeUse ( iterator  i)
protectedpure virtual

invoked before an entry is used to match a lookup

When overridden in a subclass, a policy implementation may witness this operation and adjust its cleanup index.

Referenced by beforeUse().

◆ evictEntries()

virtual void nfd::cs::Policy::evictEntries ( )
protectedpure virtual

evicts zero or more entries

Postcondition
CS size does not exceed hard limit

Referenced by setLimit().

Member Data Documentation

◆ beforeEvict

signal::Signal<Policy, iterator> nfd::cs::Policy::beforeEvict

emits when an entry is being evicted

A policy implementation should emit this signal to cause CS to erase the entry from its index. CS should connect to this signal and erase the entry upon signal emission.

Definition at line 97 of file cs-policy.hpp.

Referenced by nfd::cs::lru::LruPolicy::LruPolicy(), and nfd::cs::priority_fifo::PriorityFifoPolicy::~PriorityFifoPolicy().


The documentation for this class was generated from the following files: