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>