From cd09ffa4f8e7b6f5a283ba1733aa5a292060b2d7 Mon Sep 17 00:00:00 2001 From: liushuai <770722922@qq.com> Date: Mon, 18 Sep 2023 12:53:34 +0800 Subject: [PATCH] feat: refine include --- .gitmodules | 4 ++-- CMakeLists.txt | 5 ++--- include/asio_net.hpp | 7 +++++++ config.h => include/asio_net/config.h | 0 {detail => include/asio_net/detail}/log.h | 0 {detail => include/asio_net/detail}/message.hpp | 0 {detail => include/asio_net/detail}/noncopyable.hpp | 0 {rpc => include/asio_net}/detail/rpc_client_t.hpp | 6 +++--- {rpc => include/asio_net}/detail/rpc_server_t.hpp | 4 ++-- {rpc => include/asio_net}/detail/rpc_session_t.hpp | 4 ++-- {detail => include/asio_net/detail}/socket_type.hpp | 0 {detail => include/asio_net/detail}/tcp_channel_t.hpp | 2 +- {detail => include/asio_net/detail}/tcp_client_t.hpp | 0 {detail => include/asio_net/detail}/tcp_server_t.hpp | 2 +- {detail => include/asio_net/detail}/udp_client_t.hpp | 0 {detail => include/asio_net/detail}/udp_server_t.hpp | 0 {rpc => include/asio_net}/rpc_client.hpp | 0 include/asio_net/rpc_core | 1 + {rpc => include/asio_net}/rpc_server.hpp | 1 + {rpc => include/asio_net}/rpc_session.hpp | 0 .../asio_net/server_discovery.hpp | 0 tcp_client.hpp => include/asio_net/tcp_client.hpp | 0 tcp_server.hpp => include/asio_net/tcp_server.hpp | 0 udp_client.hpp => include/asio_net/udp_client.hpp | 0 udp_server.hpp => include/asio_net/udp_server.hpp | 0 library.json | 5 ++--- rpc/rpc_core | 1 - test/domain_rpc.cpp | 4 ++-- test/domain_tcp.cpp | 4 ++-- test/domain_udp.cpp | 4 ++-- test/rpc.cpp | 4 ++-- test/rpc_c.cpp | 2 +- test/rpc_c_open_close.cpp | 2 +- test/rpc_reconnect.cpp | 4 ++-- test/rpc_s.cpp | 2 +- test/rpc_ssl.cpp | 4 ++-- test/server_discovery.cpp | 2 +- test/tcp.cpp | 4 ++-- test/tcp_bigdata.cpp | 4 ++-- test/tcp_c.cpp | 2 +- test/tcp_reconnect.cpp | 4 ++-- test/tcp_s.cpp | 2 +- test/tcp_ssl_c.cpp | 2 +- test/tcp_ssl_s.cpp | 2 +- test/udp.cpp | 4 ++-- test/udp_c.cpp | 2 +- test/udp_s.cpp | 2 +- 47 files changed, 54 insertions(+), 48 deletions(-) create mode 100644 include/asio_net.hpp rename config.h => include/asio_net/config.h (100%) rename {detail => include/asio_net/detail}/log.h (100%) rename {detail => include/asio_net/detail}/message.hpp (100%) rename {detail => include/asio_net/detail}/noncopyable.hpp (100%) rename {rpc => include/asio_net}/detail/rpc_client_t.hpp (96%) rename {rpc => include/asio_net}/detail/rpc_server_t.hpp (97%) rename {rpc => include/asio_net}/detail/rpc_session_t.hpp (96%) rename {detail => include/asio_net/detail}/socket_type.hpp (100%) rename {detail => include/asio_net/detail}/tcp_channel_t.hpp (99%) rename {detail => include/asio_net/detail}/tcp_client_t.hpp (100%) rename {detail => include/asio_net/detail}/tcp_server_t.hpp (99%) rename {detail => include/asio_net/detail}/udp_client_t.hpp (100%) rename {detail => include/asio_net/detail}/udp_server_t.hpp (100%) rename {rpc => include/asio_net}/rpc_client.hpp (100%) create mode 160000 include/asio_net/rpc_core rename {rpc => include/asio_net}/rpc_server.hpp (92%) rename {rpc => include/asio_net}/rpc_session.hpp (100%) rename server_discovery.hpp => include/asio_net/server_discovery.hpp (100%) rename tcp_client.hpp => include/asio_net/tcp_client.hpp (100%) rename tcp_server.hpp => include/asio_net/tcp_server.hpp (100%) rename udp_client.hpp => include/asio_net/udp_client.hpp (100%) rename udp_server.hpp => include/asio_net/udp_server.hpp (100%) delete mode 160000 rpc/rpc_core diff --git a/.gitmodules b/.gitmodules index 8ac1453..8ae244b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "rpc/rpc_core"] - path = rpc/rpc_core +[submodule "include/asio_net/rpc_core"] + path = include/asio_net/rpc_core url = git@github.com:shuai132/rpc_core.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bc26cf..bd7295e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,15 +17,14 @@ set(CMAKE_CXX_STANDARD 14) add_compile_options(-Wall) add_library(${PROJECT_NAME} INTERFACE) -target_include_directories(${PROJECT_NAME} INTERFACE .) +target_include_directories(${PROJECT_NAME} INTERFACE include) if (ASIO_NET_ENABLE_SSL) target_compile_definitions(${PROJECT_NAME} INTERFACE -DASIO_NET_ENABLE_SSL) endif () if (ASIO_NET_ENABLE_RPC) target_include_directories(${PROJECT_NAME} INTERFACE - rpc/rpc_core - rpc + include/asio_net/rpc_core/include ) endif () diff --git a/include/asio_net.hpp b/include/asio_net.hpp new file mode 100644 index 0000000..cc97071 --- /dev/null +++ b/include/asio_net.hpp @@ -0,0 +1,7 @@ +#pragma once + +#include "asio_net/server_discovery.hpp" +#include "asio_net/tcp_client.hpp" +#include "asio_net/tcp_server.hpp" +#include "asio_net/udp_client.hpp" +#include "asio_net/udp_server.hpp" diff --git a/config.h b/include/asio_net/config.h similarity index 100% rename from config.h rename to include/asio_net/config.h diff --git a/detail/log.h b/include/asio_net/detail/log.h similarity index 100% rename from detail/log.h rename to include/asio_net/detail/log.h diff --git a/detail/message.hpp b/include/asio_net/detail/message.hpp similarity index 100% rename from detail/message.hpp rename to include/asio_net/detail/message.hpp diff --git a/detail/noncopyable.hpp b/include/asio_net/detail/noncopyable.hpp similarity index 100% rename from detail/noncopyable.hpp rename to include/asio_net/detail/noncopyable.hpp diff --git a/rpc/detail/rpc_client_t.hpp b/include/asio_net/detail/rpc_client_t.hpp similarity index 96% rename from rpc/detail/rpc_client_t.hpp rename to include/asio_net/detail/rpc_client_t.hpp index c7397fb..1443259 100644 --- a/rpc/detail/rpc_client_t.hpp +++ b/include/asio_net/detail/rpc_client_t.hpp @@ -2,10 +2,10 @@ #include -#include "detail/noncopyable.hpp" +#include "noncopyable.hpp" #include "rpc_core.hpp" -#include "rpc_session.hpp" -#include "tcp_client.hpp" +#include "rpc_session_t.hpp" +#include "tcp_client_t.hpp" namespace asio_net { namespace detail { diff --git a/rpc/detail/rpc_server_t.hpp b/include/asio_net/detail/rpc_server_t.hpp similarity index 97% rename from rpc/detail/rpc_server_t.hpp rename to include/asio_net/detail/rpc_server_t.hpp index 4824488..79d84fb 100644 --- a/rpc/detail/rpc_server_t.hpp +++ b/include/asio_net/detail/rpc_server_t.hpp @@ -3,8 +3,8 @@ #include #include "asio.hpp" -#include "rpc_session.hpp" -#include "tcp_server.hpp" +#include "rpc_session_t.hpp" +#include "tcp_server_t.hpp" namespace asio_net { namespace detail { diff --git a/rpc/detail/rpc_session_t.hpp b/include/asio_net/detail/rpc_session_t.hpp similarity index 96% rename from rpc/detail/rpc_session_t.hpp rename to include/asio_net/detail/rpc_session_t.hpp index bb4236c..f2cd410 100644 --- a/rpc/detail/rpc_session_t.hpp +++ b/include/asio_net/detail/rpc_session_t.hpp @@ -2,9 +2,9 @@ #include -#include "detail/noncopyable.hpp" -#include "detail/tcp_channel_t.hpp" +#include "noncopyable.hpp" #include "rpc_core.hpp" +#include "tcp_channel_t.hpp" namespace asio_net { namespace detail { diff --git a/detail/socket_type.hpp b/include/asio_net/detail/socket_type.hpp similarity index 100% rename from detail/socket_type.hpp rename to include/asio_net/detail/socket_type.hpp diff --git a/detail/tcp_channel_t.hpp b/include/asio_net/detail/tcp_channel_t.hpp similarity index 99% rename from detail/tcp_channel_t.hpp rename to include/asio_net/detail/tcp_channel_t.hpp index a1843b0..fa6dcf8 100644 --- a/detail/tcp_channel_t.hpp +++ b/include/asio_net/detail/tcp_channel_t.hpp @@ -3,8 +3,8 @@ #include #include +#include "../config.h" #include "asio.hpp" -#include "config.h" #include "log.h" #include "message.hpp" #include "noncopyable.hpp" diff --git a/detail/tcp_client_t.hpp b/include/asio_net/detail/tcp_client_t.hpp similarity index 100% rename from detail/tcp_client_t.hpp rename to include/asio_net/detail/tcp_client_t.hpp diff --git a/detail/tcp_server_t.hpp b/include/asio_net/detail/tcp_server_t.hpp similarity index 99% rename from detail/tcp_server_t.hpp rename to include/asio_net/detail/tcp_server_t.hpp index 277aa93..f7bd78a 100644 --- a/detail/tcp_server_t.hpp +++ b/include/asio_net/detail/tcp_server_t.hpp @@ -2,8 +2,8 @@ #include +#include "../config.h" #include "asio.hpp" -#include "config.h" #include "tcp_channel_t.hpp" namespace asio_net { diff --git a/detail/udp_client_t.hpp b/include/asio_net/detail/udp_client_t.hpp similarity index 100% rename from detail/udp_client_t.hpp rename to include/asio_net/detail/udp_client_t.hpp diff --git a/detail/udp_server_t.hpp b/include/asio_net/detail/udp_server_t.hpp similarity index 100% rename from detail/udp_server_t.hpp rename to include/asio_net/detail/udp_server_t.hpp diff --git a/rpc/rpc_client.hpp b/include/asio_net/rpc_client.hpp similarity index 100% rename from rpc/rpc_client.hpp rename to include/asio_net/rpc_client.hpp diff --git a/include/asio_net/rpc_core b/include/asio_net/rpc_core new file mode 160000 index 0000000..4d51c81 --- /dev/null +++ b/include/asio_net/rpc_core @@ -0,0 +1 @@ +Subproject commit 4d51c8118ac151ac9619c24a4d364addf92d84db diff --git a/rpc/rpc_server.hpp b/include/asio_net/rpc_server.hpp similarity index 92% rename from rpc/rpc_server.hpp rename to include/asio_net/rpc_server.hpp index b1a6668..327b716 100644 --- a/rpc/rpc_server.hpp +++ b/include/asio_net/rpc_server.hpp @@ -1,6 +1,7 @@ #pragma once #include "detail/rpc_server_t.hpp" +#include "rpc_session.hpp" namespace asio_net { diff --git a/rpc/rpc_session.hpp b/include/asio_net/rpc_session.hpp similarity index 100% rename from rpc/rpc_session.hpp rename to include/asio_net/rpc_session.hpp diff --git a/server_discovery.hpp b/include/asio_net/server_discovery.hpp similarity index 100% rename from server_discovery.hpp rename to include/asio_net/server_discovery.hpp diff --git a/tcp_client.hpp b/include/asio_net/tcp_client.hpp similarity index 100% rename from tcp_client.hpp rename to include/asio_net/tcp_client.hpp diff --git a/tcp_server.hpp b/include/asio_net/tcp_server.hpp similarity index 100% rename from tcp_server.hpp rename to include/asio_net/tcp_server.hpp diff --git a/udp_client.hpp b/include/asio_net/udp_client.hpp similarity index 100% rename from udp_client.hpp rename to include/asio_net/udp_client.hpp diff --git a/udp_server.hpp b/include/asio_net/udp_server.hpp similarity index 100% rename from udp_server.hpp rename to include/asio_net/udp_server.hpp diff --git a/library.json b/library.json index 0892924..e5c42b8 100644 --- a/library.json +++ b/library.json @@ -14,9 +14,8 @@ "build": { "srcDir": "_", "flags": [ - "-I .", - "-I rpc", - "-I rpc/rpc_core" + "-I include", + "-I asio_net/rpc_core/include" ] } } diff --git a/rpc/rpc_core b/rpc/rpc_core deleted file mode 160000 index d9b1383..0000000 --- a/rpc/rpc_core +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d9b13833002dc0acc616996222edc01b3d03a543 diff --git a/test/domain_rpc.cpp b/test/domain_rpc.cpp index 9b64433..52740a3 100644 --- a/test/domain_rpc.cpp +++ b/test/domain_rpc.cpp @@ -5,8 +5,8 @@ #include "assert_def.h" #include "log.h" -#include "rpc_client.hpp" -#include "rpc_server.hpp" +#include "asio_net/rpc_client.hpp" +#include "asio_net/rpc_server.hpp" using namespace asio_net; diff --git a/test/domain_tcp.cpp b/test/domain_tcp.cpp index 2af0fbf..bf0ed8b 100644 --- a/test/domain_tcp.cpp +++ b/test/domain_tcp.cpp @@ -5,8 +5,8 @@ #include "assert_def.h" #include "log.h" -#include "tcp_client.hpp" -#include "tcp_server.hpp" +#include "asio_net/tcp_client.hpp" +#include "asio_net/tcp_server.hpp" using namespace asio_net; diff --git a/test/domain_udp.cpp b/test/domain_udp.cpp index d089546..3d0f2f1 100644 --- a/test/domain_udp.cpp +++ b/test/domain_udp.cpp @@ -5,8 +5,8 @@ #include "assert_def.h" #include "log.h" -#include "udp_client.hpp" -#include "udp_server.hpp" +#include "asio_net/udp_client.hpp" +#include "asio_net/udp_server.hpp" using namespace asio_net; diff --git a/test/rpc.cpp b/test/rpc.cpp index 13daddd..babceae 100644 --- a/test/rpc.cpp +++ b/test/rpc.cpp @@ -5,8 +5,8 @@ #include "assert_def.h" #include "log.h" -#include "rpc_client.hpp" -#include "rpc_server.hpp" +#include "asio_net/rpc_client.hpp" +#include "asio_net/rpc_server.hpp" using namespace asio_net; diff --git a/test/rpc_c.cpp b/test/rpc_c.cpp index e03a103..c46a69a 100644 --- a/test/rpc_c.cpp +++ b/test/rpc_c.cpp @@ -1,7 +1,7 @@ #include #include "log.h" -#include "rpc_client.hpp" +#include "asio_net/rpc_client.hpp" using namespace asio_net; diff --git a/test/rpc_c_open_close.cpp b/test/rpc_c_open_close.cpp index eb1401e..395d129 100644 --- a/test/rpc_c_open_close.cpp +++ b/test/rpc_c_open_close.cpp @@ -1,7 +1,7 @@ #include #include "log.h" -#include "rpc_client.hpp" +#include "asio_net/rpc_client.hpp" using namespace asio_net; diff --git a/test/rpc_reconnect.cpp b/test/rpc_reconnect.cpp index 0214823..ae589d9 100644 --- a/test/rpc_reconnect.cpp +++ b/test/rpc_reconnect.cpp @@ -3,8 +3,8 @@ #include #include "log.h" -#include "rpc_client.hpp" -#include "rpc_server.hpp" +#include "asio_net/rpc_client.hpp" +#include "asio_net/rpc_server.hpp" using namespace asio_net; diff --git a/test/rpc_s.cpp b/test/rpc_s.cpp index df57411..f5504bc 100644 --- a/test/rpc_s.cpp +++ b/test/rpc_s.cpp @@ -1,7 +1,7 @@ #include #include "log.h" -#include "rpc_server.hpp" +#include "asio_net/rpc_server.hpp" using namespace asio_net; diff --git a/test/rpc_ssl.cpp b/test/rpc_ssl.cpp index 021f8b0..4f90fcb 100644 --- a/test/rpc_ssl.cpp +++ b/test/rpc_ssl.cpp @@ -5,8 +5,8 @@ #include "assert_def.h" #include "log.h" -#include "rpc_client.hpp" -#include "rpc_server.hpp" +#include "asio_net/rpc_client.hpp" +#include "asio_net/rpc_server.hpp" using namespace asio_net; diff --git a/test/server_discovery.cpp b/test/server_discovery.cpp index b3741a4..8e1da33 100644 --- a/test/server_discovery.cpp +++ b/test/server_discovery.cpp @@ -1,4 +1,4 @@ -#include "server_discovery.hpp" +#include "asio_net/server_discovery.hpp" #include diff --git a/test/tcp.cpp b/test/tcp.cpp index 7a1a575..587578c 100644 --- a/test/tcp.cpp +++ b/test/tcp.cpp @@ -5,8 +5,8 @@ #include "assert_def.h" #include "log.h" -#include "tcp_client.hpp" -#include "tcp_server.hpp" +#include "asio_net/tcp_client.hpp" +#include "asio_net/tcp_server.hpp" using namespace asio_net; diff --git a/test/tcp_bigdata.cpp b/test/tcp_bigdata.cpp index fd65ab4..1db18ad 100644 --- a/test/tcp_bigdata.cpp +++ b/test/tcp_bigdata.cpp @@ -4,8 +4,8 @@ #include "assert_def.h" #include "log.h" -#include "tcp_client.hpp" -#include "tcp_server.hpp" +#include "asio_net/tcp_client.hpp" +#include "asio_net/tcp_server.hpp" using namespace asio_net; diff --git a/test/tcp_c.cpp b/test/tcp_c.cpp index 2b4dc96..670d213 100644 --- a/test/tcp_c.cpp +++ b/test/tcp_c.cpp @@ -1,5 +1,5 @@ #include "log.h" -#include "tcp_client.hpp" +#include "asio_net/tcp_client.hpp" using namespace asio_net; diff --git a/test/tcp_reconnect.cpp b/test/tcp_reconnect.cpp index 44238ea..f7c72dd 100644 --- a/test/tcp_reconnect.cpp +++ b/test/tcp_reconnect.cpp @@ -4,8 +4,8 @@ #include "assert_def.h" #include "log.h" -#include "tcp_client.hpp" -#include "tcp_server.hpp" +#include "asio_net/tcp_client.hpp" +#include "asio_net/tcp_server.hpp" using namespace asio_net; diff --git a/test/tcp_s.cpp b/test/tcp_s.cpp index afe3739..87a132f 100644 --- a/test/tcp_s.cpp +++ b/test/tcp_s.cpp @@ -1,6 +1,6 @@ #include "assert_def.h" #include "log.h" -#include "tcp_server.hpp" +#include "asio_net/tcp_server.hpp" using namespace asio_net; diff --git a/test/tcp_ssl_c.cpp b/test/tcp_ssl_c.cpp index 96c440c..6c10d5d 100644 --- a/test/tcp_ssl_c.cpp +++ b/test/tcp_ssl_c.cpp @@ -1,5 +1,5 @@ #include "log.h" -#include "tcp_client.hpp" +#include "asio_net/tcp_client.hpp" using namespace asio_net; diff --git a/test/tcp_ssl_s.cpp b/test/tcp_ssl_s.cpp index 4769830..10891ce 100644 --- a/test/tcp_ssl_s.cpp +++ b/test/tcp_ssl_s.cpp @@ -1,6 +1,6 @@ #include "assert_def.h" #include "log.h" -#include "tcp_server.hpp" +#include "asio_net/tcp_server.hpp" using namespace asio_net; diff --git a/test/udp.cpp b/test/udp.cpp index 2c0c970..88a05b3 100644 --- a/test/udp.cpp +++ b/test/udp.cpp @@ -5,8 +5,8 @@ #include "assert_def.h" #include "log.h" -#include "udp_client.hpp" -#include "udp_server.hpp" +#include "asio_net/udp_client.hpp" +#include "asio_net/udp_server.hpp" using namespace asio_net; diff --git a/test/udp_c.cpp b/test/udp_c.cpp index 7e41189..9927b2f 100644 --- a/test/udp_c.cpp +++ b/test/udp_c.cpp @@ -1,5 +1,5 @@ #include "log.h" -#include "udp_client.hpp" +#include "asio_net/udp_client.hpp" using namespace asio_net; diff --git a/test/udp_s.cpp b/test/udp_s.cpp index a97e3d6..c9815fe 100644 --- a/test/udp_s.cpp +++ b/test/udp_s.cpp @@ -1,5 +1,5 @@ #include "log.h" -#include "udp_server.hpp" +#include "asio_net/udp_server.hpp" using namespace asio_net;