table: simplify pit::Entry API
refs #3546
Change-Id: I6a9cb83b9e56ce1d1bb6047049378c51781605af
diff --git a/daemon/fw/access-strategy.cpp b/daemon/fw/access-strategy.cpp
index 8d53168..862e165 100644
--- a/daemon/fw/access-strategy.cpp
+++ b/daemon/fw/access-strategy.cpp
@@ -195,14 +195,14 @@
pi->rtoTimer.cancel();
}
- if (pitEntry->getInRecords().empty()) { // already satisfied by another upstream
+ if (!pitEntry->hasInRecords()) { // already satisfied by another upstream
NFD_LOG_DEBUG(pitEntry->getInterest() << " dataFrom " << inFace.getId() <<
" not-fastest");
return;
}
- pit::OutRecordCollection::const_iterator outRecord = pitEntry->getOutRecord(inFace);
- if (outRecord == pitEntry->getOutRecords().end()) { // no OutRecord
+ pit::OutRecordCollection::iterator outRecord = pitEntry->getOutRecord(inFace);
+ if (outRecord == pitEntry->out_end()) { // no out-record
NFD_LOG_DEBUG(pitEntry->getInterest() << " dataFrom " << inFace.getId() <<
" no-out-record");
return;
diff --git a/daemon/fw/best-route-strategy2.cpp b/daemon/fw/best-route-strategy2.cpp
index 96791be..0644ba9 100644
--- a/daemon/fw/best-route-strategy2.cpp
+++ b/daemon/fw/best-route-strategy2.cpp
@@ -50,7 +50,7 @@
* \param pitEntry PIT entry
* \param nexthop next hop
* \param currentDownstream incoming FaceId of current Interest
- * \param wantUnused if true, NextHop must not have unexpired OutRecord
+ * \param wantUnused if true, NextHop must not have unexpired out-record
* \param now time::steady_clock::now(), ignored if !wantUnused
*/
static inline bool
@@ -70,10 +70,9 @@
return false;
if (wantUnused) {
- // NextHop must not have unexpired OutRecord
- pit::OutRecordCollection::const_iterator outRecord = pitEntry->getOutRecord(*upstream);
- if (outRecord != pitEntry->getOutRecords().end() &&
- outRecord->getExpiry() > now) {
+ // NextHop must not have unexpired out-record
+ pit::OutRecordCollection::iterator outRecord = pitEntry->getOutRecord(*upstream);
+ if (outRecord != pitEntry->out_end() && outRecord->getExpiry() > now) {
return false;
}
}
@@ -81,8 +80,8 @@
return true;
}
-/** \brief pick an eligible NextHop with earliest OutRecord
- * \note It is assumed that every nexthop has an OutRecord
+/** \brief pick an eligible NextHop with earliest out-record
+ * \note It is assumed that every nexthop has an out-record.
*/
static inline fib::NextHopList::const_iterator
findEligibleNextHopWithEarliestOutRecord(const shared_ptr<pit::Entry>& pitEntry,
@@ -94,8 +93,8 @@
for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
if (!predicate_NextHop_eligible(pitEntry, *it, currentDownstream))
continue;
- pit::OutRecordCollection::const_iterator outRecord = pitEntry->getOutRecord(*it->getFace());
- BOOST_ASSERT(outRecord != pitEntry->getOutRecords().end());
+ pit::OutRecordCollection::iterator outRecord = pitEntry->getOutRecord(*it->getFace());
+ BOOST_ASSERT(outRecord != pitEntry->out_end());
if (outRecord->getLastRenewed() < earliestRenewed) {
found = it;
earliestRenewed = outRecord->getLastRenewed();
@@ -209,8 +208,8 @@
if (nOutRecordsNotNacked == 1) {
BOOST_ASSERT(lastFaceNotNacked != nullptr);
- pit::InRecordCollection::const_iterator inR = pitEntry->getInRecord(*lastFaceNotNacked);
- if (inR != pitEntry->getInRecords().end()) {
+ pit::InRecordCollection::iterator inR = pitEntry->getInRecord(*lastFaceNotNacked);
+ if (inR != pitEntry->in_end()) {
// one out-record not Nacked, which is also a downstream
NFD_LOG_DEBUG(nack.getInterest() << " nack-from=" << inFace.getId() <<
" nack=" << nack.getReason() <<
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index ef792ae..b575e3b 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -142,9 +142,7 @@
this->cancelUnsatisfyAndStragglerTimer(pitEntry);
// is pending?
- const pit::InRecordCollection& inRecords = pitEntry->getInRecords();
- bool isPending = inRecords.begin() != inRecords.end();
- if (!isPending) {
+ if (!pitEntry->hasInRecords()) {
m_cs.find(interest,
bind(&Forwarder::onContentStoreHit, this, ref(inFace), pitEntry, _1, _2),
bind(&Forwarder::onContentStoreMiss, this, ref(inFace), pitEntry, _1));
@@ -184,7 +182,7 @@
NFD_LOG_DEBUG("onContentStoreMiss interest=" << interest.getName());
shared_ptr<Face> face = const_pointer_cast<Face>(inFace.shared_from_this());
- // insert InRecord
+ // insert in-record
pitEntry->insertOrUpdateInRecord(face, interest);
// set PIT unsatisfy timer
@@ -261,14 +259,14 @@
this->onOutgoingData(data, *const_pointer_cast<Face>(inFace.shared_from_this()));
}
-/** \brief compare two InRecords for picking outgoing Interest
+/** \brief compare two in-records for picking outgoing Interest
* \return true if b is preferred over a
*
* This function should be passed to std::max_element over InRecordCollection.
* The outgoing Interest picked is the last incoming Interest
* that does not come from outFace.
- * If all InRecords come from outFace, it's fine to pick that. This happens when
- * there's only one InRecord that comes from outFace. The legit use is for
+ * If all in-records come from outFace, it's fine to pick that. This happens when
+ * there's only one in-record that comes from outFace. The legit use is for
* vehicular network; otherwise, strategy shouldn't send to the sole inFace.
*/
static inline bool
@@ -306,12 +304,10 @@
}
// pick Interest
- const pit::InRecordCollection& inRecords = pitEntry->getInRecords();
- pit::InRecordCollection::const_iterator pickedInRecord = std::max_element(
- inRecords.begin(), inRecords.end(), bind(&compare_pickInterest, _1, _2, &outFace));
- BOOST_ASSERT(pickedInRecord != inRecords.end());
- shared_ptr<Interest> interest = const_pointer_cast<Interest>(
- pickedInRecord->getInterest().shared_from_this());
+ pit::InRecordCollection::iterator pickedInRecord = std::max_element(
+ pitEntry->in_begin(), pitEntry->in_end(), bind(&compare_pickInterest, _1, _2, &outFace));
+ BOOST_ASSERT(pickedInRecord != pitEntry->in_end());
+ auto interest = const_pointer_cast<Interest>(pickedInRecord->getInterest().shared_from_this());
if (wantNewNonce) {
interest = make_shared<Interest>(*interest);
@@ -319,7 +315,7 @@
interest->setNonce(dist(getGlobalRng()));
}
- // insert OutRecord
+ // insert out-record
pitEntry->insertOrUpdateOutRecord(outFace.shared_from_this(), *interest);
// send Interest
@@ -403,6 +399,7 @@
std::set<Face*> pendingDownstreams;
// foreach PitEntry
+ auto now = time::steady_clock::now();
for (const shared_ptr<pit::Entry>& pitEntry : pitMatches) {
NFD_LOG_DEBUG("onIncomingData matching=" << pitEntry->getName());
@@ -410,9 +407,8 @@
this->cancelUnsatisfyAndStragglerTimer(pitEntry);
// remember pending downstreams
- const pit::InRecordCollection& inRecords = pitEntry->getInRecords();
- for (const pit::InRecord& inRecord : inRecords) {
- if (inRecord.getExpiry() > time::steady_clock::now()) {
+ for (const pit::InRecord& inRecord : pitEntry->getInRecords()) {
+ if (inRecord.getExpiry() > now) {
pendingDownstreams.insert(inRecord.getFace().get());
}
}
@@ -421,11 +417,11 @@
this->dispatchToStrategy(pitEntry, bind(&Strategy::beforeSatisfyInterest, _1,
pitEntry, cref(inFace), cref(data)));
- // Dead Nonce List insert if necessary (for OutRecord of inFace)
+ // Dead Nonce List insert if necessary (for out-record of inFace)
this->insertDeadNonceList(*pitEntry, true, data.getFreshnessPeriod(), &inFace);
// mark PIT satisfied
- pitEntry->deleteInRecords();
+ pitEntry->clearInRecords();
pitEntry->deleteOutRecord(inFace);
// set PIT straggler timer
@@ -511,7 +507,7 @@
// has out-record?
pit::OutRecordCollection::iterator outRecord = pitEntry->getOutRecord(inFace);
// if no out-record found, drop
- if (outRecord == pitEntry->getOutRecords().end()) {
+ if (outRecord == pitEntry->out_end()) {
NFD_LOG_DEBUG("onIncomingNack face=" << inFace.getId() <<
" nack=" << nack.getInterest().getName() <<
"~" << nack.getReason() << " no-out-record");
@@ -552,10 +548,10 @@
}
// has in-record?
- pit::InRecordCollection::const_iterator inRecord = pitEntry->getInRecord(outFace);
+ pit::InRecordCollection::iterator inRecord = pitEntry->getInRecord(outFace);
// if no in-record found, drop
- if (inRecord == pitEntry->getInRecords().end()) {
+ if (inRecord == pitEntry->in_end()) {
NFD_LOG_DEBUG("onOutgoingNack face=" << outFace.getId() <<
" nack=" << pitEntry->getInterest().getName() <<
"~" << nack.getReason() << " no-in-record");
@@ -595,15 +591,13 @@
void
Forwarder::setUnsatisfyTimer(shared_ptr<pit::Entry> pitEntry)
{
- const pit::InRecordCollection& inRecords = pitEntry->getInRecords();
- pit::InRecordCollection::const_iterator lastExpiring =
- std::max_element(inRecords.begin(), inRecords.end(),
- &compare_InRecord_expiry);
+ pit::InRecordCollection::iterator lastExpiring =
+ std::max_element(pitEntry->in_begin(), pitEntry->in_end(), &compare_InRecord_expiry);
time::steady_clock::TimePoint lastExpiry = lastExpiring->getExpiry();
- time::nanoseconds lastExpiryFromNow = lastExpiry - time::steady_clock::now();
- if (lastExpiryFromNow <= time::seconds(0)) {
- // TODO all InRecords are already expired; will this happen?
+ time::nanoseconds lastExpiryFromNow = lastExpiry - time::steady_clock::now();
+ if (lastExpiryFromNow <= time::seconds::zero()) {
+ // TODO all in-records are already expired; will this happen?
}
scheduler::cancel(pitEntry->m_unsatisfyTimer);
@@ -666,7 +660,7 @@
}
else {
// insert outgoing Nonce of a specific face
- pit::OutRecordCollection::const_iterator outRecord = pitEntry.getOutRecord(*upstream);
+ pit::OutRecordCollection::iterator outRecord = pitEntry.getOutRecord(*upstream);
if (outRecord != pitEntry.getOutRecords().end()) {
m_deadNonceList.add(pitEntry.getName(), outRecord->getLastNonce());
}
diff --git a/daemon/fw/forwarder.hpp b/daemon/fw/forwarder.hpp
index 2bac6b0..bb3935c 100644
--- a/daemon/fw/forwarder.hpp
+++ b/daemon/fw/forwarder.hpp
@@ -206,8 +206,8 @@
cancelUnsatisfyAndStragglerTimer(shared_ptr<pit::Entry> pitEntry);
/** \brief insert Nonce to Dead Nonce List if necessary
- * \param upstream if null, insert Nonces from all OutRecords;
- * if not null, insert Nonce only on the OutRecord of this face
+ * \param upstream if null, insert Nonces from all out-records;
+ * if not null, insert Nonce only on the out-records of this face
*/
VIRTUAL_WITH_TESTS void
insertDeadNonceList(pit::Entry& pitEntry, bool isSatisfied,
diff --git a/daemon/fw/ncc-strategy.cpp b/daemon/fw/ncc-strategy.cpp
index ef91c6b..c096fe1 100644
--- a/daemon/fw/ncc-strategy.cpp
+++ b/daemon/fw/ncc-strategy.cpp
@@ -192,7 +192,7 @@
NccStrategy::beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
const Face& inFace, const Data& data)
{
- if (pitEntry->getInRecords().empty()) {
+ if (!pitEntry->hasInRecords()) {
// PIT entry has already been satisfied (and is now waiting for straggler timer to expire)
// NCC does not collect measurements for non-best face
return;
diff --git a/daemon/fw/pit-algorithm.cpp b/daemon/fw/pit-algorithm.cpp
index ac04e2a..ca54dfe 100644
--- a/daemon/fw/pit-algorithm.cpp
+++ b/daemon/fw/pit-algorithm.cpp
@@ -48,7 +48,7 @@
if (scope_prefix::LOCALHOP.isPrefixOf(pitEntry.getName())) {
// face is non-local, violates localhop scope unless PIT entry has local in-record
- return std::none_of(pitEntry.getInRecords().begin(), pitEntry.getInRecords().end(),
+ return std::none_of(pitEntry.in_begin(), pitEntry.in_end(),
[] (const pit::InRecord& inRecord) { return inRecord.getFace()->getScope() == ndn::nfd::FACE_SCOPE_LOCAL; });
}
@@ -61,7 +61,7 @@
{
time::steady_clock::TimePoint now = time::steady_clock::now();
- bool hasUnexpiredOutRecord = std::any_of(pitEntry.getOutRecords().begin(), pitEntry.getOutRecords().end(),
+ bool hasUnexpiredOutRecord = std::any_of(pitEntry.out_begin(), pitEntry.out_end(),
[&face, &now] (const pit::OutRecord& outRecord) {
return outRecord.getFace().get() == &face && outRecord.getExpiry() >= now;
});
@@ -69,7 +69,7 @@
return false;
}
- bool hasUnexpiredOtherInRecord = std::any_of(pitEntry.getInRecords().begin(), pitEntry.getInRecords().end(),
+ bool hasUnexpiredOtherInRecord = std::any_of(pitEntry.in_begin(), pitEntry.in_end(),
[&face, &now] (const pit::InRecord& inRecord) {
return inRecord.getFace().get() != &face && inRecord.getExpiry() >= now;
});
@@ -114,7 +114,7 @@
hasPendingOutRecords(const pit::Entry& pitEntry)
{
time::steady_clock::TimePoint now = time::steady_clock::now();
- return std::any_of(pitEntry.getOutRecords().begin(), pitEntry.getOutRecords().end(),
+ return std::any_of(pitEntry.out_begin(), pitEntry.out_end(),
[&now] (const pit::OutRecord& outRecord) { return outRecord.getExpiry() >= now; });
}
diff --git a/daemon/fw/retx-suppression.cpp b/daemon/fw/retx-suppression.cpp
index a420581..9ae122a 100644
--- a/daemon/fw/retx-suppression.cpp
+++ b/daemon/fw/retx-suppression.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -31,13 +31,12 @@
time::steady_clock::TimePoint
RetxSuppression::getLastOutgoing(const pit::Entry& pitEntry) const
{
- const pit::OutRecordCollection& outRecords = pitEntry.getOutRecords();
pit::OutRecordCollection::const_iterator lastOutgoing = std::max_element(
- outRecords.begin(), outRecords.end(),
- [] (const pit::OutRecord& a, const pit::OutRecord& b) {
- return a.getLastRenewed() < b.getLastRenewed();
- });
- BOOST_ASSERT(lastOutgoing != outRecords.end()); // otherwise it's new PIT entry
+ pitEntry.out_begin(), pitEntry.out_end(),
+ [] (const pit::OutRecord& a, const pit::OutRecord& b) {
+ return a.getLastRenewed() < b.getLastRenewed();
+ });
+ BOOST_ASSERT(lastOutgoing != pitEntry.out_end()); // otherwise it's new PIT entry
return lastOutgoing->getLastRenewed();
}
diff --git a/daemon/fw/strategy.cpp b/daemon/fw/strategy.cpp
index 00fe82f..e0dca89 100644
--- a/daemon/fw/strategy.cpp
+++ b/daemon/fw/strategy.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -74,8 +74,7 @@
{
// populate downstreams with all downstreams faces
std::unordered_set<const Face*> downstreams;
- const pit::InRecordCollection& inRecords = pitEntry->getInRecords();
- std::transform(inRecords.begin(), inRecords.end(), std::inserter(downstreams, downstreams.end()),
+ std::transform(pitEntry->in_begin(), pitEntry->in_end(), std::inserter(downstreams, downstreams.end()),
[] (const pit::InRecord& inR) { return inR.getFace().get(); });
// delete excluded faces
@@ -88,7 +87,7 @@
for (const Face* downstream : downstreams) {
this->sendNack(pitEntry, *downstream, header);
}
- // warning: don't loop on pitEntry->getInRecords(), because InRecord is erased when sending Nack
+ // warning: don't loop on pitEntry->getInRecords(), because in-record is deleted when sending Nack
}
} // namespace fw
diff --git a/daemon/table/pit-entry.cpp b/daemon/table/pit-entry.cpp
index 21e4c53..d19369a 100644
--- a/daemon/table/pit-entry.cpp
+++ b/daemon/table/pit-entry.cpp
@@ -34,10 +34,11 @@
{
}
-const Name&
-Entry::getName() const
+InRecordCollection::iterator
+Entry::getInRecord(const Face& face)
{
- return m_interest->getName();
+ return std::find_if(m_inRecords.begin(), m_inRecords.end(),
+ [&face] (const InRecord& inRecord) { return inRecord.getFace().get() == &face; });
}
InRecordCollection::iterator
@@ -54,13 +55,6 @@
return it;
}
-InRecordCollection::const_iterator
-Entry::getInRecord(const Face& face) const
-{
- return std::find_if(m_inRecords.begin(), m_inRecords.end(),
- [&face] (const InRecord& inRecord) { return inRecord.getFace().get() == &face; });
-}
-
void
Entry::deleteInRecord(const Face& face)
{
@@ -72,12 +66,19 @@
}
void
-Entry::deleteInRecords()
+Entry::clearInRecords()
{
m_inRecords.clear();
}
OutRecordCollection::iterator
+Entry::getOutRecord(const Face& face)
+{
+ return std::find_if(m_outRecords.begin(), m_outRecords.end(),
+ [&face] (const OutRecord& outRecord) { return outRecord.getFace().get() == &face; });
+}
+
+OutRecordCollection::iterator
Entry::insertOrUpdateOutRecord(shared_ptr<Face> face, const Interest& interest)
{
auto it = std::find_if(m_outRecords.begin(), m_outRecords.end(),
@@ -91,13 +92,6 @@
return it;
}
-OutRecordCollection::iterator
-Entry::getOutRecord(const Face& face)
-{
- return std::find_if(m_outRecords.begin(), m_outRecords.end(),
- [&face] (const OutRecord& outRecord) { return outRecord.getFace().get() == &face; });
-}
-
void
Entry::deleteOutRecord(const Face& face)
{
diff --git a/daemon/table/pit-entry.hpp b/daemon/table/pit-entry.hpp
index 012b5aa..ece0b40 100644
--- a/daemon/table/pit-entry.hpp
+++ b/daemon/table/pit-entry.hpp
@@ -40,15 +40,21 @@
namespace pit {
-/** \brief represents an unordered collection of InRecords
+/** \brief an unordered collection of in-records
*/
-typedef std::list< InRecord> InRecordCollection;
+typedef std::list<InRecord> InRecordCollection;
-/** \brief represents an unordered collection of OutRecords
+/** \brief an unordered collection of out-records
*/
typedef std::list<OutRecord> OutRecordCollection;
-/** \brief represents a PIT entry
+/** \brief an Interest table entry
+ *
+ * An Interest table entry represents either a pending Interest or a recently satisfied Interest.
+ * Each entry contains a collection of in-records, a collection of out-records,
+ * and two timers used in forwarding pipelines.
+ * In addition, the entry, in-records, and out-records are subclasses of StrategyInfoHost,
+ * which allows forwarding strategy to store arbitrary information on them.
*/
class Entry : public StrategyInfoHost, noncopyable
{
@@ -56,6 +62,11 @@
explicit
Entry(const Interest& interest);
+ /** \return the representative Interest of the PIT entry
+ * \note Every Interest in in-records and out-records should have same Name and Selectors
+ * as the representative Interest.
+ * \todo #3162 require Link field to match the representative Interest
+ */
const Interest&
getInterest() const;
@@ -64,57 +75,118 @@
const Name&
getName() const;
-public: // InRecord
+public: // in-record
+ /** \return collection of in-records
+ */
const InRecordCollection&
getInRecords() const;
- /** \brief inserts a InRecord for face, and updates it with interest
- *
- * If InRecord for face exists, the existing one is updated.
- * This method does not add the Nonce as a seen Nonce.
- * \return an iterator to the InRecord
+ /** \retval true There is at least one in-record.
+ * This implies some downstream is waiting for Data or Nack.
+ * \retval false There is no in-record.
+ * This implies the entry is new or has been satisfied or Nacked.
+ */
+ bool
+ hasInRecords() const;
+
+ InRecordCollection::iterator
+ in_begin();
+
+ InRecordCollection::const_iterator
+ in_begin() const;
+
+ InRecordCollection::iterator
+ in_end();
+
+ InRecordCollection::const_iterator
+ in_end() const;
+
+ /** \brief get the in-record for \p face
+ * \return an iterator to the in-record, or .in_end() if it does not exist
+ */
+ InRecordCollection::iterator
+ getInRecord(const Face& face);
+
+ /** \brief insert or update an in-record
+ * \return an iterator to the new or updated in-record
*/
InRecordCollection::iterator
insertOrUpdateInRecord(shared_ptr<Face> face, const Interest& interest);
- /** \brief get the InRecord for face
- * \return an iterator to the InRecord, or .end if it does not exist
+ /** \brief delete the in-record for \p face if it exists
*/
- InRecordCollection::const_iterator
- getInRecord(const Face& face) const;
-
- /// deletes one InRecord for face if exists
void
deleteInRecord(const Face& face);
- /// deletes all InRecords
+ /** \brief delete all in-records
+ */
void
- deleteInRecords();
+ clearInRecords();
-public: // OutRecord
+public: // out-record
+ /** \return collection of in-records
+ */
const OutRecordCollection&
getOutRecords() const;
- /** \brief inserts a OutRecord for face, and updates it with interest
- *
- * If OutRecord for face exists, the existing one is updated.
- * \return an iterator to the OutRecord
+ /** \retval true There is at least one out-record.
+ * This implies the Interest has been forwarded to some upstream,
+ * and they haven't returned Data, but may have returned Nacks.
+ * \retval false There is no out-record.
+ * This implies the Interest has not been forwarded.
*/
- OutRecordCollection::iterator
- insertOrUpdateOutRecord(shared_ptr<Face> face, const Interest& interest);
+ bool
+ hasOutRecords() const;
- /** \brief get the OutRecord for face
- * \return an iterator to the OutRecord, or .end if it does not exist
+ OutRecordCollection::iterator
+ out_begin();
+
+ OutRecordCollection::const_iterator
+ out_begin() const;
+
+ OutRecordCollection::iterator
+ out_end();
+
+ OutRecordCollection::const_iterator
+ out_end() const;
+
+ /** \brief get the out-record for \p face
+ * \return an iterator to the out-record, or .out_end() if it does not exist
*/
OutRecordCollection::iterator
getOutRecord(const Face& face);
- /// deletes one OutRecord for face if exists
+ /** \brief insert or update an out-record
+ * \return an iterator to the new or updated out-record
+ */
+ OutRecordCollection::iterator
+ insertOrUpdateOutRecord(shared_ptr<Face> face, const Interest& interest);
+
+ /** \brief delete the out-record for \p face if it exists
+ */
void
deleteOutRecord(const Face& face);
public:
+ /** \brief unsatisfy timer
+ *
+ * This timer is used in forwarding pipelines to delete the entry
+ * when it expires without being satisfied.
+ * It fires when the last InterestLifetime among in-records expires.
+ *
+ * Either this or the straggler timer should be set at all times,
+ * except when this entry is being processed in a pipeline.
+ */
scheduler::EventId m_unsatisfyTimer;
+
+ /** \brief straggler timer
+ *
+ * This timer is used in forwarding pipelines to delete the entry when it has been satisfied
+ * and is no longer needed for measurement collection purpose.
+ *
+ * Either this or the unsatisfy timer should be set at all times,
+ * except when this entry is being processed in a pipeline.
+ */
scheduler::EventId m_stragglerTimer;
private:
@@ -122,9 +194,6 @@
InRecordCollection m_inRecords;
OutRecordCollection m_outRecords;
- static const Name LOCALHOST_NAME;
- static const Name LOCALHOP_NAME;
-
shared_ptr<name_tree::Entry> m_nameTreeEntry;
friend class nfd::NameTree;
@@ -137,18 +206,84 @@
return *m_interest;
}
+inline const Name&
+Entry::getName() const
+{
+ return m_interest->getName();
+}
+
inline const InRecordCollection&
Entry::getInRecords() const
{
return m_inRecords;
}
+inline bool
+Entry::hasInRecords() const
+{
+ return !m_inRecords.empty();
+}
+
+inline InRecordCollection::iterator
+Entry::in_begin()
+{
+ return m_inRecords.begin();
+}
+
+inline InRecordCollection::const_iterator
+Entry::in_begin() const
+{
+ return m_inRecords.begin();
+}
+
+inline InRecordCollection::iterator
+Entry::in_end()
+{
+ return m_inRecords.end();
+}
+
+inline InRecordCollection::const_iterator
+Entry::in_end() const
+{
+ return m_inRecords.end();
+}
+
inline const OutRecordCollection&
Entry::getOutRecords() const
{
return m_outRecords;
}
+inline bool
+Entry::hasOutRecords() const
+{
+ return !m_outRecords.empty();
+}
+
+inline OutRecordCollection::iterator
+Entry::out_begin()
+{
+ return m_outRecords.begin();
+}
+
+inline OutRecordCollection::const_iterator
+Entry::out_begin() const
+{
+ return m_outRecords.begin();
+}
+
+inline OutRecordCollection::iterator
+Entry::out_end()
+{
+ return m_outRecords.end();
+}
+
+inline OutRecordCollection::const_iterator
+Entry::out_end() const
+{
+ return m_outRecords.end();
+}
+
} // namespace pit
} // namespace nfd
diff --git a/daemon/table/pit-in-record.hpp b/daemon/table/pit-in-record.hpp
index da56d1f..dd6ad06 100644
--- a/daemon/table/pit-in-record.hpp
+++ b/daemon/table/pit-in-record.hpp
@@ -1,12 +1,12 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis
+ * Copyright (c) 2014-2016, Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology,
+ * The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
@@ -31,8 +31,7 @@
namespace nfd {
namespace pit {
-/** \class InRecord
- * \brief contains information about an Interest from an incoming face
+/** \brief contains information about an Interest from an incoming face
*/
class InRecord : public FaceRecord
{