face: remove awkward Face::setLocal, use a constructor argument instead.
Change-Id: Ic366ecdc83c5771138ff584ffb944a4e17300eb1
diff --git a/daemon/face/ethernet-face.cpp b/daemon/face/ethernet-face.cpp
index a6e089f..2d3b8e3 100644
--- a/daemon/face/ethernet-face.cpp
+++ b/daemon/face/ethernet-face.cpp
@@ -38,7 +38,6 @@
, m_interface(interface)
, m_destAddress(address)
{
- setLocal(false);
pcapInit();
int fd = pcap_get_selectable_fd(m_pcap);
diff --git a/daemon/face/face.cpp b/daemon/face/face.cpp
index cc4fba8..8e81217 100644
--- a/daemon/face/face.cpp
+++ b/daemon/face/face.cpp
@@ -9,10 +9,11 @@
namespace nfd {
-NFD_LOG_INIT("Face");
+NFD_LOG_INIT("Face")
-Face::Face()
+Face::Face(bool isLocal)
: m_id(INVALID_FACEID)
+ , m_isLocal(isLocal)
{
}
@@ -33,26 +34,6 @@
m_id = faceId;
}
-bool
-Face::isLocal() const
-{
- return m_isLocal;
-}
-
-// this method is protected and can be used only in derived class
-// to set localhost scope
-void
-Face::setLocal(bool isLocal)
-{
- m_isLocal = isLocal;
-}
-
-bool
-Face::isUp() const
-{
- return true;
-}
-
void
Face::setDescription(const std::string& description)
{
@@ -72,6 +53,12 @@
}
bool
+Face::isUp() const
+{
+ return true;
+}
+
+bool
Face::decodeAndDispatchInput(const Block& element)
{
/// \todo Ensure lazy field decoding process
diff --git a/daemon/face/face.hpp b/daemon/face/face.hpp
index 45cde49..325ad67 100644
--- a/daemon/face/face.hpp
+++ b/daemon/face/face.hpp
@@ -20,7 +20,7 @@
const FaceId INVALID_FACEID = -1;
-const std::size_t MAX_NDN_PACKET_SIZE = 8800;
+const size_t MAX_NDN_PACKET_SIZE = 8800;
/** \brief represents a face
@@ -36,7 +36,8 @@
Error(const std::string& what) : std::runtime_error(what) {}
};
- Face();
+ explicit
+ Face(bool isLocal = false);
virtual
~Face();
@@ -69,21 +70,6 @@
virtual void
close() = 0;
- /** \brief Get whether underlying communication is up
- *
- * In this base class this property is always true.
- */
- virtual bool
- isUp() const;
-
- /** \brief Get whether face is connected to a local app
- *
- * False by default and can become true if a derived class, implementing
- * one of the local face types, explicitly calls Face::setLocal(true)
- */
- bool
- isLocal() const;
-
/** \brief Set the description
*
* This is typically invoked by mgmt on set description command
@@ -95,6 +81,11 @@
virtual const std::string&
getDescription() const;
+ /** \brief Get whether face is connected to a local app
+ */
+ bool
+ isLocal() const;
+
/** \brief Get whether packets sent this Face may reach multiple peers
*
* In this base class this property is always false.
@@ -102,13 +93,17 @@
virtual bool
isMultiAccess() const;
+ /** \brief Get whether underlying communication is up
+ *
+ * In this base class this property is always true.
+ */
+ virtual bool
+ isUp() const;
+
const FaceCounters&
getCounters() const;
protected:
- void
- setLocal(bool isLocal);
-
// this is a non-virtual method
bool
decodeAndDispatchInput(const Block& element);
@@ -131,6 +126,12 @@
};
+inline bool
+Face::isLocal() const
+{
+ return m_isLocal;
+}
+
inline const FaceCounters&
Face::getCounters() const
{
diff --git a/daemon/face/local-face.hpp b/daemon/face/local-face.hpp
index 6175b5d..b7d973a 100644
--- a/daemon/face/local-face.hpp
+++ b/daemon/face/local-face.hpp
@@ -82,9 +82,9 @@
inline
LocalFace::LocalFace()
- : m_localControlHeaderFeatures(LOCAL_CONTROL_HEADER_FEATURE_MAX)
+ : Face(true)
+ , m_localControlHeaderFeatures(LOCAL_CONTROL_HEADER_FEATURE_MAX)
{
- setLocal(true);
}
inline bool
diff --git a/daemon/face/stream-face.hpp b/daemon/face/stream-face.hpp
index 9baef1d..db37660 100644
--- a/daemon/face/stream-face.hpp
+++ b/daemon/face/stream-face.hpp
@@ -24,6 +24,7 @@
/**
* \brief Create instance of StreamFace
*/
+ explicit
StreamFace(const shared_ptr<typename protocol::socket>& socket);
virtual
diff --git a/daemon/mgmt/internal-face.cpp b/daemon/mgmt/internal-face.cpp
index 707ee30..a6c116b 100644
--- a/daemon/mgmt/internal-face.cpp
+++ b/daemon/mgmt/internal-face.cpp
@@ -11,8 +11,8 @@
NFD_LOG_INIT("InternalFace");
InternalFace::InternalFace()
+ : Face(true)
{
- setLocal(true);
}
void