table: pit::FaceRecord stores Face& instead of shared_ptr
refs #3164
Change-Id: Ib23ab2341a37213fee791f2070f13b76da851d53
diff --git a/daemon/table/pit-entry.cpp b/daemon/table/pit-entry.cpp
index d19369a..395fc90 100644
--- a/daemon/table/pit-entry.cpp
+++ b/daemon/table/pit-entry.cpp
@@ -38,14 +38,14 @@
Entry::getInRecord(const Face& face)
{
return std::find_if(m_inRecords.begin(), m_inRecords.end(),
- [&face] (const InRecord& inRecord) { return inRecord.getFace().get() == &face; });
+ [&face] (const InRecord& inRecord) { return &inRecord.getFace() == &face; });
}
InRecordCollection::iterator
-Entry::insertOrUpdateInRecord(shared_ptr<Face> face, const Interest& interest)
+Entry::insertOrUpdateInRecord(Face& face, const Interest& interest)
{
auto it = std::find_if(m_inRecords.begin(), m_inRecords.end(),
- [&face] (const InRecord& inRecord) { return inRecord.getFace() == face; });
+ [&face] (const InRecord& inRecord) { return &inRecord.getFace() == &face; });
if (it == m_inRecords.end()) {
m_inRecords.emplace_front(face);
it = m_inRecords.begin();
@@ -59,7 +59,7 @@
Entry::deleteInRecord(const Face& face)
{
auto it = std::find_if(m_inRecords.begin(), m_inRecords.end(),
- [&face] (const InRecord& inRecord) { return inRecord.getFace().get() == &face; });
+ [&face] (const InRecord& inRecord) { return &inRecord.getFace() == &face; });
if (it != m_inRecords.end()) {
m_inRecords.erase(it);
}
@@ -75,14 +75,14 @@
Entry::getOutRecord(const Face& face)
{
return std::find_if(m_outRecords.begin(), m_outRecords.end(),
- [&face] (const OutRecord& outRecord) { return outRecord.getFace().get() == &face; });
+ [&face] (const OutRecord& outRecord) { return &outRecord.getFace() == &face; });
}
OutRecordCollection::iterator
-Entry::insertOrUpdateOutRecord(shared_ptr<Face> face, const Interest& interest)
+Entry::insertOrUpdateOutRecord(Face& face, const Interest& interest)
{
auto it = std::find_if(m_outRecords.begin(), m_outRecords.end(),
- [&face] (const OutRecord& outRecord) { return outRecord.getFace() == face; });
+ [&face] (const OutRecord& outRecord) { return &outRecord.getFace() == &face; });
if (it == m_outRecords.end()) {
m_outRecords.emplace_front(face);
it = m_outRecords.begin();
@@ -96,7 +96,7 @@
Entry::deleteOutRecord(const Face& face)
{
auto it = std::find_if(m_outRecords.begin(), m_outRecords.end(),
- [&face] (const OutRecord& outRecord) { return outRecord.getFace().get() == &face; });
+ [&face] (const OutRecord& outRecord) { return &outRecord.getFace() == &face; });
if (it != m_outRecords.end()) {
m_outRecords.erase(it);
}
diff --git a/daemon/table/pit-entry.hpp b/daemon/table/pit-entry.hpp
index 5f77a4d..99832ad 100644
--- a/daemon/table/pit-entry.hpp
+++ b/daemon/table/pit-entry.hpp
@@ -111,7 +111,7 @@
* \return an iterator to the new or updated in-record
*/
InRecordCollection::iterator
- insertOrUpdateInRecord(shared_ptr<Face> face, const Interest& interest);
+ insertOrUpdateInRecord(Face& face, const Interest& interest);
/** \brief delete the in-record for \p face if it exists
*/
@@ -160,7 +160,7 @@
* \return an iterator to the new or updated out-record
*/
OutRecordCollection::iterator
- insertOrUpdateOutRecord(shared_ptr<Face> face, const Interest& interest);
+ insertOrUpdateOutRecord(Face& face, const Interest& interest);
/** \brief delete the out-record for \p face if it exists
*/
diff --git a/daemon/table/pit-face-record.cpp b/daemon/table/pit-face-record.cpp
index c62a1b5..d594cb9 100644
--- a/daemon/table/pit-face-record.cpp
+++ b/daemon/table/pit-face-record.cpp
@@ -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.
@@ -28,7 +28,7 @@
namespace nfd {
namespace pit {
-FaceRecord::FaceRecord(shared_ptr<Face> face)
+FaceRecord::FaceRecord(Face& face)
: m_face(face)
, m_lastNonce(0)
, m_lastRenewed(time::steady_clock::TimePoint::min())
diff --git a/daemon/table/pit-face-record.hpp b/daemon/table/pit-face-record.hpp
index c1d6c77..90c3cdb 100644
--- a/daemon/table/pit-face-record.hpp
+++ b/daemon/table/pit-face-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.
@@ -41,9 +41,9 @@
{
public:
explicit
- FaceRecord(shared_ptr<Face> face);
+ FaceRecord(Face& face);
- shared_ptr<Face>
+ Face&
getFace() const;
uint32_t
@@ -64,13 +64,13 @@
update(const Interest& interest);
private:
- shared_ptr<Face> m_face;
+ Face& m_face;
uint32_t m_lastNonce;
time::steady_clock::TimePoint m_lastRenewed;
time::steady_clock::TimePoint m_expiry;
};
-inline shared_ptr<Face>
+inline Face&
FaceRecord::getFace() const
{
return m_face;
diff --git a/daemon/table/pit-in-record.cpp b/daemon/table/pit-in-record.cpp
index b7f0edf..8167190 100644
--- a/daemon/table/pit-in-record.cpp
+++ b/daemon/table/pit-in-record.cpp
@@ -1,11 +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
+ * 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.
@@ -20,14 +21,14 @@
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
#include "pit-in-record.hpp"
namespace nfd {
namespace pit {
-InRecord::InRecord(shared_ptr<Face> face)
+InRecord::InRecord(Face& face)
: FaceRecord(face)
{
}
diff --git a/daemon/table/pit-in-record.hpp b/daemon/table/pit-in-record.hpp
index dd6ad06..45167c3 100644
--- a/daemon/table/pit-in-record.hpp
+++ b/daemon/table/pit-in-record.hpp
@@ -37,7 +37,7 @@
{
public:
explicit
- InRecord(shared_ptr<Face> face);
+ InRecord(Face& face);
void
update(const Interest& interest);
diff --git a/daemon/table/pit-out-record.cpp b/daemon/table/pit-out-record.cpp
index 1cf303d..8b4f609 100644
--- a/daemon/table/pit-out-record.cpp
+++ b/daemon/table/pit-out-record.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,
@@ -28,7 +28,7 @@
namespace nfd {
namespace pit {
-OutRecord::OutRecord(shared_ptr<Face> face)
+OutRecord::OutRecord(Face& face)
: FaceRecord(face)
{
}
diff --git a/daemon/table/pit-out-record.hpp b/daemon/table/pit-out-record.hpp
index 4717779..4400fd4 100644
--- a/daemon/table/pit-out-record.hpp
+++ b/daemon/table/pit-out-record.hpp
@@ -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,
@@ -37,7 +37,7 @@
{
public:
explicit
- OutRecord(shared_ptr<Face> face);
+ OutRecord(Face& face);
/** \return last NACK returned by \p getFace()
*