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;
207 #endif // NFD_DAEMON_TABLE_CS_HPP Table::const_iterator const_iterator
const_iterator end() const
std::set< Entry, std::less<> > Table
an ordered container of ContentStore entries
void enableAdmit(bool shouldAdmit)
set CS_ENABLE_ADMIT flag
implements the Content Store
bool shouldServe() const
get CS_ENABLE_SERVE flag
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
void insert(const Data &data, bool isUnsolicited=false)
inserts a Data packet
void erase(const Name &prefix, size_t limit, AfterEraseCallback &&cb)
asynchronously erases entries under prefix
bool shouldAdmit() const
get CS_ENABLE_ADMIT flag
void enableServe(bool shouldServe)
set CS_ENABLE_SERVE flag
void setLimit(size_t nMaxPackets)
change capacity (in number of packets)
size_t size() const
get number of stored packets
void setPolicy(unique_ptr< Policy > policy)
change replacement policy
size_t getLimit() const
get capacity (in number of packets)
Policy * getPolicy() const
get replacement policy
const_iterator begin() const
represents a CS replacement policy
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
void find(const Interest &interest, HitCallback &&hit, MissCallback &&miss) const
finds the best matching Data packet
Cs(size_t nMaxPackets=10)