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