26 #ifndef NFD_DAEMON_TABLE_CS_POLICY_HPP
27 #define NFD_DAEMON_TABLE_CS_POLICY_HPP
45 Registry& registry = getRegistry();
46 BOOST_ASSERT(registry.count(policyName) == 0);
47 registry[policyName] = [] {
return make_unique<P>(); };
53 static unique_ptr<Policy>
54 create(
const std::string& policyName);
58 static std::set<std::string>
63 Policy(
const std::string& policyName);
196 using CreateFunc = std::function<unique_ptr<Policy>()>;
197 using Registry = std::map<std::string, CreateFunc>;
203 std::string m_policyName;
214 #define NFD_REGISTER_CS_POLICY(P) \
215 static class NfdAuto ## P ## CsPolicyRegistrationClass \
218 NfdAuto ## P ## CsPolicyRegistrationClass() \
220 ::nfd::cs::Policy::registerPolicy<P>(); \
222 } g_nfdAuto ## P ## CsPolicyRegistrationVariable
implements the Content Store
represents a CS replacement policy
static void registerPolicy(const std::string &policyName=P::POLICY_NAME)
virtual void doAfterInsert(EntryRef i)=0
invoked after a new entry is created in CS
virtual void doAfterRefresh(EntryRef i)=0
invoked after an existing entry is refreshed by same Data
Policy(const std::string &policyName)
void setLimit(size_t nMaxEntries)
sets hard limit (in number of entries)
void beforeUse(EntryRef i)
invoked by CS before an entry is used to match a lookup
void afterInsert(EntryRef i)
invoked by CS after a new entry is inserted
Cs * getCs() const
gets cs
static std::set< std::string > getPolicyNames()
static unique_ptr< Policy > create(const std::string &policyName)
virtual void evictEntries()=0
evicts zero or more entries
void setCs(Cs *cs)
sets cs
virtual void doBeforeErase(EntryRef i)=0
invoked before an entry is erased due to management command
size_t getLimit() const
gets hard limit (in number of entries)
virtual ~Policy()=default
virtual void doBeforeUse(EntryRef i)=0
invoked before an entry is used to match a lookup
void beforeErase(EntryRef i)
invoked by CS before an entry is erased due to management command
const std::string & getName() const
Table::const_iterator EntryRef
a reference to an CS entry
signal::Signal< Policy, EntryRef > beforeEvict
emits when an entry is being evicted
void afterRefresh(EntryRef i)
invoked by CS after an existing entry is refreshed by same Data
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents,...