diff --git a/libmuscle/cpp/src/libmuscle/mcp/tcp_transport_server.cpp b/libmuscle/cpp/src/libmuscle/mcp/tcp_transport_server.cpp index 98d52361..936305bf 100644 --- a/libmuscle/cpp/src/libmuscle/mcp/tcp_transport_server.cpp +++ b/libmuscle/cpp/src/libmuscle/mcp/tcp_transport_server.cpp @@ -284,7 +284,7 @@ class TcpTransportServerWorker { namespace libmuscle { namespace _MUSCLE_IMPL_NS { namespace mcp { TcpTransportServer::TcpTransportServer(RequestHandler & handler) - : TransportServer(handler) + : TransportServerBase(handler) { pipe(control_pipe_); thread_ = std::thread(server_thread_, this); diff --git a/libmuscle/cpp/src/libmuscle/mcp/tcp_transport_server.hpp b/libmuscle/cpp/src/libmuscle/mcp/tcp_transport_server.hpp index 933077c6..a3b5f690 100644 --- a/libmuscle/cpp/src/libmuscle/mcp/tcp_transport_server.hpp +++ b/libmuscle/cpp/src/libmuscle/mcp/tcp_transport_server.hpp @@ -16,7 +16,7 @@ namespace libmuscle { namespace _MUSCLE_IMPL_NS { namespace mcp { /** A server that accepts TCP connections. */ -class TcpTransportServer : public TransportServer { +class TcpTransportServer : public TransportServerBase { public: /** Create a TcpTransportServer. * diff --git a/libmuscle/cpp/src/libmuscle/mcp/transport_server.cpp b/libmuscle/cpp/src/libmuscle/mcp/transport_server.cpp index 3337bad8..d5ff4575 100644 --- a/libmuscle/cpp/src/libmuscle/mcp/transport_server.cpp +++ b/libmuscle/cpp/src/libmuscle/mcp/transport_server.cpp @@ -6,7 +6,7 @@ namespace libmuscle { namespace _MUSCLE_IMPL_NS {namespace mcp { RequestHandler::~RequestHandler() {} -TransportServer::TransportServer(RequestHandler & handler) +TransportServerBase::TransportServerBase(RequestHandler & handler) : handler_(handler) {} diff --git a/libmuscle/cpp/src/libmuscle/mcp/transport_server.hpp b/libmuscle/cpp/src/libmuscle/mcp/transport_server.hpp index d3f7f052..d4118848 100644 --- a/libmuscle/cpp/src/libmuscle/mcp/transport_server.hpp +++ b/libmuscle/cpp/src/libmuscle/mcp/transport_server.hpp @@ -64,12 +64,6 @@ class RequestHandler { */ class TransportServer { public: - /** Create a TransportServer. - * - * @param handler: A handler to handle requests - */ - TransportServer(RequestHandler & handler); - /** Destroy the Transport Server object */ virtual ~TransportServer() = default; @@ -86,6 +80,21 @@ class TransportServer { * then frees any other resources. */ virtual void close() = 0; +}; + + +/** Base class for TransportServers. + * + * They always have a handler, so this saves some typing. This is separate from the + * interface so that we can create a mock that doesn't have the reference. + */ +class TransportServerBase : public TransportServer { + public: + /** Create a TransportServerBase. + * + * @param handler: A handler to handle requests + */ + TransportServerBase(RequestHandler & handler); protected: RequestHandler & handler_;