30 #include <boost/range/adaptor/map.hpp>
31 #include <boost/range/algorithm/copy.hpp>
40 static Registry registry;
47 Registry& registry = getRegistry();
48 auto i = registry.find(policyName);
49 return i == registry.end() ? nullptr : i->second();
55 std::set<std::string> policyNames;
56 boost::copy(getRegistry() | boost::adaptors::map_keys,
57 std::inserter(policyNames, policyNames.end()));
62 : m_policyName(policyName)
70 m_limit = nMaxEntries;
77 BOOST_ASSERT(m_cs !=
nullptr);
84 BOOST_ASSERT(m_cs !=
nullptr);
91 BOOST_ASSERT(m_cs !=
nullptr);
98 BOOST_ASSERT(m_cs !=
nullptr);
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.
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.
static std::set< std::string > getPolicyNames()
Returns a list of available policy names.
static unique_ptr< Policy > create(const std::string &policyName)
Returns a cs::Policy identified by policyName, or nullptr if policyName is unknown.
virtual void evictEntries()=0
Evicts zero or more entries.
virtual void doBeforeErase(EntryRef i)=0
Invoked before an entry is erased due to management command.
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.
Policy(std::string_view policyName)
Table::const_iterator EntryRef
A reference to a CS entry.
void afterRefresh(EntryRef i)
Invoked by CS after an existing entry is refreshed by same Data.
#define NFD_LOG_INIT(name)