26 #ifndef NFD_DAEMON_TABLE_CS_HPP
27 #define NFD_DAEMON_TABLE_CS_HPP
44 class Cs : noncopyable
48 Cs(
size_t nMaxPackets = 10);
53 insert(
const Data& data,
bool isUnsolicited =
false);
62 template<
typename AfterEraseCallback>
64 erase(
const Name& prefix,
size_t limit, AfterEraseCallback&& cb)
66 size_t nErased = eraseImpl(prefix, limit);
79 template<
typename HitCallback,
typename MissCallback>
81 find(
const Interest& interest, HitCallback&& hit, MissCallback&& miss)
const
83 auto match = findImpl(interest);
84 if (match == m_table.end()) {
88 hit(interest, match->getData());
96 return m_table.size();
105 return m_policy->getLimit();
113 return m_policy->setLimit(nMaxPackets);
121 return m_policy.get();
136 return m_shouldAdmit;
151 return m_shouldServe;
166 return m_table.begin();
172 return m_table.end();
176 std::pair<const_iterator, const_iterator>
177 findPrefixRange(
const Name& prefix)
const;
180 eraseImpl(
const Name& prefix,
size_t limit);
183 findImpl(
const Interest& interest)
const;
186 setPolicyImpl(unique_ptr<Policy> policy);
194 unique_ptr<Policy> m_policy;
195 signal::ScopedConnection m_beforeEvictConnection;
197 bool m_shouldAdmit =
true;
198 bool m_shouldServe =
true;
implements the Content Store
Policy * getPolicy() const
get replacement policy
Table::const_iterator const_iterator
size_t size() const
get number of stored packets
size_t getLimit() const
get capacity (in number of packets)
void erase(const Name &prefix, size_t limit, AfterEraseCallback &&cb)
asynchronously erases entries under prefix
void setPolicy(unique_ptr< Policy > policy)
change replacement policy
Cs(size_t nMaxPackets=10)
void enableServe(bool shouldServe)
set CS_ENABLE_SERVE flag
void insert(const Data &data, bool isUnsolicited=false)
inserts a Data packet
void find(const Interest &interest, HitCallback &&hit, MissCallback &&miss) const
finds the best matching Data packet
void enableAdmit(bool shouldAdmit)
set CS_ENABLE_ADMIT flag
void setLimit(size_t nMaxPackets)
change capacity (in number of packets)
const_iterator end() const
const_iterator begin() const
bool shouldServe() const
get CS_ENABLE_SERVE flag
bool shouldAdmit() const
get CS_ENABLE_ADMIT flag
represents a CS replacement policy
#define NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE
std::set< Entry, std::less<> > Table
an ordered container of ContentStore entries
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents,...