Skip to content

Commit

Permalink
Add delegating constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
IsabelParedes committed Apr 15, 2024
1 parent 4bb5459 commit cc56080
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/xhook_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

#ifndef UVW_AS_LIB
#define UVW_AS_LIB
#include <uvw.hpp>
#endif
#include <uvw.hpp>

namespace xeus
{
Expand Down
2 changes: 1 addition & 1 deletion src/xserver_shell_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

#ifndef UVW_AS_LIB
#define UVW_AS_LIB
#include <uvw.hpp>
#endif
#include <uvw.hpp>

#include "zmq_addon.hpp"
#include "xeus/xguid.hpp"
Expand Down
6 changes: 3 additions & 3 deletions src/xserver_zmq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#include <memory>

#ifndef UVW_AS_LIB
#define UVW_AS_LIB
#include <uvw.hpp>
#endif

#include <memory>
#include <uvw.hpp>

#include "xeus-zmq/xserver_zmq.hpp"
#include "xserver_zmq_impl.hpp"
Expand Down
46 changes: 27 additions & 19 deletions src/xserver_zmq_split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@

#ifndef UVW_AS_LIB
#define UVW_AS_LIB
#include <uvw.hpp>
#endif
#include <uvw.hpp>

#include "zmq_addon.hpp"
#include "xeus/xguid.hpp"
#include "xeus-zmq/xmiddleware.hpp"
#include "xeus-zmq/xhook_base.hpp"
#include "xauthentication.hpp"
#include "xzmq_serializer.hpp"
#include "xserver_zmq_split.hpp"
Expand All @@ -34,38 +35,45 @@ namespace xeus
xserver_zmq_split::xserver_zmq_split(zmq::context_t& context,
const xconfiguration& config,
nl::json::error_handler_t eh)
: p_auth(make_xauthentication(config.m_signature_scheme, config.m_key))
, p_controller(new xcontrol(context, config.m_transport, config.m_ip ,config.m_control_port, this))
, p_heartbeat(new xheartbeat(context, config.m_transport, config.m_ip, config.m_hb_port))
, p_publisher(new xpublisher(context,
std::bind(&xserver_zmq_split::serialize_iopub, this, std::placeholders::_1),
config.m_transport, config.m_ip, config.m_iopub_port))
, p_shell(new xshell_default(context, config.m_transport, config.m_ip, config.m_shell_port, config.m_stdin_port, this))
, m_control_thread()
, m_hb_thread()
, m_iopub_thread()
, m_shell_thread()
, m_error_handler(eh)
, m_control_stopped(false)
: xserver_zmq_split(context, config, eh,
std::move(std::make_unique<xshell_default>(context,
config.m_transport,
config.m_ip,
config.m_shell_port,
config.m_stdin_port,
this)))
{
p_controller->connect_messenger();
}

// In the case where an event loop is provided
xserver_zmq_split::xserver_zmq_split(zmq::context_t& context,
const xconfiguration& config,
nl::json::error_handler_t eh,
std::shared_ptr<uvw::loop> loop_ptr,
std::unique_ptr<xhook_base> hook)
: xserver_zmq_split(context, config, eh,
std::move(std::make_unique<xshell_uv>(context,
config.m_transport,
config.m_ip,
config.m_shell_port,
config.m_stdin_port,
this,
loop_ptr,
std::move(hook))))
{
}

// Delegating constructor
xserver_zmq_split::xserver_zmq_split(zmq::context_t& context,
const xconfiguration& config,
nl::json::error_handler_t eh,
shell_ptr shell)
: p_auth(make_xauthentication(config.m_signature_scheme, config.m_key))
, p_controller(new xcontrol(context, config.m_transport, config.m_ip ,config.m_control_port, this))
, p_heartbeat(new xheartbeat(context, config.m_transport, config.m_ip, config.m_hb_port))
, p_publisher(new xpublisher(context,
std::bind(&xserver_zmq_split::serialize_iopub, this, std::placeholders::_1),
config.m_transport, config.m_ip, config.m_iopub_port))
, p_shell(new xshell_uv(context, config.m_transport, config.m_ip,
config.m_shell_port, config.m_stdin_port, this,
loop_ptr, std::move(hook)))
, p_shell(std::move(shell))
, m_control_thread()
, m_hb_thread()
, m_iopub_thread()
Expand Down
7 changes: 6 additions & 1 deletion src/xserver_zmq_split.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ namespace xeus
const xconfiguration& config,
nl::json::error_handler_t eh);

// In the case where an event loop is provided
xserver_zmq_split(zmq::context_t& context,
const xconfiguration& config,
nl::json::error_handler_t eh,
Expand Down Expand Up @@ -96,6 +95,12 @@ namespace xeus

private:

// Delegating constructor
xserver_zmq_split(zmq::context_t& context,
const xconfiguration& config,
nl::json::error_handler_t eh,
shell_ptr shell);

virtual void start_server(zmq::multipart_t& wire_msg) = 0;

using authentication_ptr = std::unique_ptr<xauthentication>;
Expand Down
2 changes: 1 addition & 1 deletion src/xshell_uv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

#ifndef UVW_AS_LIB
#define UVW_AS_LIB
#include <uvw.hpp>
#endif
#include <uvw.hpp>

#include "xshell_uv.hpp"
#include "xserver_zmq_split.hpp"
Expand Down

0 comments on commit cc56080

Please sign in to comment.