37 BOOST_CONCEPT_ASSERT((boost::ForwardIterator<Cs::const_iterator>));
40 #ifdef HAVE_IS_DEFAULT_CONSTRUCTIBLE 41 static_assert(std::is_default_constructible<Cs::const_iterator>::value,
42 "Cs::const_iterator must be default-constructible");
44 BOOST_CONCEPT_ASSERT((boost::DefaultConstructible<Cs::const_iterator>));
45 #endif // HAVE_IS_DEFAULT_CONSTRUCTIBLE 50 return make_unique<PriorityFifoPolicy>();
53 Cs::Cs(
size_t nMaxPackets, unique_ptr<Policy> policy)
55 this->setPolicyImpl(policy);
56 m_policy->setLimit(nMaxPackets);
62 m_policy->setLimit(nMaxPackets);
68 return m_policy->getLimit();
74 BOOST_ASSERT(policy !=
nullptr);
75 BOOST_ASSERT(m_policy !=
nullptr);
76 size_t limit = m_policy->getLimit();
77 this->setPolicyImpl(policy);
78 m_policy->setLimit(limit);
86 if (m_policy->getLimit() == 0) {
100 bool isNewEntry =
false;
103 std::tie(it, isNewEntry) = m_table.insert(
EntryImpl(data.shared_from_this(), isUnsolicited));
114 m_policy->afterRefresh(it);
117 m_policy->afterInsert(it);
126 BOOST_ASSERT(static_cast<bool>(hitCallback));
127 BOOST_ASSERT(static_cast<bool>(missCallback));
131 NFD_LOG_DEBUG(
"find " << prefix << (isRightmost ?
" R" :
" L"));
133 iterator first = m_table.lower_bound(prefix);
135 if (prefix.
size() > 0) {
141 match = this->findRightmost(interest, first, last);
144 match = this->findLeftmost(interest, first, last);
149 missCallback(interest);
153 m_policy->beforeUse(match);
154 hitCallback(interest, match->getData());
170 size_t interestNameLength = interest.
getName().
size();
171 for (
iterator right = last; right != first;) {
175 if (prev->getName().size() == interestNameLength) {
177 iterator matchExact = this->findRightmostAmongExact(interest, first, right);
178 return matchExact == right ? last : matchExact;
181 Name prefix = prev->getName().
getPrefix(interestNameLength + 1);
182 iterator left = m_table.lower_bound(prefix);
186 iterator match = this->findLeftmost(interest, left, right);
187 if (match != right) {
202 Cs::setPolicyImpl(unique_ptr<Policy>& policy)
204 m_policy = std::move(policy);
205 m_beforeEvictConnection = m_policy->beforeEvict.connect([
this] (
iterator it) {
209 m_policy->setCs(
this);
210 BOOST_ASSERT(m_policy->getCs() ==
this);
PartialName getPrefix(ssize_t nComponents) const
Extract a prefix (PartialName) of the name, containing first nComponents components.
shared_ptr< T > getTag() const
get a tag item
#define NFD_LOG_DEBUG(expression)
int getChildSelector() const
bool isUnsolicited() const
Cs(size_t nMaxPackets=10, unique_ptr< Policy > policy=makeDefaultPolicy())
Copyright (c) 2014-2016, Regents of the University of California, Arizona Board of Regents...
const Name & getName() const
Get name of the Data packet.
Name getSuccessor() const
Get the successor of a name.
It find_last_if(It first, It last, Pred p)
represents an Interest packet
an Entry in ContentStore implementation
provides a tag type for simple types
Table::const_iterator iterator
void insert(const Data &data, bool isUnsolicited=false)
inserts a Data packet
Copyright (c) 2011-2015 Regents of the University of California.
unique_ptr< Policy > makeDefaultPolicy()
void setPolicy(unique_ptr< Policy > policy)
changes cs replacement policy
void setLimit(size_t nMaxPackets)
changes capacity (in number of packets)
CachePolicyType
indicates the cache policy applied to a Data packet
Name abstraction to represent an absolute name.
void find(const Interest &interest, const HitCallback &hitCallback, const MissCallback &missCallback) const
finds the best matching Data packet
std::function< void(const Interest &, const Data &data)> HitCallback
std::function< void(const Interest &)> MissCallback
size_t size() const
Get the number of components.
void updateStaleTime()
refreshes stale time relative to current time
#define NFD_LOG_INIT(name)
#define NFD_LOG_TRACE(expression)
bool canSatisfy(const Interest &interest) const
determines whether Interest can be satisified by the stored Data
const Name & getName() const