From 7ee3d1058098e63f115c896c944221b6a546bf6e Mon Sep 17 00:00:00 2001 From: Isabel Paredes Date: Tue, 12 Mar 2024 18:27:32 +0100 Subject: [PATCH] Clean up --- CMakeLists.txt | 2 +- include/xeus-zmq/hook_base.hpp | 28 ------------------------ include/xeus-zmq/xhook_base.hpp | 37 ++++++++++++++++++++++++++++++++ include/xeus-zmq/xserver_zmq.hpp | 4 ++-- src/xserver_shell_main.cpp | 2 +- src/xserver_shell_main.hpp | 4 ++-- src/xserver_zmq.cpp | 2 +- src/xserver_zmq_split.cpp | 2 +- src/xserver_zmq_split.hpp | 4 ++-- src/xshell_uv.cpp | 4 +--- src/xshell_uv.hpp | 6 +++--- 11 files changed, 51 insertions(+), 44 deletions(-) delete mode 100644 include/xeus-zmq/hook_base.hpp create mode 100644 include/xeus-zmq/xhook_base.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 31b5ac1..6b16df6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/include/xeus-zmq/hook_base.hpp b/include/xeus-zmq/hook_base.hpp deleted file mode 100644 index 207eaa1..0000000 --- a/include/xeus-zmq/hook_base.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef HOOK_BASE_HPP -#define HOOK_BASE_HPP - -#ifndef UVW_AS_LIB -#define UVW_AS_LIB -#include -#endif - -namespace xeus -{ - class hook_base - { - public: - - virtual ~hook_base() = default; - - virtual void pre_hook() = 0; - virtual void post_hook() = 0; - - virtual void run(std::shared_ptr loop) - { - loop->run(); - }; - - }; -} - -#endif diff --git a/include/xeus-zmq/xhook_base.hpp b/include/xeus-zmq/xhook_base.hpp new file mode 100644 index 0000000..3e95955 --- /dev/null +++ b/include/xeus-zmq/xhook_base.hpp @@ -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 +#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 loop) + { + loop->run(); + }; + + }; +} + +#endif diff --git a/include/xeus-zmq/xserver_zmq.hpp b/include/xeus-zmq/xserver_zmq.hpp index a016ceb..45e37bd 100644 --- a/include/xeus-zmq/xserver_zmq.hpp +++ b/include/xeus-zmq/xserver_zmq.hpp @@ -22,7 +22,7 @@ #include "xeus/xserver.hpp" #include "xeus-zmq.hpp" -#include "hook_base.hpp" +#include "xhook_base.hpp" namespace xeus { @@ -78,7 +78,7 @@ namespace xeus const xconfiguration& config, nl::json::error_handler_t eh = nl::json::error_handler_t::strict, std::shared_ptr loop_ptr = nullptr, - std::unique_ptr hook = nullptr); + std::unique_ptr hook = nullptr); } diff --git a/src/xserver_shell_main.cpp b/src/xserver_shell_main.cpp index e8671c7..e9880be 100644 --- a/src/xserver_shell_main.cpp +++ b/src/xserver_shell_main.cpp @@ -36,7 +36,7 @@ namespace xeus const xconfiguration& config, nl::json::error_handler_t eh, std::shared_ptr loop_ptr, - std::unique_ptr hook) + std::unique_ptr hook) : xserver_zmq_split(context, config, eh, loop_ptr, std::move(hook)) { } diff --git a/src/xserver_shell_main.hpp b/src/xserver_shell_main.hpp index ebd16ab..b94e84b 100644 --- a/src/xserver_shell_main.hpp +++ b/src/xserver_shell_main.hpp @@ -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 { @@ -37,7 +37,7 @@ namespace xeus const xconfiguration& config, nl::json::error_handler_t he, std::shared_ptr loop_ptr, - std::unique_ptr hook); + std::unique_ptr hook); virtual ~xserver_shell_main(); diff --git a/src/xserver_zmq.cpp b/src/xserver_zmq.cpp index 5ea6dd0..52717e9 100644 --- a/src/xserver_zmq.cpp +++ b/src/xserver_zmq.cpp @@ -128,7 +128,7 @@ namespace xeus const xconfiguration& config, nl::json::error_handler_t eh, std::shared_ptr loop_ptr, - std::unique_ptr hook) + std::unique_ptr hook) { auto impl = std::make_unique( context.get_wrapped_context(), config, eh, loop_ptr, std::move(hook)); diff --git a/src/xserver_zmq_split.cpp b/src/xserver_zmq_split.cpp index 45ddefe..cb761eb 100644 --- a/src/xserver_zmq_split.cpp +++ b/src/xserver_zmq_split.cpp @@ -56,7 +56,7 @@ namespace xeus const xconfiguration& config, nl::json::error_handler_t eh, std::shared_ptr loop_ptr, - std::unique_ptr hook) + std::unique_ptr 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)) diff --git a/src/xserver_zmq_split.hpp b/src/xserver_zmq_split.hpp index d393d3d..a4a6087 100644 --- a/src/xserver_zmq_split.hpp +++ b/src/xserver_zmq_split.hpp @@ -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" @@ -53,7 +53,7 @@ namespace xeus const xconfiguration& config, nl::json::error_handler_t eh, std::shared_ptr loop_ptr, - std::unique_ptr hook); + std::unique_ptr hook); ~xserver_zmq_split() override; diff --git a/src/xshell_uv.cpp b/src/xshell_uv.cpp index ab64e20..d3037bb 100644 --- a/src/xshell_uv.cpp +++ b/src/xshell_uv.cpp @@ -27,7 +27,7 @@ namespace xeus const std::string& stdin_port, xserver_zmq_split* server, std::shared_ptr loop_ptr, - std::unique_ptr hook) + std::unique_ptr hook) : xshell_base(context, transport, ip, shell_port, stdin_port, server) , p_loop{loop_ptr} , p_hook{std::move(hook)} @@ -114,10 +114,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(); } } diff --git a/src/xshell_uv.hpp b/src/xshell_uv.hpp index af066b6..65b91ae 100644 --- a/src/xshell_uv.hpp +++ b/src/xshell_uv.hpp @@ -18,7 +18,7 @@ #endif #include "xshell_base.hpp" -#include "xeus-zmq/hook_base.hpp" +#include "xeus-zmq/xhook_base.hpp" namespace xeus { @@ -35,7 +35,7 @@ namespace xeus const std::string& stdin_port, xserver_zmq_split* server, std::shared_ptr loop_ptr, - std::unique_ptr hook); + std::unique_ptr hook); ~xshell_uv(); @@ -48,7 +48,7 @@ namespace xeus std::shared_ptr p_loop{ nullptr }; std::shared_ptr p_shell_poll{ nullptr }; std::shared_ptr p_controller_poll{ nullptr }; - std::unique_ptr p_hook{ nullptr }; + std::unique_ptr p_hook{ nullptr }; }; } // namespace xeus