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 unique_ptr<Policy>(
new 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);
89 if (lch.hasCachingPolicy()) {
91 if (policy == LocalControlHeader::CachingPolicy::NO_CACHE) {
96 bool isNewEntry =
false;
99 std::tie(it, isNewEntry) = m_table.insert(
EntryImpl(data.shared_from_this(), isUnsolicited));
110 m_policy->afterRefresh(it);
113 m_policy->afterInsert(it);
124 BOOST_ASSERT(static_cast<bool>(hitCallback));
125 BOOST_ASSERT(static_cast<bool>(missCallback));
129 NFD_LOG_DEBUG(
"find " << prefix << (isRightmost ?
" R" :
" L"));
131 iterator first = m_table.lower_bound(prefix);
133 if (prefix.
size() > 0) {
139 match = this->findRightmost(interest, first, last);
142 match = this->findLeftmost(interest, first, last);
147 missCallback(interest);
151 m_policy->beforeUse(match);
152 hitCallback(interest, match->getData());
168 size_t interestNameLength = interest.
getName().
size();
169 for (
iterator right = last; right != first;) {
173 if (prev->getName().size() == interestNameLength) {
175 iterator matchExact = this->findRightmostAmongExact(interest, first, right);
176 return matchExact == right ? last : matchExact;
179 Name prefix = prev->getName().
getPrefix(interestNameLength + 1);
180 iterator left = m_table.lower_bound(prefix);
184 iterator match = this->findLeftmost(interest, left, right);
185 if (match != right) {
200 Cs::setPolicyImpl(unique_ptr<Policy>& policy)
202 m_policy = std::move(policy);
203 m_beforeEvictConnection = m_policy->beforeEvict.connect([
this] (
iterator it) {
207 m_policy->setCs(
this);
208 BOOST_ASSERT(m_policy->getCs() ==
this);
const Name & getName() const
#define NFD_LOG_DEBUG(expression)
bool canSatisfy(const Interest &interest) const
determines whether Interest can be satisified by the stored Data
Name getSuccessor() const
Get the successor of a name.
Cs(size_t nMaxPackets=10, unique_ptr< Policy > policy=makeDefaultPolicy())
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
bool insert(const Data &data, bool isUnsolicited=false)
inserts a Data packet
It find_last_if(It first, It last, Pred p)
represents an Interest packet
int getChildSelector() const
an Entry in ContentStore implementation
const Name & getName() const
Get name of the Data packet.
Table::const_iterator iterator
Copyright (c) 2011-2015 Regents of the University of California.
unique_ptr< Policy > makeDefaultPolicy()
void find(const Interest &interest, const HitCallback &hitCallback, const MissCallback &missCallback) const
finds the best matching Data packet
void setPolicy(unique_ptr< Policy > policy)
changes cs replacement policy
bool isUnsolicited() const
void setLimit(size_t nMaxPackets)
changes capacity (in number of packets)
size_t size() const
Get the number of components.
Name abstraction to represent an absolute name.
std::function< void(const Interest &, const Data &data)> HitCallback
std::function< void(const Interest &)> MissCallback
void updateStaleTime()
refreshes stale time relative to current time
#define NFD_LOG_INIT(name)
#define NFD_LOG_TRACE(expression)
PartialName getPrefix(ssize_t nComponents) const
Extract a prefix (PartialName) of the name, containing first nComponents components.
nfd::LocalControlHeader & getLocalControlHeader()