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);
193 DECLARE_SIGNAL_EMIT(beforeEvict)
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 224 #endif // NFD_DAEMON_TABLE_CS_POLICY_HPP virtual void doAfterInsert(EntryRef i)=0
invoked after a new entry is created in CS
virtual ~Policy()=default
void afterRefresh(EntryRef i)
invoked by CS after an existing entry is refreshed by same Data
void afterInsert(EntryRef i)
invoked by CS after a new entry is inserted
static void registerPolicy(const std::string &policyName=P::POLICY_NAME)
static unique_ptr< Policy > create(const std::string &policyName)
implements the Content Store
void setCs(Cs *cs)
sets cs
virtual void doBeforeErase(EntryRef i)=0
invoked before an entry is erased due to management command
void beforeErase(EntryRef i)
invoked by CS before an entry is erased due to management command
const std::string & getName() const
virtual void evictEntries()=0
evicts zero or more entries
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
size_t getLimit() const
gets hard limit (in number of entries)
void beforeUse(EntryRef i)
invoked by CS before an entry is used to match a lookup
static std::set< std::string > getPolicyNames()
represents a CS replacement policy
Table::const_iterator EntryRef
a reference to an CS entry
Cs * getCs() const
gets cs
void setLimit(size_t nMaxEntries)
sets hard limit (in number of entries)
signal::Signal< Policy, EntryRef > beforeEvict
emits when an entry is being evicted
virtual void doAfterRefresh(EntryRef i)=0
invoked after an existing entry is refreshed by same Data
Policy(const std::string &policyName)
virtual void doBeforeUse(EntryRef i)=0
invoked before an entry is used to match a lookup