27 #include <type_traits> 29 #include <boost/concept/assert.hpp> 30 #include <boost/concept_check.hpp> 31 #include <type_traits> 36 #if HAVE_IS_MOVE_CONSTRUCTIBLE 37 static_assert(std::is_move_constructible<DataMatchResult>::value,
38 "DataMatchResult must be MoveConstructible");
39 #endif // HAVE_IS_MOVE_CONSTRUCTIBLE 44 BOOST_CONCEPT_ASSERT((boost::ForwardIterator<Pit::const_iterator>));
47 #ifdef HAVE_IS_DEFAULT_CONSTRUCTIBLE 48 static_assert(std::is_default_constructible<Pit::const_iterator>::value,
49 "Pit::const_iterator must be default-constructible");
51 BOOST_CONCEPT_ASSERT((boost::DefaultConstructible<Pit::const_iterator>));
52 #endif // HAVE_IS_DEFAULT_CONSTRUCTIBLE 55 : m_nameTree(nameTree)
60 std::pair<shared_ptr<pit::Entry>,
bool>
61 Pit::findOrInsert(
const Interest& interest,
bool allowInsert)
65 bool isEndWithDigest = name.
size() > 0 && name[-1].isImplicitSha256Digest();
66 shared_ptr<name_tree::Entry> nte = m_nameTree.
lookup(isEndWithDigest ? name.
getPrefix(-1) : name);
67 BOOST_ASSERT(nte !=
nullptr);
68 size_t nteNameLen = nte->getPrefix().size();
71 const std::vector<shared_ptr<pit::Entry>>& pitEntries = nte->getPitEntries();
72 auto it = std::find_if(pitEntries.begin(), pitEntries.end(),
73 [&interest, nteNameLen] (
const shared_ptr<pit::Entry>& entry) ->
bool {
75 BOOST_ASSERT(entry->getInterest().getName().compare(0, nteNameLen,
76 interest.
getName(), 0, nteNameLen) == 0);
78 return entry->getInterest().getName().compare(nteNameLen,
Name::npos,
79 interest.
getName(), nteNameLen) == 0 &&
80 entry->getInterest().getSelectors() == interest.
getSelectors();
82 if (it != pitEntries.end()) {
87 return {
nullptr,
true};
90 auto entry = make_shared<pit::Entry>(interest);
91 nte->insertPitEntry(entry);
104 for (
const shared_ptr<pit::Entry>& pitEntry : nte.getPitEntries()) {
105 if (pitEntry->getInterest().matchesData(data))
106 matches.emplace_back(pitEntry);
116 shared_ptr<name_tree::Entry> nameTreeEntry = pitEntry->m_nameTreeEntry;
117 BOOST_ASSERT(static_cast<bool>(nameTreeEntry));
119 nameTreeEntry->erasePitEntry(pitEntry);
129 [] (
const name_tree::Entry& entry) { return entry.hasPitEntries(); }).begin());
PartialName getPrefix(ssize_t nComponents) const
Extract a prefix (PartialName) of the name, containing first nComponents components.
void erase(shared_ptr< pit::Entry > pitEntry)
erases a PIT Entry
const Selectors & getSelectors() const
bool eraseEntryIfEmpty(shared_ptr< name_tree::Entry > entry)
Delete a Name Tree Entry if this entry is empty.
const Name & getName() const
Get name of the Data packet.
static const size_t npos
indicates "until the end" in getSubName and compare
represents an Interest packet
pit::DataMatchResult findAllDataMatches(const Data &data) const
performs a Data match
const_iterator begin() const
returns an iterator pointing to the first PIT entry
Copyright (c) 2011-2015 Regents of the University of California.
Name abstraction to represent an absolute name.
shared_ptr< name_tree::Entry > lookup(const Name &prefix)
Look for the Name Tree Entry that contains this name prefix.
boost::iterator_range< const_iterator > findAllMatches(const Name &prefix, const name_tree::EntrySelector &entrySelector=name_tree::AnyEntry()) const
Enumerate all the name prefixes that satisfy the prefix and entrySelector.
size_t size() const
Get the number of components.
boost::iterator_range< const_iterator > fullEnumerate(const name_tree::EntrySelector &entrySelector=name_tree::AnyEntry()) const
Enumerate all entries, optionally filtered by an EntrySelector.
const Name & getName() const
std::vector< shared_ptr< pit::Entry > > DataMatchResult