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.
bool shouldServe() const noexcept
Get CS_ENABLE_SERVE flag.
Table::const_iterator const_iterator
void enableAdmit(bool shouldAdmit) noexcept
Set CS_ENABLE_ADMIT flag.
size_t size() const
Get number of stored packets.
bool shouldAdmit() const noexcept
Get CS_ENABLE_ADMIT flag.
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 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 setLimit(size_t nMaxPackets)
Change capacity (in number of packets).
void enableServe(bool shouldServe) noexcept
Set CS_ENABLE_SERVE flag.
Policy * getPolicy() const noexcept
Get replacement policy.
const_iterator end() const
size_t getLimit() const noexcept
Get capacity (in number of packets).
const_iterator begin() const
Represents a CS replacement policy.
#define NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE
std::set< Entry, std::less<> > Table
An ordered container of ContentStore entries.