38 : m_nameTree(nameTree)
43 std::pair<shared_ptr<Entry>,
bool>
44 Pit::findOrInsert(
const Interest& interest,
bool allowInsert)
47 const Name& name = interest.getName();
48 bool isEndWithDigest = name.size() > 0 && name[-1].isImplicitSha256Digest();
49 const Name& nteName = isEndWithDigest ? name.getPrefix(-1) : name;
54 nte = &m_nameTree.lookup(nteName);
57 nte = m_nameTree.findExactMatch(nteName);
59 return {
nullptr,
true};
64 size_t nteNameLen = nteName.size();
65 const std::vector<shared_ptr<Entry>>& pitEntries = nte->
getPitEntries();
66 auto it = std::find_if(pitEntries.begin(), pitEntries.end(),
67 [&interest, nteNameLen] (
const shared_ptr<Entry>& entry) ->
bool {
69 BOOST_ASSERT(entry->getInterest().getName().compare(0, nteNameLen,
70 interest.getName(), 0, nteNameLen) == 0);
72 return entry->getInterest().getName().compare(nteNameLen, Name::npos,
73 interest.getName(), nteNameLen) == 0 &&
74 entry->getInterest().getSelectors() == interest.getSelectors();
76 if (it != pitEntries.end()) {
82 return {
nullptr,
true};
85 auto entry = make_shared<Entry>(interest);
94 auto&& ntMatches = m_nameTree.findAllMatches(data.getName(), &
nteHasPitEntries);
98 for (
const shared_ptr<Entry>& pitEntry : nte.
getPitEntries()) {
99 if (pitEntry->getInterest().matchesData(data))
100 matches.emplace_back(pitEntry);
111 BOOST_ASSERT(nte !=
nullptr);
115 m_nameTree.eraseIfEmpty(nte);
123 BOOST_ASSERT(entry !=
nullptr);
const_iterator begin() const
void deleteInRecord(const Face &face)
delete the in-record for face if it exists
an unordered iterable of all PIT entries matching Data
void erasePitEntry(pit::Entry *pitEntry)
void deleteOutRecord(const Face &face)
delete the out-record for face if it exists
const std::vector< shared_ptr< pit::Entry > > & getPitEntries() const
bool hasPitEntries() const
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
void deleteInOutRecords(Entry *entry, const Face &face)
deletes in-record and out-record for face
an entry in the name tree
static bool nteHasPitEntries(const name_tree::Entry &nte)
DataMatchResult findAllDataMatches(const Data &data) const
performs a Data match
void erase(Entry *entry)
deletes an entry
std::vector< shared_ptr< Entry > > DataMatchResult
void insertPitEntry(shared_ptr< pit::Entry > pitEntry)