From 0eeb7bb32fab3a4294bd3bb2e9c3eafce0807ab3 Mon Sep 17 00:00:00 2001 From: Sangwan Kwon Date: Tue, 31 Dec 2019 16:13:54 +0900 Subject: [PATCH] Reorganize rmi direcorty - vist/rmi: API header to be exposed - vist/rmi/impl: Implementation to be hidden Signed-off-by: Sangwan Kwon --- src/vist/CMakeLists.txt | 1 - src/vist/rmi/CMakeLists.txt | 8 +++- src/vist/rmi/gateway.cpp | 12 ++--- src/vist/rmi/gateway.hpp | 6 --- src/vist/{transport => rmi/impl}/client.hpp | 14 +++--- src/vist/{transport => rmi/impl}/protocol.cpp | 6 ++- src/vist/{transport => rmi/impl}/protocol.hpp | 13 +++--- src/vist/{transport => rmi/impl}/server.hpp | 20 ++++----- .../{transport => rmi/impl}/tests/protocol.cpp | 6 ++- .../impl}/tests/server-client.cpp | 8 ++-- src/vist/{transport => rmi}/message.cpp | 10 +---- src/vist/{transport => rmi}/message.hpp | 10 +---- src/vist/rmi/remote.cpp | 10 +---- src/vist/rmi/remote.hpp | 10 +---- src/vist/rmi/tests/rmi.cpp | 6 --- src/vist/transport/CMakeLists.txt | 19 -------- src/vist/transport/systemd-socket.hpp | 51 ---------------------- 17 files changed, 50 insertions(+), 160 deletions(-) rename src/vist/{transport => rmi/impl}/client.hpp (86%) rename src/vist/{transport => rmi/impl}/protocol.cpp (98%) rename src/vist/{transport => rmi/impl}/protocol.hpp (87%) rename src/vist/{transport => rmi/impl}/server.hpp (92%) rename src/vist/{transport => rmi/impl}/tests/protocol.cpp (97%) rename src/vist/{transport => rmi/impl}/tests/server-client.cpp (93%) rename src/vist/{transport => rmi}/message.cpp (87%) rename src/vist/{transport => rmi}/message.hpp (89%) delete mode 100644 src/vist/transport/CMakeLists.txt delete mode 100644 src/vist/transport/systemd-socket.hpp diff --git a/src/vist/CMakeLists.txt b/src/vist/CMakeLists.txt index bf217bd..4114423 100644 --- a/src/vist/CMakeLists.txt +++ b/src/vist/CMakeLists.txt @@ -45,7 +45,6 @@ ADD_SUBDIRECTORY(klass) ADD_SUBDIRECTORY(logger) ADD_SUBDIRECTORY(rmi) ADD_SUBDIRECTORY(sdk) -ADD_SUBDIRECTORY(transport) # policy ADD_SUBDIRECTORY(policy) diff --git a/src/vist/rmi/CMakeLists.txt b/src/vist/rmi/CMakeLists.txt index 01b8e67..3ae4076 100644 --- a/src/vist/rmi/CMakeLists.txt +++ b/src/vist/rmi/CMakeLists.txt @@ -13,7 +13,13 @@ # limitations under the License ADD_VIST_COMMON_LIBRARY(vist_rmi gateway.cpp - remote.cpp) + remote.cpp + message.cpp) + +ADD_VIST_COMMON_LIBRARY(vist_rmi_impl impl/protocol.cpp) FILE(GLOB RMI_TESTS "tests/*.cpp") ADD_VIST_TEST(${RMI_TESTS}) + +FILE(GLOB RMI_IMPL_TESTS "impl/tests/*.cpp") +ADD_VIST_TEST(${RMI_IMPL_TESTS}) diff --git a/src/vist/rmi/gateway.cpp b/src/vist/rmi/gateway.cpp index 7654d1c..a7f6ab4 100644 --- a/src/vist/rmi/gateway.cpp +++ b/src/vist/rmi/gateway.cpp @@ -13,25 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License */ -/* - * @file gateway.cpp - * @author Sangwan Kwon (sangwan.kwon@samsung.com) - * @author Jaemin Ryu (jm77.ryu@samsung.com) - * @brief Implementation of Server-side stub for exposing method. - */ #include "gateway.hpp" #include -#include -#include +#include +#include #include namespace vist { namespace rmi { -using namespace vist::transport; +using namespace vist::rmi::impl; class Gateway::Impl { public: diff --git a/src/vist/rmi/gateway.hpp b/src/vist/rmi/gateway.hpp index e1195d9..0b8ff8c 100644 --- a/src/vist/rmi/gateway.hpp +++ b/src/vist/rmi/gateway.hpp @@ -13,12 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License */ -/* - * @file gateway.hpp - * @author Sangwan Kwon (sangwan.kwon@samsung.com) - * @author Jaemin Ryu (jm77.ryu@samsung.com) - * @brief Server-side stub for exposing method. - */ #pragma once diff --git a/src/vist/transport/client.hpp b/src/vist/rmi/impl/client.hpp similarity index 86% rename from src/vist/transport/client.hpp rename to src/vist/rmi/impl/client.hpp index 1f2091b..c9186e8 100644 --- a/src/vist/transport/client.hpp +++ b/src/vist/rmi/impl/client.hpp @@ -13,20 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License */ -/* - * @file client.hpp - * @author Sangwan Kwon (sangwan.kwon@samsung.com) - * @brief Protocol compliant client. - */ #pragma once +#include "protocol.hpp" + #include #include -#include namespace vist { -namespace transport { +namespace rmi { +namespace impl { using boost::asio::local::stream_protocol; @@ -52,5 +49,6 @@ private: Protocol::Socket socket; }; -} // namespace transport +} // namespace impl +} // namespace rmi } // namespace vist diff --git a/src/vist/transport/protocol.cpp b/src/vist/rmi/impl/protocol.cpp similarity index 98% rename from src/vist/transport/protocol.cpp rename to src/vist/rmi/impl/protocol.cpp index 88fb9ff..82c49b0 100644 --- a/src/vist/transport/protocol.cpp +++ b/src/vist/rmi/impl/protocol.cpp @@ -20,7 +20,8 @@ #include namespace vist { -namespace transport { +namespace rmi { +namespace impl { Message Protocol::Recv(Socket& socket) { @@ -141,5 +142,6 @@ void Protocol::Async::process(const Task& task, std::atomic& polling) boost::asio::async_write(self->socket, headerBuffer, handler); } -} // namespace transport +} // namespace impl +} // namespace rmi } // namespace vist diff --git a/src/vist/transport/protocol.hpp b/src/vist/rmi/impl/protocol.hpp similarity index 87% rename from src/vist/transport/protocol.hpp rename to src/vist/rmi/impl/protocol.hpp index 877dd76..aa7ecf6 100644 --- a/src/vist/transport/protocol.hpp +++ b/src/vist/rmi/impl/protocol.hpp @@ -13,15 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License */ -/* - * @file protocol.hpp - * @author Sangwan Kwon (sangwan.kwon@samsung.com) - * @brief Socket communication protocol between server and client. - */ #pragma once -#include +#include #include #include @@ -29,7 +24,8 @@ #include namespace vist { -namespace transport { +namespace rmi { +namespace impl { struct Protocol { using Acceptor = boost::asio::local::stream_protocol::acceptor; @@ -62,5 +58,6 @@ struct Protocol { }; }; -} // namespace transport +} // namespace impl +} // namespace rmi } // namespace vist diff --git a/src/vist/transport/server.hpp b/src/vist/rmi/impl/server.hpp similarity index 92% rename from src/vist/transport/server.hpp rename to src/vist/rmi/impl/server.hpp index afb22d8..5e59b09 100644 --- a/src/vist/transport/server.hpp +++ b/src/vist/rmi/impl/server.hpp @@ -13,29 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License */ -/* - * @file server.hpp - * @author Sangwan Kwon (sangwan.kwon@samsung.com) - * @brief Protocol compliant server. - */ #pragma once +#include "protocol.hpp" + #include #include #include -#include -#include #include -#include #include +#include +#include -#include #include +#include namespace vist { -namespace transport { +namespace rmi { +namespace impl { class Server { public: @@ -100,5 +97,6 @@ private: std::atomic polling; }; -} // namespace transport +} // namespace impl +} // namespace rmi } // namespace vist diff --git a/src/vist/transport/tests/protocol.cpp b/src/vist/rmi/impl/tests/protocol.cpp similarity index 97% rename from src/vist/transport/tests/protocol.cpp rename to src/vist/rmi/impl/tests/protocol.cpp index 94262a9..2b2e4ac 100644 --- a/src/vist/transport/tests/protocol.cpp +++ b/src/vist/rmi/impl/tests/protocol.cpp @@ -14,7 +14,8 @@ * limitations under the License */ -#include +#include +#include #include #include @@ -24,7 +25,8 @@ #include -using namespace vist::transport; +using namespace vist::rmi; +using namespace vist::rmi::impl; using boost::asio::local::stream_protocol; namespace { diff --git a/src/vist/transport/tests/server-client.cpp b/src/vist/rmi/impl/tests/server-client.cpp similarity index 93% rename from src/vist/transport/tests/server-client.cpp rename to src/vist/rmi/impl/tests/server-client.cpp index d76c6f9..17058cb 100644 --- a/src/vist/transport/tests/server-client.cpp +++ b/src/vist/rmi/impl/tests/server-client.cpp @@ -14,8 +14,9 @@ * limitations under the License */ -#include -#include +#include +#include +#include #include #include @@ -24,7 +25,8 @@ #include -using namespace vist::transport; +using namespace vist::rmi; +using namespace vist::rmi::impl; using boost::asio::local::stream_protocol; namespace { diff --git a/src/vist/transport/message.cpp b/src/vist/rmi/message.cpp similarity index 87% rename from src/vist/transport/message.cpp rename to src/vist/rmi/message.cpp index 3153cd6..86902c6 100644 --- a/src/vist/transport/message.cpp +++ b/src/vist/rmi/message.cpp @@ -13,17 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License */ -/* - * @file message.cpp - * @author Jaemin Ryu (jm77.ryu@samsung.com) - * @author Sangwan Kwon (sangwan.kwon@samsung.com) - * @brief Implementaion of message. - */ #include "message.hpp" namespace vist { -namespace transport { +namespace rmi { Message::Message(unsigned int type, const std::string& signature) : header({0, type, signature.size()}), @@ -67,5 +61,5 @@ std::vector& Message::getBuffer(void) noexcept return this->buffer.getBuffer(); } -} // namespace transport +} // namespace rmi } // namespace vist diff --git a/src/vist/transport/message.hpp b/src/vist/rmi/message.hpp similarity index 89% rename from src/vist/transport/message.hpp rename to src/vist/rmi/message.hpp index 55dd5b5..4aca730 100644 --- a/src/vist/transport/message.hpp +++ b/src/vist/rmi/message.hpp @@ -13,12 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License */ -/* - * @file message.hpp - * @author Jaemin Ryu (jm77.ryu@samsung.com) - * @author Sangwan Kwon (sangwan.kwon@samsung.com) - * @brief The unit of socket communication. - */ #pragma once @@ -28,7 +22,7 @@ #include namespace vist { -namespace transport { +namespace rmi { struct Message final { enum Type : unsigned int { @@ -88,5 +82,5 @@ void Message::disclose(Args&... args) this->buffer.unpack(args...); } -} // namespace transport +} // namespace rmi } // namespace vist diff --git a/src/vist/rmi/remote.cpp b/src/vist/rmi/remote.cpp index 6ea77d7..d2ff1e6 100644 --- a/src/vist/rmi/remote.cpp +++ b/src/vist/rmi/remote.cpp @@ -13,16 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License */ -/* - * @file remote.cpp - * @author Sangwan Kwon (sangwan.kwon@samsung.com) - * @author Jaemin Ryu (jm77.ryu@samsung.com) - * @brief Implementation of remote. - */ #include "remote.hpp" -#include +#include #include #include @@ -30,7 +24,7 @@ namespace vist { namespace rmi { -using namespace vist::transport; +using namespace vist::rmi::impl; class Remote::Impl { public: diff --git a/src/vist/rmi/remote.hpp b/src/vist/rmi/remote.hpp index 4dd64f4..5896e39 100644 --- a/src/vist/rmi/remote.hpp +++ b/src/vist/rmi/remote.hpp @@ -13,17 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License */ -/* - * @file remote.hpp - * @author Sangwan Kwon (sangwan.kwon@samsung.com) - * @author Jaemin Ryu (jm77.ryu@samsung.com) - * @brief Client-side stub for invoking remote method. - */ #pragma once #include -#include +#include #include #include @@ -33,8 +27,6 @@ namespace vist { namespace rmi { -using namespace vist::transport; - class Remote final { public: explicit Remote(const std::string& path); diff --git a/src/vist/rmi/tests/rmi.cpp b/src/vist/rmi/tests/rmi.cpp index d73663e..c5de56f 100644 --- a/src/vist/rmi/tests/rmi.cpp +++ b/src/vist/rmi/tests/rmi.cpp @@ -13,12 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License */ -/* - * @file rmi.cpp - * @author Sangwan Kwon (sangwan.kwon@samsung.com) - * @brief Testcases of rmi. - */ - #include #include diff --git a/src/vist/transport/CMakeLists.txt b/src/vist/transport/CMakeLists.txt deleted file mode 100644 index 451f12a..0000000 --- a/src/vist/transport/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License - -ADD_VIST_COMMON_LIBRARY(vist_transport message.cpp - protocol.cpp) - -FILE(GLOB TRANSPORT_TESTS "tests/*.cpp") -ADD_VIST_TEST(${TRANSPORT_TESTS}) diff --git a/src/vist/transport/systemd-socket.hpp b/src/vist/transport/systemd-socket.hpp deleted file mode 100644 index 4d768ed..0000000 --- a/src/vist/transport/systemd-socket.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -#pragma once - -#include -#include - -#include - -namespace vist { -namespace transport { - -class SystemdSocket { -public: - static int Create(const std::string& path) - { - static int fds = -1; - - if (fds == -1) - fds = ::sd_listen_fds(0); - - if (fds < 0) - THROW(ErrCode::RuntimeError) << "Failed to get listened systemd fds."; - - for (int fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + fds; ++fd) { - if (::sd_is_socket_unix(fd, SOCK_STREAM, 1, path.c_str(), 0) > 0) { - INFO(VIST) << "Systemd socket of service is found with fd: " << fd; - return fd; - } - } - - THROW(ErrCode::RuntimeError) << "Failed to find listened systemd fds."; - } -}; - -} // namespace transport -} // namespace vist -- 2.7.4