table: PIT entry InRecord/OutRecord getters

refs #1569

Change-Id: I52d9516fa6154036904e163f918890579a745e4f
diff --git a/daemon/table/pit-entry.cpp b/daemon/table/pit-entry.cpp
index e607dba..6fc34de 100644
--- a/daemon/table/pit-entry.cpp
+++ b/daemon/table/pit-entry.cpp
@@ -148,6 +148,13 @@
   return it;
 }
 
+InRecordCollection::const_iterator
+Entry::getInRecord(shared_ptr<Face> face) const
+{
+  return std::find_if(m_inRecords.begin(), m_inRecords.end(),
+                      bind(&predicate_FaceRecord_Face, _1, face.get()));
+}
+
 void
 Entry::deleteInRecords()
 {
@@ -169,6 +176,13 @@
   return it;
 }
 
+OutRecordCollection::const_iterator
+Entry::getOutRecord(shared_ptr<Face> face) const
+{
+  return std::find_if(m_outRecords.begin(), m_outRecords.end(),
+                      bind(&predicate_FaceRecord_Face, _1, face.get()));
+}
+
 void
 Entry::deleteOutRecord(shared_ptr<Face> face)
 {
diff --git a/daemon/table/pit-entry.hpp b/daemon/table/pit-entry.hpp
index c419f78..521671d 100644
--- a/daemon/table/pit-entry.hpp
+++ b/daemon/table/pit-entry.hpp
@@ -39,13 +39,11 @@
 
 namespace pit {
 
-/** \class InRecordCollection
- *  \brief represents an unordered collection of InRecords
+/** \brief represents an unordered collection of InRecords
  */
 typedef std::list< InRecord>  InRecordCollection;
 
-/** \class OutRecordCollection
- *  \brief represents an unordered collection of OutRecords
+/** \brief represents an unordered collection of OutRecords
  */
 typedef std::list<OutRecord> OutRecordCollection;
 
@@ -65,20 +63,6 @@
   const Name&
   getName() const;
 
-  const InRecordCollection&
-  getInRecords() const;
-
-  const OutRecordCollection&
-  getOutRecords() const;
-
-  /** \brief determines whether any InRecord is a local Face
-   *
-   *  \return true if any InRecord is a local Face,
-   *          false if all InRecords are non-local Faces
-   */
-  bool
-  hasLocalInRecord() const;
-
   /** \brief decides whether Interest can be forwarded to face
    *
    *  \return true if OutRecord of this face does not exist or has expired,
@@ -107,6 +91,18 @@
   bool
   addNonce(uint32_t nonce);
 
+public: // InRecord
+  const InRecordCollection&
+  getInRecords() const;
+
+  /** \brief determines whether any InRecord is a local Face
+   *
+   *  \return true if any InRecord is a local Face,
+   *          false if all InRecords are non-local Faces
+   */
+  bool
+  hasLocalInRecord() const;
+
   /** \brief inserts a InRecord for face, and updates it with interest
    *
    *  If InRecord for face exists, the existing one is updated.
@@ -116,10 +112,20 @@
   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
+   */
+  InRecordCollection::const_iterator
+  getInRecord(shared_ptr<Face> face) const;
+
   /// deletes all InRecords
   void
   deleteInRecords();
 
+public: // OutRecord
+  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.
@@ -128,6 +134,12 @@
   OutRecordCollection::iterator
   insertOrUpdateOutRecord(shared_ptr<Face> face, const Interest& interest);
 
+  /** \brief get the OutRecord for face
+   *  \return an iterator to the OutRecord, or .end if it does not exist
+   */
+  OutRecordCollection::const_iterator
+  getOutRecord(shared_ptr<Face> face) const;
+
   /// deletes one OutRecord for face if exists
   void
   deleteOutRecord(shared_ptr<Face> face);
diff --git a/daemon/table/pit-face-record.cpp b/daemon/table/pit-face-record.cpp
index 2102baf..a014e65 100644
--- a/daemon/table/pit-face-record.cpp
+++ b/daemon/table/pit-face-record.cpp
@@ -35,14 +35,6 @@
 {
 }
 
-FaceRecord::FaceRecord(const FaceRecord& other)
-  : m_face(other.m_face)
-  , m_lastNonce(other.m_lastNonce)
-  , m_lastRenewed(other.m_lastRenewed)
-  , m_expiry(other.m_expiry)
-{
-}
-
 void
 FaceRecord::update(const Interest& interest)
 {
diff --git a/daemon/table/pit-face-record.hpp b/daemon/table/pit-face-record.hpp
index a4cea26..1e0a720 100644
--- a/daemon/table/pit-face-record.hpp
+++ b/daemon/table/pit-face-record.hpp
@@ -43,8 +43,6 @@
   explicit
   FaceRecord(shared_ptr<Face> face);
 
-  FaceRecord(const FaceRecord& other);
-
   shared_ptr<Face>
   getFace() const;
 
diff --git a/daemon/table/pit-in-record.cpp b/daemon/table/pit-in-record.cpp
index 55df06b..b7f0edf 100644
--- a/daemon/table/pit-in-record.cpp
+++ b/daemon/table/pit-in-record.cpp
@@ -32,11 +32,6 @@
 {
 }
 
-InRecord::InRecord(const InRecord& other)
-  : FaceRecord(other)
-{
-}
-
 void
 InRecord::update(const Interest& interest)
 {
diff --git a/daemon/table/pit-in-record.hpp b/daemon/table/pit-in-record.hpp
index 95b90ba..88fa1f3 100644
--- a/daemon/table/pit-in-record.hpp
+++ b/daemon/table/pit-in-record.hpp
@@ -39,8 +39,6 @@
   explicit
   InRecord(shared_ptr<Face> face);
 
-  InRecord(const InRecord& other);
-
   void
   update(const Interest& interest);
 
diff --git a/daemon/table/pit-out-record.cpp b/daemon/table/pit-out-record.cpp
index 2e74e9c..268b67b 100644
--- a/daemon/table/pit-out-record.cpp
+++ b/daemon/table/pit-out-record.cpp
@@ -32,10 +32,5 @@
 {
 }
 
-OutRecord::OutRecord(const OutRecord& other)
-  : FaceRecord(other)
-{
-}
-
 } // namespace pit
 } // namespace nfd
diff --git a/daemon/table/pit-out-record.hpp b/daemon/table/pit-out-record.hpp
index 9b954e6..c75e005 100644
--- a/daemon/table/pit-out-record.hpp
+++ b/daemon/table/pit-out-record.hpp
@@ -38,8 +38,6 @@
 public:
   explicit
   OutRecord(shared_ptr<Face> face);
-
-  OutRecord(const OutRecord& other);
 };
 
 } // namespace pit
