26 #ifndef NFD_DAEMON_TABLE_CS_POLICY_HPP
27 #define NFD_DAEMON_TABLE_CS_POLICY_HPP
46 Registry& registry = getRegistry();
47 BOOST_ASSERT(registry.count(policyName) == 0);
48 registry[policyName] = [] {
return make_unique<P>(); };
54 static unique_ptr<Policy>
55 create(
const std::string& policyName);
59 static std::set<std::string>
64 Policy(
const std::string& policyName);
177 DECLARE_SIGNAL_EMIT(beforeEvict)
180 typedef
std::function<unique_ptr<
Policy>()> CreateFunc;
181 typedef
std::map<
std::
string, CreateFunc> Registry;
187 std::
string m_policyName;
192 inline const
std::
string&
222 #define NFD_REGISTER_CS_POLICY(P) \
223 static class NfdAuto ## P ## CsPolicyRegistrationClass \
226 NfdAuto ## P ## CsPolicyRegistrationClass() \
228 ::nfd::cs::Policy::registerPolicy<P>(); \
230 } g_nfdAuto ## P ## CsPolicyRegistrationVariable
232 #endif // NFD_DAEMON_TABLE_CS_POLICY_HPP
virtual ~Policy()=default
void beforeUse(iterator i)
invoked by CS before an entry is used to match a lookup
void beforeErase(iterator i)
invoked by CS before an entry is erased due to management command
static void registerPolicy(const std::string &policyName=P::POLICY_NAME)
Cs * getCs() const
gets cs
size_t getLimit() const
gets hard limit (in number of entries)
void afterRefresh(iterator i)
invoked by CS after an existing entry is refreshed by same Data
Copyright (c) 2014-2016, Regents of the University of California, Arizona Board of Regents...
static unique_ptr< Policy > create(const std::string &policyName)
void afterInsert(iterator i)
invoked by CS after a new entry is inserted
virtual void doBeforeErase(iterator i)=0
invoked before an entry is erased due to management command
represents the ContentStore
virtual void doAfterRefresh(iterator i)=0
invoked after an existing entry is refreshed by same Data
Table::const_iterator iterator
void setCs(Cs *cs)
sets cs
virtual void evictEntries()=0
evicts zero or more entries
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
static std::set< std::string > getPolicyNames()
virtual void doAfterInsert(iterator i)=0
invoked after a new entry is created in CS
represents a CS replacement policy
signal::Signal< Policy, iterator > beforeEvict
emits when an entry is being evicted
virtual void doBeforeUse(iterator i)=0
invoked before an entry is used to match a lookup
void setLimit(size_t nMaxEntries)
sets hard limit (in number of entries)
const std::string & getName() const
Policy(const std::string &policyName)