Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
IsabelParedes committed Mar 13, 2024
1 parent 08c7f07 commit 304a36a
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 45 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ set(XEUS_ZMQ_HEADERS
${XEUS_ZMQ_INCLUDE_DIR}/xeus-zmq/xthread.hpp
${XEUS_ZMQ_INCLUDE_DIR}/xeus-zmq/xzmq_context.hpp
${XEUS_ZMQ_INCLUDE_DIR}/xeus-zmq/xzmq_serializer.hpp
${XEUS_ZMQ_INCLUDE_DIR}/xeus-zmq/hook_base.hpp
${XEUS_ZMQ_INCLUDE_DIR}/xeus-zmq/xhook_base.hpp
)

set(XEUS_ZMQ_SOURCES
Expand Down
28 changes: 0 additions & 28 deletions include/xeus-zmq/hook_base.hpp

This file was deleted.

37 changes: 37 additions & 0 deletions include/xeus-zmq/xhook_base.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/***************************************************************************
* Copyright (c) 2016, Johan Mabille, Sylvain Corlay, Martin Renou *
* Copyright (c) 2016, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XHOOK_BASE_HPP
#define XHOOK_BASE_HPP

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

namespace xeus
{
class xhook_base
{
public:

virtual ~xhook_base() = default;

virtual void pre_hook() = 0;
virtual void post_hook() = 0;

virtual void run(std::shared_ptr<uvw::loop> loop)
{
loop->run();
};

};
}

#endif
4 changes: 2 additions & 2 deletions include/xeus-zmq/xserver_zmq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "xeus/xserver.hpp"

#include "xeus-zmq.hpp"
#include "hook_base.hpp"
#include "xhook_base.hpp"

namespace xeus
{
Expand Down Expand Up @@ -78,7 +78,7 @@ namespace xeus
const xconfiguration& config,
nl::json::error_handler_t eh = nl::json::error_handler_t::strict,
std::shared_ptr<uvw::loop> loop_ptr = nullptr,
std::unique_ptr<hook_base> hook = nullptr);
std::unique_ptr<xhook_base> hook = nullptr);

}

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 @@ -36,7 +36,7 @@ namespace xeus
const xconfiguration& config,
nl::json::error_handler_t eh,
std::shared_ptr<uvw::loop> loop_ptr,
std::unique_ptr<hook_base> hook)
std::unique_ptr<xhook_base> hook)
: xserver_zmq_split(context, config, eh, loop_ptr, std::move(hook))
{
}
Expand Down
4 changes: 2 additions & 2 deletions src/xserver_shell_main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "xeus-zmq/xeus-zmq.hpp"
#include "xserver_zmq_split.hpp"
#include "xeus-zmq/hook_base.hpp"
#include "xeus-zmq/xhook_base.hpp"

namespace xeus
{
Expand All @@ -37,7 +37,7 @@ namespace xeus
const xconfiguration& config,
nl::json::error_handler_t he,
std::shared_ptr<uvw::loop> loop_ptr,
std::unique_ptr<hook_base> hook);
std::unique_ptr<xhook_base> hook);

virtual ~xserver_shell_main();

Expand Down
2 changes: 1 addition & 1 deletion src/xserver_zmq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ namespace xeus
const xconfiguration& config,
nl::json::error_handler_t eh,
std::shared_ptr<uvw::loop> loop_ptr,
std::unique_ptr<hook_base> hook)
std::unique_ptr<xhook_base> hook)
{
auto impl = std::make_unique<xserver_shell_main>(
context.get_wrapped_context<zmq::context_t>(), config, eh, loop_ptr, std::move(hook));
Expand Down
2 changes: 1 addition & 1 deletion src/xserver_zmq_split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace xeus
const xconfiguration& config,
nl::json::error_handler_t eh,
std::shared_ptr<uvw::loop> loop_ptr,
std::unique_ptr<hook_base> hook)
std::unique_ptr<xhook_base> hook)
: 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))
Expand Down
4 changes: 2 additions & 2 deletions src/xserver_zmq_split.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "xeus-zmq/xeus-zmq.hpp"
#include "xeus-zmq/xthread.hpp"
#include "xeus-zmq/hook_base.hpp"
#include "xeus-zmq/xhook_base.hpp"

#include "xserver_zmq_impl.hpp"

Expand Down Expand Up @@ -53,7 +53,7 @@ namespace xeus
const xconfiguration& config,
nl::json::error_handler_t eh,
std::shared_ptr<uvw::loop> loop_ptr,
std::unique_ptr<hook_base> hook);
std::unique_ptr<xhook_base> hook);

~xserver_zmq_split() override;

Expand Down
5 changes: 1 addition & 4 deletions src/xshell_uv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
****************************************************************************/

#include <memory>
#include <iostream>

#ifndef UVW_AS_LIB
#define UVW_AS_LIB
Expand All @@ -27,7 +26,7 @@ namespace xeus
const std::string& stdin_port,
xserver_zmq_split* server,
std::shared_ptr<uvw::loop> loop_ptr,
std::unique_ptr<hook_base> hook)
std::unique_ptr<xhook_base> hook)
: xshell_base(context, transport, ip, shell_port, stdin_port, server)
, p_loop{loop_ptr}
, p_hook{std::move(hook)}
Expand Down Expand Up @@ -114,10 +113,8 @@ namespace xeus

if (p_hook)
{
std::cout << "Running PPP hook\n";
p_hook->run(p_loop);
} else {
std::cout << "Running normal loop\n";
p_loop->run();
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/xshell_uv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#endif

#include "xshell_base.hpp"
#include "xeus-zmq/hook_base.hpp"
#include "xeus-zmq/xhook_base.hpp"

namespace xeus
{
Expand All @@ -35,7 +35,7 @@ namespace xeus
const std::string& stdin_port,
xserver_zmq_split* server,
std::shared_ptr<uvw::loop> loop_ptr,
std::unique_ptr<hook_base> hook);
std::unique_ptr<xhook_base> hook);

~xshell_uv();

Expand All @@ -48,7 +48,7 @@ namespace xeus
std::shared_ptr<uvw::loop> p_loop{ nullptr };
std::shared_ptr<uvw::poll_handle> p_shell_poll{ nullptr };
std::shared_ptr<uvw::poll_handle> p_controller_poll{ nullptr };
std::unique_ptr<hook_base> p_hook{ nullptr };
std::unique_ptr<xhook_base> p_hook{ nullptr };
};

} // namespace xeus
Expand Down

0 comments on commit 304a36a

Please sign in to comment.