diff --git a/daemon/table/pit.hpp b/daemon/table/pit.hpp
index 48a267b..41cf520 100644
--- a/daemon/table/pit.hpp
+++ b/daemon/table/pit.hpp
@@ -58,8 +58,8 @@
   size_t
   size() const;
 
-  /** \brief inserts a FIB entry for prefix
-   *  If an entry for exact same prefix exists, that entry is returned.
+  /** \brief inserts a PIT entry for prefix
+   *  If an entry for exact same name and selectors exists, that entry is returned.
    *  \return{ the entry, and true for new entry, false for existing entry }
    */
   std::pair<shared_ptr<pit::Entry>, bool>
diff --git a/tests/daemon/table/pit.cpp b/tests/daemon/table/pit.cpp
index c77c909..d24bae9 100644
--- a/tests/daemon/table/pit.cpp
+++ b/tests/daemon/table/pit.cpp
@@ -76,6 +76,7 @@
   BOOST_CHECK_LE(in1->getExpiry() - in1->getLastRenewed()
                  - interest1->getInterestLifetime(),
                  (after1 - before1));
+  BOOST_CHECK(in1 == entry.getInRecord(face1));
 
   // insert OutRecord
   time::steady_clock::TimePoint before2 = time::steady_clock::now();
@@ -92,6 +93,7 @@
   BOOST_CHECK_LE(out1->getExpiry() - out1->getLastRenewed()
                  - interest1->getInterestLifetime(),
                  (after2 - before2));
+  BOOST_CHECK(out1 == entry.getOutRecord(face1));
 
   // update InRecord
   time::steady_clock::TimePoint before3 = time::steady_clock::now();
@@ -114,10 +116,16 @@
   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());
+  BOOST_CHECK_EQUAL(in4->getFace(), face1);
+
   // delete all InRecords
   entry.deleteInRecords();
   const pit::InRecordCollection& inRecords5 = entry.getInRecords();
   BOOST_CHECK_EQUAL(inRecords5.size(), 0);
+  BOOST_CHECK(entry.getInRecord(face1) == entry.getInRecords().end());
 
   // insert another OutRecord
   pit::OutRecordCollection::iterator out2 =
@@ -126,11 +134,17 @@
   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());
+  BOOST_CHECK_EQUAL(out3->getFace(), face1);
+
   // delete OutRecord
   entry.deleteOutRecord(face2);
   const pit::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_AUTO_TEST_CASE(EntryNonce)