fw: FaceTable::get returns Face* instead of shared_ptr
refs #3205
Change-Id: I1c61493382fe065389266ff3519ab2b265fe4f79
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index b8506ac..ac9085c 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -150,9 +150,9 @@
const ControlParameters& parameters,
const ndn::mgmt::CommandContinuation& done)
{
- shared_ptr<Face> target = m_faceTable.get(parameters.getFaceId());
- if (target) {
- target->close();
+ Face* face = m_faceTable.get(parameters.getFaceId());
+ if (face != nullptr) {
+ face->close();
}
done(ControlResponse(200, "OK").setBody(parameters.wireEncode()));
@@ -228,7 +228,7 @@
// and is initialized synchronously with IncomingFaceId field enabled.
BOOST_ASSERT(incomingFaceIdTag != nullptr);
- auto face = m_faceTable.get(*incomingFaceIdTag);
+ Face* face = m_faceTable.get(*incomingFaceIdTag);
if (face == nullptr) {
NFD_LOG_DEBUG("FaceId " << *incomingFaceIdTag << " not found");
done(ControlResponse(410, "Face not found"));
@@ -241,7 +241,7 @@
return nullptr;
}
- return face.get();
+ return face;
}
void
diff --git a/daemon/mgmt/fib-manager.cpp b/daemon/mgmt/fib-manager.cpp
index b7ac209..1c15ebf 100644
--- a/daemon/mgmt/fib-manager.cpp
+++ b/daemon/mgmt/fib-manager.cpp
@@ -24,6 +24,7 @@
*/
#include "fib-manager.hpp"
+#include "fw/face-table.hpp"
#include <ndn-cxx/management/nfd-fib-entry.hpp>
namespace nfd {
@@ -31,12 +32,12 @@
NFD_LOG_INIT("FibManager");
FibManager::FibManager(Fib& fib,
- function<shared_ptr<Face>(FaceId)> getFace,
+ const FaceTable& faceTable,
Dispatcher& dispatcher,
CommandValidator& validator)
: NfdManagerBase(dispatcher, validator, "fib")
, m_fib(fib)
- , m_getFace(getFace)
+ , m_faceTable(faceTable)
{
registerCommandHandler<ndn::nfd::FibAddNextHopCommand>("add-nexthop",
bind(&FibManager::addNextHop, this, _2, _3, _4, _5));
@@ -61,7 +62,7 @@
<< " faceid: " << faceId
<< " cost: " << cost);
- shared_ptr<Face> face = m_getFace(faceId);
+ Face* face = m_faceTable.get(faceId);
if (face != nullptr) {
fib::Entry* entry = m_fib.insert(prefix).first;
entry->addNextHop(*face, cost);
@@ -89,7 +90,7 @@
NFD_LOG_TRACE("remove-nexthop prefix: " << parameters.getName()
<< " faceid: " << parameters.getFaceId());
- shared_ptr<Face> face = m_getFace(parameters.getFaceId());
+ Face* face = m_faceTable.get(parameters.getFaceId());
if (face != nullptr) {
fib::Entry* entry = m_fib.findExactMatch(parameters.getName());
if (entry != nullptr) {
diff --git a/daemon/mgmt/fib-manager.hpp b/daemon/mgmt/fib-manager.hpp
index 94300cb..9599a01 100644
--- a/daemon/mgmt/fib-manager.hpp
+++ b/daemon/mgmt/fib-manager.hpp
@@ -33,6 +33,8 @@
namespace nfd {
+class FaceTable;
+
/**
* @brief implement the FIB Management of NFD Management Protocol.
* @sa http://redmine.named-data.net/projects/nfd/wiki/FibMgmt
@@ -44,12 +46,12 @@
* @brief construct a FibManger
*
* @param fib the managed FIB
- * @param getFace a function used to retrive a face by FaceId from the face table
+ * @param faceTable FaceTable for querying available faces
* @param dispatcher the management dispatcher
* @param validator the command validator
*/
FibManager(Fib& fib,
- function<shared_ptr<Face>(FaceId)> getFace,
+ const FaceTable& faceTable,
Dispatcher& dispatcher,
CommandValidator& validator);
@@ -74,7 +76,7 @@
private:
Fib& m_fib;
- function<shared_ptr<Face>(FaceId)> m_getFace;
+ const FaceTable& m_faceTable;
};
} // namespace nfd