From 54ddda26a0a20a0b322e97c1e880358afe8c92f0 Mon Sep 17 00:00:00 2001 From: deniskovalchuk Date: Sun, 7 Apr 2024 15:26:09 +0300 Subject: [PATCH] core: inline socket_factory::create() --- CMakeLists.txt | 2 -- include/ftp/detail/socket_factory.hpp | 41 --------------------------- src/control_connection.cpp | 3 +- src/data_connection.cpp | 4 +-- src/socket_factory.cpp | 37 ------------------------ 5 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 include/ftp/detail/socket_factory.hpp delete mode 100644 src/socket_factory.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ff01e71..82bffb2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,6 @@ set(sources include/ftp/detail/net_utils.hpp include/ftp/detail/socket.hpp include/ftp/detail/socket_base.hpp - include/ftp/detail/socket_factory.hpp include/ftp/detail/ssl_socket.hpp include/ftp/detail/utils.hpp include/ftp/stream/input_stream.hpp @@ -59,7 +58,6 @@ set(sources src/replies.cpp src/reply.cpp src/socket.cpp - src/socket_factory.cpp src/ssl_socket.cpp src/utils.cpp) diff --git a/include/ftp/detail/socket_factory.hpp b/include/ftp/detail/socket_factory.hpp deleted file mode 100644 index 225cc93..0000000 --- a/include/ftp/detail/socket_factory.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2024 Denis Kovalchuk - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef LIBFTP_SOCKET_FACTORY_HPP -#define LIBFTP_SOCKET_FACTORY_HPP - -#include -#include - -namespace ftp::detail -{ - -class socket_factory -{ -public: - static socket_base_ptr create(boost::asio::io_context & io_context); -}; - -} // namespace ftp::detail -#endif //LIBFTP_SOCKET_FACTORY_HPP diff --git a/src/control_connection.cpp b/src/control_connection.cpp index f29571d..ab658ae 100644 --- a/src/control_connection.cpp +++ b/src/control_connection.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -44,7 +43,7 @@ static bool try_parse_status_code(std::string_view line, std::uint16_t & status_ control_connection::control_connection(net_context & net_context) { - socket_ = socket_factory::create(net_context.get_io_context()); + socket_ = std::make_unique(net_context.get_io_context()); } void control_connection::connect(std::string_view hostname, std::uint16_t port) diff --git a/src/data_connection.cpp b/src/data_connection.cpp index bda81cb..d6372b9 100644 --- a/src/data_connection.cpp +++ b/src/data_connection.cpp @@ -23,7 +23,7 @@ */ #include -#include +#include #include #include @@ -33,7 +33,7 @@ namespace ftp::detail data_connection::data_connection(net_context & net_context) : acceptor_(net_context.get_io_context()) { - socket_ = socket_factory::create(net_context.get_io_context()); + socket_ = std::make_unique(net_context.get_io_context()); } void data_connection::connect(std::string_view ip, std::uint16_t port) diff --git a/src/socket_factory.cpp b/src/socket_factory.cpp deleted file mode 100644 index ab21004..0000000 --- a/src/socket_factory.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2024 Denis Kovalchuk - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -namespace ftp::detail -{ - -socket_base_ptr socket_factory::create(boost::asio::io_context & io_context) -{ - return std::make_unique(io_context); -} - -} // namespace ftp::detail