Bläddra i källkod

Separate interface module from core module

Patrick-Christopher Mattulat 1 vecka sedan
förälder
incheckning
a215f7cb63

+ 37 - 6
CMakeLists.txt

@@ -16,6 +16,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
 ################################
 
 set(MODULE_NAME_CORE ls-atlantis-core)
+set(MODULE_NAME_INTERFACE ls-atlantis-interface)
 
 include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
 
@@ -25,13 +26,18 @@ include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
 
 find_package(GTest REQUIRED)
 
+################################################################
+################################################################
+# Module: Core
+################################################################
+################################################################
+
 ################################
 # Source Files: Core Module
 ################################
 
 set(ATLANTIS_CORE_SOURCES
-    ${CMAKE_CURRENT_SOURCE_DIR}/source/IWindowApi.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/source/StatusCode.cpp
+        ${CMAKE_CURRENT_SOURCE_DIR}/source/core/StatusCodeOk.cpp
 )
 
 ################################
@@ -40,12 +46,16 @@ set(ATLANTIS_CORE_SOURCES
 
 add_library(${MODULE_NAME_CORE} SHARED ${ATLANTIS_CORE_SOURCES})
 
+target_link_libraries(${MODULE_NAME_CORE} PUBLIC
+    ${MODULE_NAME_INTERFACE}
+)
+
 ################################
 # Test Files: Core Module
 ################################
 
 set(ATLANTIS_CORE_TEST_SOURCES
-    ${CMAKE_CURRENT_SOURCE_DIR}/test/core/StatusCodeTest.cpp
+        ${CMAKE_CURRENT_SOURCE_DIR}/test/core/StatusCodeOkTest.cpp
 )
 
 ################################
@@ -54,12 +64,33 @@ set(ATLANTIS_CORE_TEST_SOURCES
 
 enable_testing()
 
-add_executable(atlantis-core-tests ${ATLANTIS_CORE_TEST_SOURCES})
+add_executable(${MODULE_NAME_CORE}-tests ${ATLANTIS_CORE_TEST_SOURCES})
 
-target_link_libraries(atlantis-core-tests PRIVATE
+target_link_libraries(${MODULE_NAME_CORE}-tests PRIVATE
     ${MODULE_NAME_CORE}
     GTest::gtest_main
 )
 
 include(GoogleTest)
-gtest_discover_tests(atlantis-core-tests)
+gtest_discover_tests(${MODULE_NAME_CORE}-tests)
+
+################################################################
+################################################################
+# Module: Interface
+################################################################
+################################################################
+
+################################
+# Source Files: Interface Module
+################################
+
+set(ATLANTIS_INTERFACE_SOURCES
+        ${CMAKE_CURRENT_SOURCE_DIR}/source/interface/AStatusCode.cpp
+        ${CMAKE_CURRENT_SOURCE_DIR}/source/interface/IWindowApi.cpp
+)
+
+################################
+# Library Creation: Interface Module
+################################
+
+add_library(${MODULE_NAME_INTERFACE} SHARED ${ATLANTIS_INTERFACE_SOURCES})

+ 1 - 1
doc/coding-guidelines.md

@@ -33,4 +33,4 @@ The following naming conventions must be met for code contribution:
 The following source code creation guidelines must be followed:
 
 1. In source code (.cpp files) namespaces must not be used throughout the code and must be announced through the __using__ keyword after the imports (e.g. using ls::std::boxing::Integer). The only exception is when the same class name is being used in more than one namespace.
-2. Include directives in header files must be used with angle brackets. Include paths are handled via CMake. The only exception to that rule is a header file, which is located in the same directory. On the contrary, include directives in source files must always be in angle brackets writing.
+2. Include directives in header files must be used with angle brackets. Include paths are handled via CMake. Include directives in source files must always be in angle brackets writing.

+ 0 - 24
include/core/IWindowApi.hpp

@@ -1,24 +0,0 @@
-/*
- * author: Patrick-Christopher Mattulat
- * e-mail: webmaster@lynarstudios.com
- */
-
-#ifndef LS_ATLANTIS_ENGINE_CORE_I_WINDOW_API_HPP
-#define LS_ATLANTIS_ENGINE_CORE_I_WINDOW_API_HPP
-
-#include "StatusCode.hpp"
-
-namespace ls::atlantis::core::interfaces
-{
-  class IWindowApi
-  {
-    public:
-
-      IWindowApi();
-      virtual ~IWindowApi();
-
-      virtual StatusCode init() = 0;
-  };
-}
-
-#endif

+ 0 - 31
include/core/StatusCode.hpp

@@ -1,31 +0,0 @@
-/*
- * author: Patrick-Christopher Mattulat
- * e-mail: webmaster@lynarstudios.com
- */
-
-#ifndef LS_ATLANTIS_ENGINE_CORE_STATUS_CODE_HPP
-#define LS_ATLANTIS_ENGINE_CORE_STATUS_CODE_HPP
-
-#include <Export.hpp>
-#include <string>
-
-namespace ls::atlantis::core
-{
-  class LS_ATLANTIS_DYNAMIC_GOAL StatusCode
-  {
-    public:
-
-      explicit StatusCode(const uint16_t &_statusId, ::std::string _statusText);
-      ~StatusCode();
-
-      [[nodiscard]] uint16_t getId() const;
-      [[nodiscard]] ::std::string getText() const;
-
-    private:
-
-      uint16_t statusId{};
-      ::std::string statusText{};
-  };
-}
-
-#endif

+ 24 - 0
include/core/StatusCodeOk.hpp

@@ -0,0 +1,24 @@
+/*
+ * author: Patrick-Christopher Mattulat
+ * e-mail: webmaster@lynarstudios.com
+ */
+
+#ifndef LS_ATLANTIS_ENGINE_CORE_STATUS_CODE_HPP
+#define LS_ATLANTIS_ENGINE_CORE_STATUS_CODE_HPP
+
+#include <Export.hpp>
+#include <interface/AStatusCode.hpp>
+#include <string>
+
+namespace ls::atlantis::core
+{
+  class LS_ATLANTIS_DYNAMIC_GOAL StatusCodeOk : public ls::atlantis::interfaces::AStatusCode
+  {
+    public:
+
+      StatusCodeOk();
+      ~StatusCodeOk() override;
+  };
+}
+
+#endif

+ 31 - 0
include/interface/AStatusCode.hpp

@@ -0,0 +1,31 @@
+/*
+ * author: Patrick-Christopher Mattulat
+ * e-mail: webmaster@lynarstudios.com
+ */
+
+#ifndef LS_ATLANTIS_ENGINE_INTERFACE_STATUS_CODE_HPP
+#define LS_ATLANTIS_ENGINE_INTERFACE_STATUS_CODE_HPP
+
+#include <Export.hpp>
+#include <string>
+
+namespace ls::atlantis::interfaces
+{
+  class LS_ATLANTIS_DYNAMIC_GOAL AStatusCode
+  {
+    public:
+
+      explicit AStatusCode(const uint16_t &_statusId, ::std::string _statusText);
+      virtual ~AStatusCode();
+
+      [[nodiscard]] virtual uint16_t getId() const;
+      [[nodiscard]] virtual ::std::string getText() const;
+
+    private:
+
+      uint16_t statusId{};
+      ::std::string statusText{};
+  };
+}
+
+#endif

+ 26 - 0
include/interface/IWindowApi.hpp

@@ -0,0 +1,26 @@
+/*
+ * author: Patrick-Christopher Mattulat
+ * e-mail: webmaster@lynarstudios.com
+ */
+
+#ifndef LS_ATLANTIS_ENGINE_INTERFACE_WINDOW_API_HPP
+#define LS_ATLANTIS_ENGINE_INTERFACE_WINDOW_API_HPP
+
+#include <Export.hpp>
+#include <interface/AStatusCode.hpp>
+#include <memory>
+
+namespace ls::atlantis::interfaces
+{
+  class LS_ATLANTIS_DYNAMIC_GOAL IWindowApi
+  {
+    public:
+
+      IWindowApi();
+      virtual ~IWindowApi();
+
+      virtual std::shared_ptr<AStatusCode> init() = 0;
+  };
+}
+
+#endif

+ 0 - 25
source/StatusCode.cpp

@@ -1,25 +0,0 @@
-/*
- * author: Patrick-Christopher Mattulat
- * e-mail: webmaster@lynarstudios.com
- */
-
-#include <core/StatusCode.hpp>
-
-using ls::atlantis::core::StatusCode;
-using ::std::move;
-using ::std::string;
-
-StatusCode::StatusCode(const uint16_t &_statusId, string _statusText) : statusId(_statusId), statusText(::move(_statusText))
-{}
-
-StatusCode::~StatusCode() = default;
-
-uint16_t StatusCode::getId() const
-{
-  return this->statusId;
-}
-
-string StatusCode::getText() const
-{
-  return this->statusText;
-}

+ 16 - 0
source/core/StatusCodeOk.cpp

@@ -0,0 +1,16 @@
+/*
+ * author: Patrick-Christopher Mattulat
+ * e-mail: webmaster@lynarstudios.com
+ */
+
+#include <core/StatusCodeOk.hpp>
+
+using ls::atlantis::core::StatusCodeOk;
+using ls::atlantis::interfaces::AStatusCode;
+using ::std::move;
+using ::std::string;
+
+StatusCodeOk::StatusCodeOk() : AStatusCode(1, "ok")
+{}
+
+StatusCodeOk::~StatusCodeOk() = default;

+ 25 - 0
source/interface/AStatusCode.cpp

@@ -0,0 +1,25 @@
+/*
+ * author: Patrick-Christopher Mattulat
+ * e-mail: webmaster@lynarstudios.com
+ */
+
+#include <interface/AStatusCode.hpp>
+
+using ls::atlantis::interfaces::AStatusCode;
+using ::std::move;
+using ::std::string;
+
+AStatusCode::AStatusCode(const uint16_t &_statusId, string _statusText) : statusId(_statusId), statusText(::move(_statusText))
+{}
+
+AStatusCode::~AStatusCode() = default;
+
+uint16_t AStatusCode::getId() const
+{
+  return this->statusId;
+}
+
+string AStatusCode::getText() const
+{
+  return this->statusText;
+}

+ 2 - 2
source/IWindowApi.cpp → source/interface/IWindowApi.cpp

@@ -3,9 +3,9 @@
  * e-mail: webmaster@lynarstudios.com
  */
 
-#include <core/IWindowApi.hpp>
+#include <interface/IWindowApi.hpp>
 
-using ls::atlantis::core::interfaces::IWindowApi;
+using ls::atlantis::interfaces::IWindowApi;
 
 IWindowApi::IWindowApi() = default;
 

+ 32 - 0
test/core/StatusCodeOkTest.cpp

@@ -0,0 +1,32 @@
+/*
+ * author: Patrick-Christopher Mattulat
+ * e-mail: webmaster@lynarstudios.com
+ */
+
+#include <core/StatusCodeOk.hpp>
+#include <gtest/gtest.h>
+
+using ls::atlantis::core::StatusCodeOk;
+using ::std::string;
+using ::testing::Test;
+
+namespace
+{
+  class StatusCodeOkTest : public Test
+  {
+    public:
+
+      StatusCodeOkTest() = default;
+      ~StatusCodeOkTest() override = default;
+  };
+
+  TEST_F(StatusCodeOkTest, getId)
+  {
+    ASSERT_EQ(1, StatusCodeOk().getId());
+  }
+
+  TEST_F(StatusCodeOkTest, getText)
+  {
+    ASSERT_EQ(string("ok"), StatusCodeOk().getText());
+  }
+}

+ 0 - 32
test/core/StatusCodeTest.cpp

@@ -1,32 +0,0 @@
-/*
- * author: Patrick-Christopher Mattulat
- * e-mail: webmaster@lynarstudios.com
- */
-
-#include <core/StatusCode.hpp>
-#include <gtest/gtest.h>
-
-using ls::atlantis::core::StatusCode;
-using ::std::string;
-using ::testing::Test;
-
-namespace
-{
-  class StatusCodeTest : public Test
-  {
-    public:
-
-      StatusCodeTest() = default;
-      ~StatusCodeTest() override = default;
-  };
-
-  TEST_F(StatusCodeTest, getId)
-  {
-    ASSERT_EQ(42, StatusCode(42, "ok").getId());
-  }
-
-  TEST_F(StatusCodeTest, getText)
-  {
-    ASSERT_EQ(string("ok"), StatusCode(42, "ok").getText());
-  }
-}