table: simplify pit::Entry API
refs #3546
Change-Id: I6a9cb83b9e56ce1d1bb6047049378c51781605af
diff --git a/tests/daemon/fw/best-route-strategy2.t.cpp b/tests/daemon/fw/best-route-strategy2.t.cpp
index 9cecd15..00c059f 100644
--- a/tests/daemon/fw/best-route-strategy2.t.cpp
+++ b/tests/daemon/fw/best-route-strategy2.t.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,
@@ -119,7 +119,7 @@
scheduler::cancel(retxFrom4Evt);
// nexthops for accepted retransmissions: follow FIB cost,
- // later forward to an eligible upstream with earliest OutRecord
+ // later forward to an eligible upstream with earliest out-record
BOOST_REQUIRE_GE(strategy.sendInterestHistory.size(), 6);
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[1].outFaceId, face1->getId());
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[2].outFaceId, face3->getId());
diff --git a/tests/daemon/fw/forwarder.t.cpp b/tests/daemon/fw/forwarder.t.cpp
index 906e2ca..45014ff 100644
--- a/tests/daemon/fw/forwarder.t.cpp
+++ b/tests/daemon/fw/forwarder.t.cpp
@@ -476,8 +476,8 @@
BOOST_CHECK_EQUAL(strategyQ->afterReceiveNack_count, 1);
// record Nack on PIT out-record
- pit::OutRecordCollection::const_iterator outRecord1 = pit1->getOutRecord(*face1);
- BOOST_REQUIRE(outRecord1 != pit1->getOutRecords().end());
+ pit::OutRecordCollection::iterator outRecord1 = pit1->getOutRecord(*face1);
+ BOOST_REQUIRE(outRecord1 != pit1->out_end());
BOOST_REQUIRE(outRecord1->getIncomingNack() != nullptr);
BOOST_CHECK_EQUAL(outRecord1->getIncomingNack()->getReason(), lp::NackReason::CONGESTION);
@@ -559,8 +559,8 @@
BOOST_CHECK_EQUAL(face1->sentNacks.back().getInterest().getNonce(), 152);
// erase in-record
- pit::InRecordCollection::const_iterator inRecord2a = pit2->getInRecord(*face1);
- BOOST_CHECK(inRecord2a == pit2->getInRecords().end());
+ pit::InRecordCollection::iterator inRecord2a = pit2->getInRecord(*face1);
+ BOOST_CHECK(inRecord2a == pit2->in_end());
// send Nack with correct Nonce
face2->sentNacks.clear();
@@ -570,8 +570,8 @@
BOOST_CHECK_EQUAL(face2->sentNacks.back().getInterest().getNonce(), 808);
// erase in-record
- pit::InRecordCollection::const_iterator inRecord2b = pit2->getInRecord(*face1);
- BOOST_CHECK(inRecord2b == pit2->getInRecords().end());
+ pit::InRecordCollection::iterator inRecord2b = pit2->getInRecord(*face1);
+ BOOST_CHECK(inRecord2b == pit2->in_end());
// don't send Nack to multi-access face
shared_ptr<Interest> interest2c = makeInterest("/Vi8tRm9MG3", 228);
diff --git a/tests/daemon/fw/ncc-strategy.t.cpp b/tests/daemon/fw/ncc-strategy.t.cpp
index 94fe162..fa42622 100644
--- a/tests/daemon/fw/ncc-strategy.t.cpp
+++ b/tests/daemon/fw/ncc-strategy.t.cpp
@@ -208,7 +208,7 @@
// face1 responds
shared_ptr<Data> data1 = makeData("ndn:/seRMz5a6/%00");
strategy->beforeSatisfyInterest(pitEntry1, *face1, *data1);
- pitEntry1->deleteInRecords();
+ pitEntry1->clearInRecords();
this->advanceClocks(time::milliseconds(10));
// face2 also responds
strategy->beforeSatisfyInterest(pitEntry1, *face2, *data1);
@@ -268,7 +268,7 @@
data1->setFreshnessPeriod(time::milliseconds(5));
strategy->beforeSatisfyInterest(pitEntry1, *face2, *data1);
pitEntry1->deleteOutRecord(*face2);
- pitEntry1->deleteInRecords();
+ pitEntry1->clearInRecords();
this->advanceClocks(time::milliseconds(10));
// similar Interest: strategy should still forward it
diff --git a/tests/daemon/table/pit.t.cpp b/tests/daemon/table/pit.t.cpp
index 9ca3ec7..01f063d 100644
--- a/tests/daemon/table/pit.t.cpp
+++ b/tests/daemon/table/pit.t.cpp
@@ -58,22 +58,21 @@
interest4->setInterestLifetime(time::milliseconds(8795));
interest4->setNonce(17365);
- pit::Entry entry(*interest);
+ Entry entry(*interest);
BOOST_CHECK_EQUAL(entry.getInterest().getName(), name);
BOOST_CHECK_EQUAL(entry.getName(), name);
- const pit::InRecordCollection& inRecords1 = entry.getInRecords();
+ const InRecordCollection& inRecords1 = entry.getInRecords();
BOOST_CHECK_EQUAL(inRecords1.size(), 0);
- const pit::OutRecordCollection& outRecords1 = entry.getOutRecords();
+ const OutRecordCollection& outRecords1 = entry.getOutRecords();
BOOST_CHECK_EQUAL(outRecords1.size(), 0);
- // insert InRecord
+ // insert in-record
time::steady_clock::TimePoint before1 = time::steady_clock::now();
- pit::InRecordCollection::iterator in1 =
- entry.insertOrUpdateInRecord(face1, *interest1);
+ InRecordCollection::iterator in1 = entry.insertOrUpdateInRecord(face1, *interest1);
time::steady_clock::TimePoint after1 = time::steady_clock::now();
- const pit::InRecordCollection& inRecords2 = entry.getInRecords();
+ const InRecordCollection& inRecords2 = entry.getInRecords();
BOOST_CHECK_EQUAL(inRecords2.size(), 1);
BOOST_CHECK(in1 == inRecords2.begin());
BOOST_CHECK_EQUAL(in1->getFace(), face1);
@@ -85,12 +84,11 @@
(after1 - before1));
BOOST_CHECK(in1 == entry.getInRecord(*face1));
- // insert OutRecord
+ // insert out-record
time::steady_clock::TimePoint before2 = time::steady_clock::now();
- pit::OutRecordCollection::iterator out1 =
- entry.insertOrUpdateOutRecord(face1, *interest1);
+ OutRecordCollection::iterator out1 = entry.insertOrUpdateOutRecord(face1, *interest1);
time::steady_clock::TimePoint after2 = time::steady_clock::now();
- const pit::OutRecordCollection& outRecords2 = entry.getOutRecords();
+ const OutRecordCollection& outRecords2 = entry.getOutRecords();
BOOST_CHECK_EQUAL(outRecords2.size(), 1);
BOOST_CHECK(out1 == outRecords2.begin());
BOOST_CHECK_EQUAL(out1->getFace(), face1);
@@ -102,12 +100,11 @@
(after2 - before2));
BOOST_CHECK(out1 == entry.getOutRecord(*face1));
- // update InRecord
+ // update in-record
time::steady_clock::TimePoint before3 = time::steady_clock::now();
- pit::InRecordCollection::iterator in2 =
- entry.insertOrUpdateInRecord(face1, *interest2);
+ InRecordCollection::iterator in2 = entry.insertOrUpdateInRecord(face1, *interest2);
time::steady_clock::TimePoint after3 = time::steady_clock::now();
- const pit::InRecordCollection& inRecords3 = entry.getInRecords();
+ const InRecordCollection& inRecords3 = entry.getInRecords();
BOOST_CHECK_EQUAL(inRecords3.size(), 1);
BOOST_CHECK(in2 == inRecords3.begin());
BOOST_CHECK_EQUAL(in2->getFace(), face1);
@@ -116,42 +113,41 @@
- interest2->getInterestLifetime(),
(after3 - before3));
- // insert another InRecord
- pit::InRecordCollection::iterator in3 =
- entry.insertOrUpdateInRecord(face2, *interest3);
- const pit::InRecordCollection& inRecords4 = entry.getInRecords();
+ // insert another in-record
+ InRecordCollection::iterator in3 = entry.insertOrUpdateInRecord(face2, *interest3);
+ const InRecordCollection& inRecords4 = entry.getInRecords();
BOOST_CHECK_EQUAL(inRecords4.size(), 2);
BOOST_CHECK_EQUAL(in3->getFace(), face2);
- // get InRecord
- pit::InRecordCollection::const_iterator in4 = entry.getInRecord(*face1);
- BOOST_REQUIRE(in4 != entry.getInRecords().end());
+ // get in-record
+ InRecordCollection::iterator in4 = entry.getInRecord(*face1);
+ BOOST_REQUIRE(in4 != entry.in_end());
BOOST_CHECK_EQUAL(in4->getFace(), face1);
- // delete all InRecords
- entry.deleteInRecords();
- const pit::InRecordCollection& inRecords5 = entry.getInRecords();
+ // clear in-records
+ entry.clearInRecords();
+ const InRecordCollection& inRecords5 = entry.getInRecords();
BOOST_CHECK_EQUAL(inRecords5.size(), 0);
- BOOST_CHECK(entry.getInRecord(*face1) == entry.getInRecords().end());
+ BOOST_CHECK(entry.getInRecord(*face1) == entry.in_end());
- // insert another OutRecord
- pit::OutRecordCollection::iterator out2 =
+ // insert another out-record
+ OutRecordCollection::iterator out2 =
entry.insertOrUpdateOutRecord(face2, *interest4);
- const pit::OutRecordCollection& outRecords3 = entry.getOutRecords();
+ const OutRecordCollection& outRecords3 = entry.getOutRecords();
BOOST_CHECK_EQUAL(outRecords3.size(), 2);
BOOST_CHECK_EQUAL(out2->getFace(), face2);
- // get OutRecord
- pit::OutRecordCollection::const_iterator out3 = entry.getOutRecord(*face1);
- BOOST_REQUIRE(out3 != entry.getOutRecords().end());
+ // get out-record
+ OutRecordCollection::iterator out3 = entry.getOutRecord(*face1);
+ BOOST_REQUIRE(out3 != entry.out_end());
BOOST_CHECK_EQUAL(out3->getFace(), face1);
- // delete OutRecord
+ // delete out-record
entry.deleteOutRecord(*face2);
- const pit::OutRecordCollection& outRecords4 = entry.getOutRecords();
+ const OutRecordCollection& outRecords4 = entry.getOutRecords();
BOOST_REQUIRE_EQUAL(outRecords4.size(), 1);
BOOST_CHECK_EQUAL(outRecords4.begin()->getFace(), face1);
- BOOST_CHECK(entry.getOutRecord(*face2) == entry.getOutRecords().end());
+ BOOST_CHECK(entry.getOutRecord(*face2) == entry.out_end());
}
BOOST_AUTO_TEST_CASE(Lifetime)
@@ -161,19 +157,19 @@
BOOST_ASSERT(interest->getInterestLifetime() < time::milliseconds::zero());
shared_ptr<Face> face = make_shared<DummyFace>();
- pit::Entry entry(*interest);
+ Entry entry(*interest);
- pit::InRecordCollection::iterator inIt = entry.insertOrUpdateInRecord(face, *interest);
+ InRecordCollection::iterator inIt = entry.insertOrUpdateInRecord(face, *interest);
BOOST_CHECK_GT(inIt->getExpiry(), time::steady_clock::now());
- pit::OutRecordCollection::iterator outIt = entry.insertOrUpdateOutRecord(face, *interest);
+ OutRecordCollection::iterator outIt = entry.insertOrUpdateOutRecord(face, *interest);
BOOST_CHECK_GT(outIt->getExpiry(), time::steady_clock::now());
}
BOOST_AUTO_TEST_CASE(OutRecordNack)
{
shared_ptr<Face> face1 = make_shared<DummyFace>();
- pit::OutRecord outR(face1);
+ OutRecord outR(face1);
BOOST_CHECK(outR.getIncomingNack() == nullptr);
shared_ptr<Interest> interest1 = makeInterest("ndn:/uWiapGjYL");
@@ -215,7 +211,7 @@
NameTree nameTree(16);
Pit pit(nameTree);
BOOST_CHECK_EQUAL(pit.size(), 0);
- std::pair<shared_ptr<pit::Entry>, bool> insertResult;
+ std::pair<shared_ptr<Entry>, bool> insertResult;
// base
shared_ptr<Interest> interestA = make_shared<Interest>(name1);
@@ -315,7 +311,7 @@
NameTree nameTree(16);
Pit pit(nameTree);
- std::pair<shared_ptr<pit::Entry>, bool> insertResult;
+ std::pair<shared_ptr<Entry>, bool> insertResult;
BOOST_CHECK_EQUAL(pit.size(), 0);
@@ -346,7 +342,7 @@
size_t nNameTreeEntriesBefore = nameTree.size();
shared_ptr<Interest> interest = makeInterest("/37xWVvQ2K");
- shared_ptr<pit::Entry> entry = pit.insert(*interest).first;
+ shared_ptr<Entry> entry = pit.insert(*interest).first;
pit.erase(entry);
BOOST_CHECK_EQUAL(nameTree.size(), nNameTreeEntriesBefore);
}
@@ -379,14 +375,14 @@
shared_ptr<Data> data = makeData(nameABCD);
- pit::DataMatchResult matches = pit.findAllDataMatches(*data);
+ DataMatchResult matches = pit.findAllDataMatches(*data);
bool hasA = false;
bool hasAB = false;
bool hasABC = false;
bool hasD = false;
- for (const shared_ptr<pit::Entry>& entry : matches) {
+ for (const shared_ptr<Entry>& entry : matches) {
++count;
if (entry->getName().equals(nameA ))
@@ -419,10 +415,10 @@
shared_ptr<Interest> interest = makeInterest(fullName);
pit.insert(*interest);
- pit::DataMatchResult matches = pit.findAllDataMatches(*data);
+ DataMatchResult matches = pit.findAllDataMatches(*data);
BOOST_REQUIRE_EQUAL(std::distance(matches.begin(), matches.end()), 1);
- shared_ptr<pit::Entry> found = *matches.begin();
+ shared_ptr<Entry> found = *matches.begin();
BOOST_CHECK_EQUAL(found->getName(), fullName);
}