face: move isListening()/size() to Channel as pure virtual methods
As a side effect, this ensures that Channel cannot be instantiated.
Change-Id: I875876ddf8fc0fbb04f3e88726c708ece8106702
diff --git a/daemon/face/unix-stream-channel.hpp b/daemon/face/unix-stream-channel.hpp
index 1916134..8f30db5 100644
--- a/daemon/face/unix-stream-channel.hpp
+++ b/daemon/face/unix-stream-channel.hpp
@@ -48,9 +48,14 @@
/**
* \brief UnixStreamChannel-related error
*/
- struct Error : public std::runtime_error
+ class Error : public std::runtime_error
{
- Error(const std::string& what) : std::runtime_error(what) {}
+ public:
+ explicit
+ Error(const std::string& what)
+ : std::runtime_error(what)
+ {
+ }
};
/**
@@ -64,6 +69,18 @@
~UnixStreamChannel() override;
+ bool
+ isListening() const override
+ {
+ return m_acceptor.is_open();
+ }
+
+ size_t
+ size() const override
+ {
+ return m_size;
+ }
+
/**
* \brief Enable listening on the local endpoint, accept connections,
* and create faces when a connection is made
@@ -78,9 +95,6 @@
const FaceCreationFailedCallback& onAcceptFailed,
int backlog = boost::asio::local::stream_protocol::acceptor::max_connections);
- bool
- isListening() const;
-
private:
void
accept(const FaceCreatedCallback& onFaceCreated,
@@ -95,14 +109,9 @@
unix_stream::Endpoint m_endpoint;
boost::asio::local::stream_protocol::acceptor m_acceptor;
boost::asio::local::stream_protocol::socket m_socket;
+ size_t m_size;
};
-inline bool
-UnixStreamChannel::isListening() const
-{
- return m_acceptor.is_open();
-}
-
} // namespace face
} // namespace nfd