From f62b9e6ec07a9722c6418f7411c051883145def6 Mon Sep 17 00:00:00 2001 From: Flavien Chenu Date: Mon, 25 Mar 2024 12:59:53 +0100 Subject: [PATCH 1/2] refactor: update CMakeLists and some includes directives --- CMakeLists.txt | 2 -- common/games/IGameProvider.hpp | 2 +- common/types/Libraries.hpp | 4 ++-- common/types/types.hpp | 1 - games/snake/CMakeLists.txt | 8 ++++---- games/snake/export.cpp | 21 +++++++++++++++++++++ games/snake/src/main.cpp | 13 ------------- graphics/ncurses/CMakeLists.txt | 8 ++++---- graphics/ncurses/export.cpp | 22 ++++++++++++++++++++++ graphics/ncurses/src/main.cpp | 13 ------------- 10 files changed, 54 insertions(+), 40 deletions(-) create mode 100644 games/snake/export.cpp delete mode 100644 games/snake/src/main.cpp create mode 100644 graphics/ncurses/export.cpp delete mode 100644 graphics/ncurses/src/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c3e8e4..b23028f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,5 +14,3 @@ set(CMAKE_SHARED_LIBRARY_PREFIX "arcade_") add_subdirectory(core) add_subdirectory(games) add_subdirectory(graphics) - -target_include_directories (arcade PUBLIC ${CMAKE_CURRENT_LIST_DIR}/common/) diff --git a/common/games/IGameProvider.hpp b/common/games/IGameProvider.hpp index ddb2bcd..b0bb274 100644 --- a/common/games/IGameProvider.hpp +++ b/common/games/IGameProvider.hpp @@ -12,7 +12,7 @@ #include "types/GameManifest.hpp" namespace shared::games { - class IGameProvider; + class IGameProvider; } class shared::games::IGameProvider diff --git a/common/types/Libraries.hpp b/common/types/Libraries.hpp index 999c223..9711994 100644 --- a/common/types/Libraries.hpp +++ b/common/types/Libraries.hpp @@ -23,7 +23,7 @@ namespace shared::types GRAPHIC, } LibraryType; - typedef std::shared_ptr (*GameProvider)(void); - typedef std::shared_ptr (*GraphicsProvider)(void); + typedef std::shared_ptr (*GameProvider)(void); + typedef std::shared_ptr (*GraphicsProvider)(void); typedef LibraryType (*LibraryTypeGetter)(void); } diff --git a/common/types/types.hpp b/common/types/types.hpp index dcfa739..2fa7a26 100644 --- a/common/types/types.hpp +++ b/common/types/types.hpp @@ -9,4 +9,3 @@ #include "Vector.hpp" #include "UUId.hpp" -#include "Libraries.hpp" diff --git a/games/snake/CMakeLists.txt b/games/snake/CMakeLists.txt index dab7a02..619422c 100644 --- a/games/snake/CMakeLists.txt +++ b/games/snake/CMakeLists.txt @@ -1,5 +1,5 @@ -project(snake) - -add_library(${PROJECT_NAME} SHARED - src/main.cpp +add_library(snake SHARED + export.cpp ) +target_include_directories(snake PUBLIC ${CMAKE_CURRENT_LIST_DIR}/src) +target_include_directories(snake PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../..) diff --git a/games/snake/export.cpp b/games/snake/export.cpp new file mode 100644 index 0000000..facedea --- /dev/null +++ b/games/snake/export.cpp @@ -0,0 +1,21 @@ +/* +** EPITECH PROJECT, 2024 +** arcade-shared +** File description: +** export +*/ + +#include "common/games/IGameProvider.hpp" +#include "common/types/Libraries.hpp" + +extern "C" { + shared::types::LibraryType SHARED_LIBRARY_TYPE_GETTER_NAME(void) + { + return shared::types::LibraryType::GAME; + } + +/* std::shared_ptr SHARED_GAME_PROVIDER_LOADER_NAME(void) + { + return std::make_shared(...) + }*/ +} diff --git a/games/snake/src/main.cpp b/games/snake/src/main.cpp deleted file mode 100644 index c17bdd9..0000000 --- a/games/snake/src/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade -** File description: -** main -*/ - -int main(int ac, char **av) -{ - (void) ac; - (void) av; - return 0; -} diff --git a/graphics/ncurses/CMakeLists.txt b/graphics/ncurses/CMakeLists.txt index fc9d7f8..8abe0ed 100644 --- a/graphics/ncurses/CMakeLists.txt +++ b/graphics/ncurses/CMakeLists.txt @@ -1,5 +1,5 @@ -project(ncurses) - -add_library(${PROJECT_NAME} SHARED - src/main.cpp +add_library(ncurses SHARED + export.cpp ) +target_include_directories(ncurses PUBLIC ${CMAKE_CURRENT_LIST_DIR}/src) +target_include_directories(ncurses PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../..) diff --git a/graphics/ncurses/export.cpp b/graphics/ncurses/export.cpp new file mode 100644 index 0000000..4e047b7 --- /dev/null +++ b/graphics/ncurses/export.cpp @@ -0,0 +1,22 @@ +/* +** EPITECH PROJECT, 2024 +** arcade-shared +** File description: +** export +*/ + +#include "common/games/IGameProvider.hpp" +#include "common/types/Libraries.hpp" + +extern "C" { + shared::types::LibraryType SHARED_LIBRARY_TYPE_GETTER_NAME(void) + { + return shared::types::LibraryType::GRAPHIC; + } + +/* std::shared_ptr SHARED_GRAPHICS_PROVIDER_LOADER_NAME(void) + { + return std::make_shared(...); + }*/ +} + diff --git a/graphics/ncurses/src/main.cpp b/graphics/ncurses/src/main.cpp deleted file mode 100644 index c17bdd9..0000000 --- a/graphics/ncurses/src/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade -** File description: -** main -*/ - -int main(int ac, char **av) -{ - (void) ac; - (void) av; - return 0; -} From d85b215a3a3b2cb16b38fce5b273744c045bc591 Mon Sep 17 00:00:00 2001 From: Flavien Chenu Date: Mon, 25 Mar 2024 13:01:03 +0100 Subject: [PATCH 2/2] refactor: update common library --- common/games/IGameProvider.hpp | 2 +- common/games/components/IComponent.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/games/IGameProvider.hpp b/common/games/IGameProvider.hpp index b0bb274..ddb2bcd 100644 --- a/common/games/IGameProvider.hpp +++ b/common/games/IGameProvider.hpp @@ -12,7 +12,7 @@ #include "types/GameManifest.hpp" namespace shared::games { - class IGameProvider; + class IGameProvider; } class shared::games::IGameProvider diff --git a/common/games/components/IComponent.hpp b/common/games/components/IComponent.hpp index a0be931..4ee1093 100644 --- a/common/games/components/IComponent.hpp +++ b/common/games/components/IComponent.hpp @@ -45,5 +45,5 @@ class shared::games::components::IComponent { * * @return Entity of the component */ - virtual std::shared_ptr getEntity() noexcept = 0; + virtual const entity::IEntity &getEntity() noexcept = 0; };