diff --git a/core/main.cpp b/core/main.cpp index 6e160ea..4c9f92b 100644 --- a/core/main.cpp +++ b/core/main.cpp @@ -5,11 +5,11 @@ ** main */ -#include "loader/DLLoader.hpp" +#include "loader/Loader.hpp" int main(void) { - DLLoader loader; + Loader loader; try { loader.loadLibraries("./lib"); diff --git a/core/src/CMakeLists.txt b/core/src/CMakeLists.txt index a72ba11..ea744bc 100644 --- a/core/src/CMakeLists.txt +++ b/core/src/CMakeLists.txt @@ -1,2 +1,3 @@ add_subdirectory(exception) add_subdirectory(loader) +add_subdirectory(utils) diff --git a/core/src/loader/CMakeLists.txt b/core/src/loader/CMakeLists.txt index 00db786..99592b3 100644 --- a/core/src/loader/CMakeLists.txt +++ b/core/src/loader/CMakeLists.txt @@ -1,3 +1,3 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE - DLLoader.cpp + Loader.cpp ) diff --git a/core/src/loader/DLLoader.cpp b/core/src/loader/DLLoader.cpp deleted file mode 100644 index db5df71..0000000 --- a/core/src/loader/DLLoader.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade -** File description: -** DLLoader -*/ - -#include -#include -#include -#include "DLLoader.hpp" -#include "exception/ArcadeError.hpp" - -void DLLoader::_throwLoadError(void *handle) { - std::string error = dlerror(); - - if (this->_dir) - closedir(this->_dir); - if (handle) - dlclose(handle); - throw ArcadeError(error.length() ? error : "Unknown error while loading library"); -} - -shared::types::LibraryType DLLoader::_getLibraryGetter(const std::string &filepath, void *handle) { - shared::types::LibraryTypeGetter getter = nullptr; - - getter = reinterpret_cast(dlsym(handle, SHARED_STRINGIFY(SHARED_LIBRARY_TYPE_GETTER_NAME))); - if (!getter) - this->_throwLoadError(handle); - return getter(); -} - -void DLLoader::_loadGameLibrary(const std::string &filepath, void *handle) { - shared::types::GameProvider game = nullptr; - - game = reinterpret_cast(dlsym(handle, SHARED_STRINGIFY(SHARED_GAME_PROVIDER_LOADER_NAME))); - if (!game) - this->_throwLoadError(handle); - this->_gamesLibraries.push_back(game()); -} - -void DLLoader::_loadGraphicsLibrary(const std::string &filepath, void *handle) { - shared::types::GraphicsProvider graphics = nullptr; - - graphics = reinterpret_cast(dlsym(handle, SHARED_STRINGIFY(SHARED_GRAPHICS_PROVIDER_LOADER_NAME))); - if (!graphics) - this->_throwLoadError(handle); - this->_graphicsLibraries.push_back(graphics()); -} - -void DLLoader::registerLibrary(const std::string &filepath) { - void *handle = dlopen(filepath.c_str(), RTLD_LAZY);; - shared::types::LibraryType type; - - if (!handle) - this->_throwLoadError(handle); - dlerror(); - type = this->_getLibraryGetter(filepath, handle); - if (type == shared::types::LibraryType::GAME) - return this->_loadGameLibrary(filepath, handle); - else if (type == shared::types::LibraryType::GRAPHIC) - return this->_loadGraphicsLibrary(filepath, handle); - dlclose(handle); - if (this->_dir) - closedir(this->_dir); - throw ArcadeError(filepath + ": Unknown library type!"); -} - -void DLLoader::loadLibraries(std::string path) { - struct dirent *ent; - - this->_dir = opendir(path.c_str()); - if (!this->_dir) - throw ArcadeError("Cannot open directory: " + path); - ent = readdir(this->_dir); - while (ent) { - if (ent->d_name[0] == '.') { - ent = readdir(this->_dir); - continue; - } - this->registerLibrary(path + "/" + ent->d_name); - ent = readdir(this->_dir); - } - closedir(this->_dir); -} - -const GameProviders &DLLoader::getGamesLibraries() const { - return this->_gamesLibraries; -} - -const GraphicsProviders &DLLoader::getGraphicsLibraries() const { - return this->_graphicsLibraries; -} diff --git a/core/src/loader/Loader.cpp b/core/src/loader/Loader.cpp new file mode 100644 index 0000000..997b504 --- /dev/null +++ b/core/src/loader/Loader.cpp @@ -0,0 +1,64 @@ +/* +** EPITECH PROJECT, 2024 +** arcade +** File description: +** Loader +*/ + +#include +#include "Loader.hpp" +#include "exception/ArcadeError.hpp" + +Loader::Loader() {} + +Loader::~Loader() {} + +shared::types::LibraryType Loader::_getLibraryGetter(const std::string &filepath, DLLoader &dlLoader) { + shared::types::LibraryTypeGetter getter = nullptr; + + getter = dlLoader.loadSymbol(SHARED_STRINGIFY(SHARED_LIBRARY_TYPE_GETTER_NAME)); + return getter(); +} + +void Loader::_loadGameLibrary(const std::string &filepath, DLLoader &dlLoader) { + shared::types::GameProviderGetter game = nullptr; + + game = dlLoader.loadSymbol(SHARED_STRINGIFY(SHARED_GAME_PROVIDER_GETTER_NAME)); + this->_gamesLibraries.push_back(std::unique_ptr(game())); +} + +void Loader::_loadGraphicsLibrary(const std::string &filepath, DLLoader &dlLoader) { + shared::types::GraphicsProviderGetter graphics = nullptr; + + graphics = dlLoader.loadSymbol(SHARED_STRINGIFY(SHARED_GRAPHICS_PROVIDER_GETTER_NAME)); + this->_graphicsLibraries.push_back(std::unique_ptr(graphics())); +} + +void Loader::registerLibrary(const std::string &filepath) { + shared::types::LibraryType type; + DLLoader dlLoader(filepath); + + dlLoader.open(); + type = this->_getLibraryGetter(filepath, dlLoader); + if (type == shared::types::LibraryType::GAME) + this->_loadGameLibrary(filepath, dlLoader); + else if (type == shared::types::LibraryType::GRAPHIC) + this->_loadGraphicsLibrary(filepath, dlLoader); + else + throw ArcadeError(filepath + ": Unknown library type!"); +} + +void Loader::loadLibraries(std::string path) { + for (const auto &entry : std::filesystem::directory_iterator(path)) { + if (entry.is_regular_file() && entry.path().extension() == ".so") + this->registerLibrary(entry.path()); + } +} + +const GameProviders &Loader::getGamesLibraries() const { + return this->_gamesLibraries; +} + +const GraphicsProviders &Loader::getGraphicsLibraries() const { + return this->_graphicsLibraries; +} diff --git a/core/src/loader/DLLoader.hpp b/core/src/loader/Loader.hpp similarity index 74% rename from core/src/loader/DLLoader.hpp rename to core/src/loader/Loader.hpp index b204b4d..809c326 100644 --- a/core/src/loader/DLLoader.hpp +++ b/core/src/loader/Loader.hpp @@ -2,18 +2,28 @@ ** EPITECH PROJECT, 2024 ** arcade ** File description: -** DLLoader +** Loader */ #pragma once -#include #include #include "types/Providers.hpp" +#include "utils/DLLoader/DLLoader.hpp" -class DLLoader { +class Loader { public: + /** + * @brief Construct a new Loader object + */ + Loader(); + + /** + * @brief Destroy the Loader object + */ + ~Loader(); + /** * @brief Register a library * @param path std::string @@ -39,7 +49,6 @@ class DLLoader { const GraphicsProviders &getGraphicsLibraries() const; private: - DIR *_dir; const std::string _path; GameProviders _gamesLibraries; GraphicsProviders _graphicsLibraries; @@ -47,28 +56,26 @@ class DLLoader { /** * @brief Get the Library Getter object * @param filepath file path of the library - * @param handle handle pointer to the library * @return getter function */ - shared::types::LibraryType _getLibraryGetter(const std::string &filepath, void *handle); + shared::types::LibraryType _getLibraryGetter(const std::string &filepath, DLLoader &dlLoader); /** * @brief Load a game library * @param filepath file path of the library * @param handle handle pointer to the library */ - void _loadGameLibrary(const std::string &filepath, void *handle); + void _loadGameLibrary(const std::string &filepath, DLLoader &dlLoader); /** * @brief Load a graphics library * @param filepath file path of the library - * @param handle handle pointer to the library */ - void _loadGraphicsLibrary(const std::string &filepath, void *handle); + void _loadGraphicsLibrary(const std::string &filepath, DLLoader &dlLoader); /** * @brief Throw an error when loading a library - * @param handle handle pointer to the library + * @param e exception */ - void _throwLoadError(void *handle); + void _throwError(std::exception const &e); }; diff --git a/core/src/types/Providers.hpp b/core/src/types/Providers.hpp index 518f976..c40fb9e 100644 --- a/core/src/types/Providers.hpp +++ b/core/src/types/Providers.hpp @@ -9,5 +9,5 @@ #include "shared/types/Libraries.hpp" -typedef std::vector> GameProviders; -typedef std::vector> GraphicsProviders; +typedef std::vector> GameProviders; +typedef std::vector> GraphicsProviders; diff --git a/core/src/utils/CMakeLists.txt b/core/src/utils/CMakeLists.txt new file mode 100644 index 0000000..97ec257 --- /dev/null +++ b/core/src/utils/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(DLLoader) diff --git a/core/src/utils/DLLoader/CMakeLists.txt b/core/src/utils/DLLoader/CMakeLists.txt new file mode 100644 index 0000000..00db786 --- /dev/null +++ b/core/src/utils/DLLoader/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${CMAKE_PROJECT_NAME} PRIVATE + DLLoader.cpp +) diff --git a/core/src/utils/DLLoader/DLLoader.cpp b/core/src/utils/DLLoader/DLLoader.cpp new file mode 100644 index 0000000..d7f7221 --- /dev/null +++ b/core/src/utils/DLLoader/DLLoader.cpp @@ -0,0 +1,38 @@ +/* +** EPITECH PROJECT, 2024 +** arcade +** File description: +** DLLoader +*/ + +#include "DLLoader.hpp" + +void DLLoader::_throwError() { + std::string error = dlerror(); + + throw DLLoaderExeption(error.empty() ? "Unknown error while loading library" : error); +} + +DLLoader::DLLoader(const std::string &filepath) : _filepath(filepath) { + this->_handle = nullptr; +} + +DLLoader::~DLLoader() { + if (this->_handle) + dlclose(this->_handle); +} + +void DLLoader::open(DLLoader::LoadingMode mode) { + if (this->_handle) + dlclose(this->_handle); + this->_handle = dlopen(this->_filepath.c_str(), mode); + if (!this->_handle) + this->_throwError(); + dlerror(); +} + +DLLoader::DLLoaderExeption::DLLoaderExeption(const std::string &message) : _message(message) {} + +const char *DLLoader::DLLoaderExeption::what() const noexcept { + return this->_message.c_str(); +} diff --git a/core/src/utils/DLLoader/DLLoader.hpp b/core/src/utils/DLLoader/DLLoader.hpp new file mode 100644 index 0000000..13303a7 --- /dev/null +++ b/core/src/utils/DLLoader/DLLoader.hpp @@ -0,0 +1,79 @@ +/* +** EPITECH PROJECT, 2024 +** arcade +** File description: +** DLLoader +*/ + +#pragma once + +#include +#include + +class DLLoader { + public: + + /** + * @brief Construct a new DLLoader object + * + * @param filepath File path of the library + */ + DLLoader(const std::string &filepath); + + ~DLLoader(); + + typedef enum { + LAZY = RTLD_LAZY, + NOW = RTLD_NOW, + LOCAL = RTLD_LOCAL, + GLOBAL = RTLD_GLOBAL, + NODELETE = RTLD_NODELETE, + DEEPBIND = RTLD_DEEPBIND, + NOLOAD = RTLD_NOLOAD + } LoadingMode; + + /** + * @brief Open the library + * + * @param mode Loading mode + */ + void open(LoadingMode mode = LAZY); + + /** + * @brief Get a function from the library + * + * @tparam T Function prototype + * @param name Symbol name + * @return T Function founded + */ + template + T loadSymbol(std::string name) { + if (!this->_handle) + throw DLLoaderExeption("Library not loaded"); + T symbol = reinterpret_cast(dlsym(this->_handle, name.c_str())); + if (!symbol) + this->_throwError(); + return symbol; + } + + class DLLoaderExeption : public std::exception { + public: + DLLoaderExeption(const std::string &message); + + const char *what() const noexcept override; + + private: + const std::string _message; + }; + + protected: + private: + void *_handle; + const std::string _filepath; + + /** + * @brief Throw an error + * + */ + void _throwError(); +}; diff --git a/shared/games/IEntity.hpp b/shared/games/IEntity.hpp index e251824..9741616 100644 --- a/shared/games/IEntity.hpp +++ b/shared/games/IEntity.hpp @@ -7,11 +7,9 @@ #pragma once -#include +#include #include -#include "../types/UUId.hpp" - namespace shared::games { class IGame; @@ -20,14 +18,15 @@ namespace shared::games { class IEntity; - typedef std::map> EntitiesMap; + typedef std::shared_ptr EntityPtr; + typedef std::vector EntitiesMap; } namespace components { class IComponent; - typedef std::map> ComponentsMap; + typedef std::vector> ComponentsMap; } } @@ -36,13 +35,6 @@ class shared::games::entity::IEntity public: virtual ~IEntity() = default; - /** - * @brief Get the id of the entity - * - * @return Entity unique id - */ - virtual const types::UUId &getId(void) const noexcept = 0; - /** * @brief Get the components of the entity * diff --git a/shared/games/IGame.hpp b/shared/games/IGame.hpp index 291ac21..bc8353d 100644 --- a/shared/games/IGame.hpp +++ b/shared/games/IGame.hpp @@ -9,7 +9,7 @@ #include #include "IEntity.hpp" -#include "../types/types.hpp" +#include "../types/Vector.hpp" #include "types/GameManifest.hpp" using namespace shared::types; @@ -36,27 +36,29 @@ class shared::games::IGame /** * @brief Manifest with informations of the game * + * @return Manifest of the game */ - virtual const GameManifest &getManifest(void) const noexcept = 0; + virtual const GameManifest &getManifest() const noexcept = 0; /** * @brief Number of tiles that represent the game * Tile size is managed by the renderer * + * @return The number of tiles of the game */ - virtual const Vector2u getSize(void) const noexcept = 0; + virtual const Vector2u getSize() const noexcept = 0; /** - * @brief Get map of entities + * @brief Get fps of the game * + * @return The number of frame per seconds of the game */ - virtual const entity::EntitiesMap &getEntities(void) const = 0; + virtual const unsigned int getFps() const noexcept = 0; /** - * @brief Get entity by id + * @brief Get map of entities * - * @param id Id of the entity - * @return The specific entity + * @return Entities map of the game */ - virtual std::shared_ptr getEntityById(const UUId &id) const = 0; + virtual const entity::EntitiesMap &getEntities(void) const = 0; }; diff --git a/shared/games/components/IComponent.hpp b/shared/games/components/IComponent.hpp index 4ee1093..e03cc51 100644 --- a/shared/games/components/IComponent.hpp +++ b/shared/games/components/IComponent.hpp @@ -8,42 +8,35 @@ #pragma once #include "../IEntity.hpp" -#include "../../types/UUId.hpp" namespace shared::games::components { - typedef enum { - DISPLAYABLE, - SOUND, - COLLIDABLE, - POSITION, - KEYBOARD - } ComponentType; - - class IComponent; + typedef enum { + TEXTURE, + TEXT, + SOUND, + COLLIDABLE, + POSITION, + KEYBOARD + } ComponentType; + + class IComponent; } class shared::games::components::IComponent { public: - virtual ~IComponent() = default; - - /** - * @brief Get the type of the component - * - * @return Type of the component - */ - virtual const ComponentType getType() const noexcept = 0; - - /** - * @brief Get the uuid of component - * - * @return Component id - */ - virtual const types::UUId &getId() const noexcept = 0; - - /** - * @brief Get the parent entity of the component - * - * @return Entity of the component - */ - virtual const entity::IEntity &getEntity() noexcept = 0; + virtual ~IComponent() = default; + + /** + * @brief Get the type of the component + * + * @return Type of the component + */ + virtual const ComponentType getType() const noexcept = 0; + + /** + * @brief Get the parent entity of the component + * + * @return Entity of the component + */ + virtual const entity::IEntity &getEntity() noexcept = 0; }; diff --git a/shared/games/components/IDisplayableComponent.hpp b/shared/games/components/IDisplayableComponent.hpp index c492e3b..0a60cec 100644 --- a/shared/games/components/IDisplayableComponent.hpp +++ b/shared/games/components/IDisplayableComponent.hpp @@ -1,8 +1,8 @@ /* ** EPITECH PROJECT, 2024 -** arcade-shared [WSL: Ubuntu-22.04] +** arcade-shared ** File description: -** ADisplaybleComponent +** IDisplaybleComponent */ #pragma once @@ -12,60 +12,40 @@ #include "../../types/Vector.hpp" namespace shared::games::components { - class IDisplayableComponent; - - typedef struct - { - const std::string ascii; // ASCII image representation path - const std::string bin; // Binary image path - Vector2f binTileSize; // Size of the binary tile - } TextureSources; - - typedef struct - { - TextureSources sources; // Sources of textures - Vector2u origin; // Origin of the texture - } TextureProps; + class IDisplayableComponent; } -class shared::games::components::IDisplayableComponent: public virtual IPositionComponent -{ +class shared::games::components::IDisplayableComponent : public virtual IPositionComponent { public: - virtual ~IDisplayableComponent() = default; + virtual ~IDisplayableComponent() = default; /** - * @brief Get size of the entity (tiles) - * - */ - virtual Vector2u &getSize(void) noexcept = 0; + * @brief Get size of the entity (tiles) + * + */ + virtual Vector2u &getSize() noexcept = 0; - /** - * @brief Get Z index that is usefull for display prioroty - * - */ - virtual unsigned int &getZIndex(void) noexcept = 0; - - /** - * @brief Get texture properties - * - */ - virtual TextureProps &getTextureProps(void) noexcept = 0; + /** + * @brief Get Z index that is usefull for display prioroty + * + */ + virtual unsigned int &getZIndex() noexcept = 0; - /** - * @brief On click event handler for the entity - * @param ctx Context of the game - */ - virtual void onMousePress(std::shared_ptr &ctx) = 0; + /** + * @brief On click event handler for the entity + * @param ctx Context of the game + */ + virtual void onMousePress(std::shared_ptr &ctx) = 0; - /** - * @brief On release event handler for the entity - * @param ctx Context of the game - */ - virtual void onMouseRelease(std::shared_ptr &ctx) = 0; + /** + * @brief On release event handler for the entity + * @param ctx Context of the game + */ + virtual void onMouseRelease(std::shared_ptr &ctx) = 0; - /** - * @brief On hover event handler for the entity - * @param ctx Context of the game - */ - virtual void onMouseHover(std::shared_ptr &ctx) = 0; + /** + * @brief On hover event handler for the entity + * @param ctx Context of the game + */ + virtual void onMouseHover(std::shared_ptr &ctx) = 0; }; diff --git a/shared/games/components/ITextComponent.hpp b/shared/games/components/ITextComponent.hpp new file mode 100644 index 0000000..655d45e --- /dev/null +++ b/shared/games/components/ITextComponent.hpp @@ -0,0 +1,53 @@ +/* +** EPITECH PROJECT, 2024 +** ITextComponent.hpp +** File description: +** ITextComponent class +*/ + +#pragma once + +#include "IDisplayableComponent.hpp" +#include "../../types/Vector.hpp" +#include "../../types/Color.hpp" + +namespace shared::games::components { + class ITextComponent; + + typedef enum { + LEFT, + CENTER, + RIGHT + } TextAlign; + + typedef enum { + BOTTOM, + MIDDLE, + TOP + } TextVerticalAlign; + + typedef struct { + std::string path; // Path of the font + unsigned int size; // Font size + } TextFontProps; + + typedef struct { + std::string content; // Content of the text + TextAlign align; // Alignment of the text + TextVerticalAlign verticalAlign; // Vertical alignment of the text + TextFontProps font; // Font of the text + types::Color color; // Color of the text + } TextProps; +} + +class shared::games::components::ITextComponent : public virtual IDisplayableComponent { +public: + virtual ~ITextComponent() = default; + + /** + * @brief Get text props of the entity + * + * @return text props + */ + virtual TextProps getTextProps() noexcept = 0; +}; diff --git a/shared/games/components/ITextureComponent.hpp b/shared/games/components/ITextureComponent.hpp new file mode 100644 index 0000000..930215c --- /dev/null +++ b/shared/games/components/ITextureComponent.hpp @@ -0,0 +1,38 @@ +/* +** EPITECH PROJECT, 2024 +** arcade-shared +** File description: +** ITextureComponent +*/ + +#pragma once + +#include "IDisplayableComponent.hpp" +#include "../IGame.hpp" +#include "../../types/Vector.hpp" + +namespace shared::games::components { + class ITextureComponent; + + typedef struct { + const std::string ascii; // ASCII image representation path + const std::string bin; // Binary image path + Vector2f binTileSize; // Size of the binary tile + } TextureSources; + + typedef struct { + TextureSources sources; // Sources of textures + Vector2u origin; // Origin of the texture + } TextureProps; +} + +class shared::games::components::ITextureComponent : public virtual IDisplayableComponent { +public: + virtual ~ITextureComponent() = default; + + /** + * @brief Get texture properties + * + */ + virtual TextureProps &getTextureProps() noexcept = 0; +}; diff --git a/shared/games/export.cpp.example b/shared/games/export.cpp.example index 12b4ae3..938943b 100644 --- a/shared/games/export.cpp.example +++ b/shared/games/export.cpp.example @@ -8,14 +8,17 @@ #include "IGame.hpp" #include "../types/Libraries.hpp" +using namespace shared::games; +using namespace shared::types; + extern "C" { - shared::types::LibraryType SHARED_LIBRARY_TYPE_GETTER_NAME(void) + LibraryType SHARED_LIBRARY_TYPE_GETTER_NAME(void) { - return shared::types::LibraryType::GAME; + return LibraryType::GAME; } - std::shared_ptr SHARED_GAME_PROVIDER_LOADER_NAME(void) + IGameProvider* SHARED_GAME_PROVIDER_GETTER_NAME(void) { - return std::make_shared(...) + return new YOUR_CLASS(); } } diff --git a/shared/games/types/GameManifest.hpp b/shared/games/types/GameManifest.hpp index 4c6efbf..25da00a 100644 --- a/shared/games/types/GameManifest.hpp +++ b/shared/games/types/GameManifest.hpp @@ -6,23 +6,22 @@ */ #pragma once + #include #include -namespace shared::games -{ - typedef struct - { - std::string name; // Name of the author - std::string email; // Public contact email - std::string website; // Website of the author (`github`, `gitlab`, etc.) - } Author; +namespace shared::games { + typedef struct { + std::string name; // Name of the author + std::string email; // Public contact email + std::string website; // Website of the author (`github`, `gitlab`, etc.) + } Author; - typedef struct - { - const std::string name; // Name of the game - const std::string description; // Description of the game - const std::string version; // Version of the game - const std::vector authors; // Authors - } GameManifest; + typedef struct { + const std::string name; // Name of the game + const std::string description; // Description of the game + const std::string version; // Version of the game + const std::vector authors; // Authors + const std::string iconPath; // Path of the icon game + } GameManifest; } diff --git a/shared/graphics/IFont.hpp b/shared/graphics/IFont.hpp new file mode 100644 index 0000000..63b7829 --- /dev/null +++ b/shared/graphics/IFont.hpp @@ -0,0 +1,17 @@ +/* +** EPITECH PROJECT, 2024 +** arcade-shared +** File description: +** IFont +*/ + +#pragma once + +namespace shared::graphics { + class IFont; +} + +class shared::graphics::IFont { + public: + virtual ~IFont() = default; +}; diff --git a/shared/graphics/IGraphicsProvider.hpp b/shared/graphics/IGraphicsProvider.hpp index 2d2b7cf..4200a5c 100644 --- a/shared/graphics/IGraphicsProvider.hpp +++ b/shared/graphics/IGraphicsProvider.hpp @@ -11,7 +11,7 @@ #include "ISound.hpp" #include "ITexture.hpp" -#include "window/IWindow.hpp" +#include "IWindow.hpp" #include "types/GraphicsManifest.hpp" namespace shared::graphics { @@ -22,7 +22,6 @@ class shared::graphics::IGraphicsProvider { public: virtual ~IGraphicsProvider() = default; - /** * @brief Get the manifest of the graphics library * @@ -31,12 +30,12 @@ class shared::graphics::IGraphicsProvider { virtual const GraphicsManifest &getManifest(void) const noexcept = 0; /** - * @brief Create a renderer object + * @brief Create a new window object * * @param windowProps Properties to use to init the window - * @return Created renderer object + * @return Created window object */ - virtual std::unique_ptr createWindow(const WindowInitProps &windowProps) = 0; + virtual std::unique_ptr createWindow(const IWindow::WindowInitProps &windowProps) = 0; /** * @brief Create a sound object @@ -54,4 +53,12 @@ class shared::graphics::IGraphicsProvider { * @return Created texture object */ virtual std::shared_ptr createTexture(const std::string &bin, const std::string &ascii) = 0; + + /** + * @brief Create a font object + * + * @param path Path of the font file + * @return Created font object + */ + virtual std::shared_ptr createFont(const std::string &path) = 0; }; diff --git a/shared/graphics/ISound.hpp b/shared/graphics/ISound.hpp index 96f192c..00da6af 100644 --- a/shared/graphics/ISound.hpp +++ b/shared/graphics/ISound.hpp @@ -10,20 +10,21 @@ namespace shared::graphics { class ISound; - - typedef unsigned char SoundVolume; - typedef enum - { - PLAY, - PAUSE, - STOP - } SoundState; } class shared::graphics::ISound { public: virtual ~ISound() = default; + typedef unsigned char SoundVolume; + + typedef enum + { + PLAY, + PAUSE, + STOP + } SoundState; + /** * @brief Get the state of the sound * diff --git a/shared/graphics/ITexture.hpp b/shared/graphics/ITexture.hpp index 69649da..f82f3e8 100644 --- a/shared/graphics/ITexture.hpp +++ b/shared/graphics/ITexture.hpp @@ -11,7 +11,7 @@ namespace shared::graphics { class ITexture; } -class ITexture { +class shared::graphics::ITexture { public: virtual ~ITexture() = default; }; diff --git a/shared/graphics/window/IWindow.hpp b/shared/graphics/IWindow.hpp similarity index 69% rename from shared/graphics/window/IWindow.hpp rename to shared/graphics/IWindow.hpp index 22f3fc3..ac1746a 100644 --- a/shared/graphics/window/IWindow.hpp +++ b/shared/graphics/IWindow.hpp @@ -9,36 +9,36 @@ #include #include +#include -#include "../events/IEvent.hpp" -#include "../../types/types.hpp" -#include "../types/EntityProps.hpp" +#include "events/IEvent.hpp" +#include "types/TextureProps.hpp" +#include "types/TextProps.hpp" using namespace shared::types; -namespace shared::graphics -{ +namespace shared::graphics { class IWindow; - - typedef enum - { - WINDOWED, - FULLSCREEN - } WindowMode; - - typedef struct { - Vector2u size; //Initial size of the window - WindowMode mode; //Initial mode of the window - unsigned int fps; //Initial framerate of the window - const std::string title; //Initial title of the window - const std::string icon; //Initial icon of the window - } WindowInitProps; } class shared::graphics::IWindow { public: virtual ~IWindow() = default; + typedef enum + { + WINDOWED, + FULLSCREEN + } WindowMode; + + typedef struct { + Vector2u size; //Initial size of the window + WindowMode mode; //Initial mode of the window + unsigned int fps; //Initial framerate of the window + const std::string title; //Initial title of the window + const std::string icon; //Initial icon of the window + } WindowInitProps; + /** * @brief Set the title of current window * @@ -46,13 +46,6 @@ class shared::graphics::IWindow { */ virtual void setTitle(const std::string &title) = 0; - /** - * @brief Get the title of current window - * - * @return Title of the window - */ - virtual std::string getTitle() const = 0; - /** * @brief Set the size of the window * @@ -103,18 +96,18 @@ class shared::graphics::IWindow { virtual void setIcon(const std::string &icon) = 0; /** - * @brief Get the icon of the window + * @brief Render the texture of entity with given properties * - * @return Icon object of the window + * @param props Properties of the entity & texture to render */ - virtual const std::string &getIcon(void) const = 0; + virtual void render(const TextureProps &props) = 0; /** - * @brief Render the entity with given properties + * @brief Render the text of entity with given properties * - * @param props Properties of the entity to render + * @param props Properties of the entity & text to render */ - virtual void render(const EntityProps &props) = 0; + virtual void render(const TextProps &props) = 0; /** * @brief Clear the content of the window @@ -150,5 +143,5 @@ class shared::graphics::IWindow { * but make another call `B` (directly after call `A`) `eventsB` * will result to an empty vector */ - virtual std::vector getEvents(void) = 0; + virtual std::vector getEvents(void) = 0; }; diff --git a/shared/graphics/events/IEvent.hpp b/shared/graphics/events/IEvent.hpp index ab455d0..84c9492 100644 --- a/shared/graphics/events/IEvent.hpp +++ b/shared/graphics/events/IEvent.hpp @@ -7,6 +7,8 @@ #pragma once +#include + namespace shared::graphics::events { class IEvent; @@ -21,6 +23,8 @@ namespace shared::graphics::events WINDOW_CLOSE, // Window closed WINDOW_RESIZE, // Window resized } EventType; + + typedef std::shared_ptr EventPtr; } class shared::graphics::events::IEvent @@ -31,5 +35,5 @@ class shared::graphics::events::IEvent /** * @brief Event type */ - virtual const EventType getType() const noexcept = 0; + virtual EventType getType() const noexcept = 0; }; diff --git a/shared/graphics/events/IKeyEvent.hpp b/shared/graphics/events/IKeyEvent.hpp new file mode 100644 index 0000000..db6cab4 --- /dev/null +++ b/shared/graphics/events/IKeyEvent.hpp @@ -0,0 +1,61 @@ +/* +** EPITECH PROJECT, 2024 +** arcade-shared +** File description: +** AKeyEvent +*/ + +#pragma once + +#include "IEvent.hpp" + +namespace shared::graphics::events { + class IKeyEvent; +} + +class shared::graphics::events::IKeyEvent : public IEvent { +public: + virtual ~IKeyEvent() = default; + + typedef enum { + CONTROL, // Control key (`Ctrl`, `Shift`, `Alt`) + ARROW, // Arrow key (`Up`, `Down`, `Left`, `Right`) + FUNC, // Function key (`F1`, `F2`, `F3`, etc.) + CHAR, // Character key (`a`, `1`, `&`, etc.) + UNKNOWN // Unknown key + } KeyType; + + typedef enum { + CTRL, // `Ctrl` key + SHIFT, // `Shift` key + ALT // `Alt` key + } ControlCode; + + typedef enum { + UP, // `Up` arrow key + DOWN, // `Down` arrow key + LEFT, // `Left` arrow key + RIGHT // `Right` arrow key + } ArrowCode; + + typedef union { + ControlCode control; // Control key + ArrowCode arrow; // Arrow key + char character; // ASCII character value + unsigned char func; // Function key number + } KeyCode; + + /** + * @brief Key code content + * + * @return Content of the key code + */ + virtual const KeyCode getKeyCode(void) const noexcept = 0; + + /** + * @brief Key type + * + * @return Type of the key pressed + */ + virtual const KeyType getKeyType(void) const noexcept = 0; +}; diff --git a/shared/graphics/events/IMouseButtonEvent.hpp b/shared/graphics/events/IMouseButtonEvent.hpp new file mode 100644 index 0000000..b70ab17 --- /dev/null +++ b/shared/graphics/events/IMouseButtonEvent.hpp @@ -0,0 +1,31 @@ +/* +** EPITECH PROJECT, 2024 +** arcade-shared +** File description: +** IMouseEvent +*/ + +#pragma once + +#include "IMouseEvent.hpp" + +namespace shared::graphics::events{ + class IMouseButtonEvent; +} + +class shared::graphics::events::IMouseButtonEvent : public IMouseEvent { +public: + virtual ~IMouseButtonEvent() = default; + + typedef enum { + LEFT, + RIGHT + } MouseButton; + + /** + * @brief Mouse button released + * + * @return Button released or pressed + */ + virtual const MouseButton getButton(void) const noexcept = 0; +}; diff --git a/shared/graphics/events/IMouseEvent.hpp b/shared/graphics/events/IMouseEvent.hpp new file mode 100644 index 0000000..a85ae4b --- /dev/null +++ b/shared/graphics/events/IMouseEvent.hpp @@ -0,0 +1,27 @@ +/* +** EPITECH PROJECT, 2024 +** arcade-shared +** File description: +** IMouseEvent +*/ + +#pragma once + +#include "../../types/Vector.hpp" +#include "IEvent.hpp" + +namespace shared::graphics::events { + class IMouseEvent; +} + +class shared::graphics::events::IMouseEvent : public IEvent { +public: + virtual ~IMouseEvent() = default; + + /** + * @brief Mouse position + * + * @return Position of the mouse + */ + virtual const shared::types::Vector2i getPosition(void) const noexcept = 0; +}; diff --git a/shared/graphics/events/key/AKeyEvent.hpp b/shared/graphics/events/key/AKeyEvent.hpp deleted file mode 100644 index ff4c436..0000000 --- a/shared/graphics/events/key/AKeyEvent.hpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** AKeyEvent -*/ - -#pragma once - -#include "../IEvent.hpp" - -namespace shared::graphics::events { - template - class AKeyEvent; - - typedef enum - { - CONTROL, // Control key (`Ctrl`, `Shift`, `Alt`) - ARROW, // Arrow key (`Up`, `Down`, `Left`, `Right`) - FUNC, // Function key (`F1`, `F2`, `F3`, etc.) - CHAR, // Character key (`a`, `1`, `&`, etc.) - UNKNOWN // Unknown key - } KeyType; - - typedef enum - { - CTRL, // `Ctrl` key - SHIFT, // `Shift` key - ALT // `Alt` key - } ControlCode; - - typedef enum - { - UP, // `Up` arrow key - DOWN, // `Down` arrow key - LEFT, // `Left` arrow key - RIGHT // `Right` arrow key - } ArrowCode; - - typedef union - { - ControlCode control; // Control key - ArrowCode arrow; // Arrow key - char character; // ASCII character value - unsigned char func; // Function key number - } KeyCode; -} - -template -class shared::graphics::events::AKeyEvent: public IEvent { - public: - ~AKeyEvent() = default; - - /** - * @brief Event type - * - */ - const EventType getType(void) const noexcept - { - return this->_type; - } - - /** - * @brief Key code content - * - */ - const KeyCode getKeyCode(void) const noexcept - { - return this->_keyCode; - } - - /** - * @brief Key type - * - */ - const KeyType getKeyType(void) const noexcept - { - return this->_keyType; - } - - protected: - AKeyEvent(KeyType keyType, KeyCode keyCode) : _keyType(keyType), _keyCode(keyCode) {} - - EventType _type = T; - KeyType _keyType; - KeyCode _keyCode; -}; diff --git a/shared/graphics/events/key/KeyPressEvent.hpp b/shared/graphics/events/key/KeyPressEvent.hpp deleted file mode 100644 index 58016b8..0000000 --- a/shared/graphics/events/key/KeyPressEvent.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** AKeyEvent -*/ - -#pragma once - -#include "AKeyEvent.hpp" - -namespace shared::graphics::events { - class KeyPressEvent; -} - -class shared::graphics::events::KeyPressEvent: public AKeyEvent { - public: - KeyPressEvent(KeyType keyType, KeyCode keyCode): AKeyEvent(keyType, keyCode) {} -}; diff --git a/shared/graphics/events/key/KeyReleaseEvent.hpp b/shared/graphics/events/key/KeyReleaseEvent.hpp deleted file mode 100644 index 8800f90..0000000 --- a/shared/graphics/events/key/KeyReleaseEvent.hpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** IKeyEvent -*/ - -#pragma once - -#include "AKeyEvent.hpp" - -namespace shared::graphics::events { - class KeyReleaseEvent; -} -class shared::graphics::events::KeyReleaseEvent: public AKeyEvent { - public: - KeyReleaseEvent(KeyType keyType, KeyCode keyCode): AKeyEvent(keyType, keyCode) {} -}; diff --git a/shared/graphics/events/mouse/AMouseButtonEvent.hpp b/shared/graphics/events/mouse/AMouseButtonEvent.hpp deleted file mode 100644 index 17342c3..0000000 --- a/shared/graphics/events/mouse/AMouseButtonEvent.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** IMouseEvent -*/ - -#pragma once - -#include "AMouseEvent.hpp" - -namespace shared::graphics::events -{ - template - class AMouseButtonEvent; -} - -template -class shared::graphics::events::AMouseButtonEvent: public AMouseEvent -{ - public: - ~AMouseButtonEvent() = default; - - /** - * @brief Mouse button released - * - */ - const MouseButton getButton(void) const noexcept { - return this->_button; - } - - protected: - AMouseButtonEvent( - MouseButton button, - types::Vector2f position - ): AMouseEvent(position), _button(button) {} - - MouseButton _button; -}; diff --git a/shared/graphics/events/mouse/AMouseEvent.hpp b/shared/graphics/events/mouse/AMouseEvent.hpp deleted file mode 100644 index 18bc030..0000000 --- a/shared/graphics/events/mouse/AMouseEvent.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** IMouseEvent -*/ - -#pragma once - -#include "../../../types/types.hpp" -#include "../IEvent.hpp" - -namespace shared::graphics::events -{ - template - class AMouseEvent; - - typedef enum { - LEFT, - RIGHT - } MouseButton; -} - -template -class shared::graphics::events::AMouseEvent : public IEvent -{ - public: - ~AMouseEvent() = default; - - /** - * @brief Event type - * - */ - const EventType getType(void) const noexcept { - return T; - } - - /** - * @brief Mouse position - * - */ - const shared::types::Vector2f getPosition(void) const noexcept { - return this->_position; - } - - protected: - AMouseEvent(types::Vector2f position): _position(position) {} - - types::Vector2f _position; -}; diff --git a/shared/graphics/events/mouse/MouseButtonPressEvent.hpp b/shared/graphics/events/mouse/MouseButtonPressEvent.hpp deleted file mode 100644 index 3a92d1e..0000000 --- a/shared/graphics/events/mouse/MouseButtonPressEvent.hpp +++ /dev/null @@ -1,24 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** IMouseEvent -*/ - -#pragma once - -#include "AMouseButtonEvent.hpp" - -namespace shared::graphics::events -{ - class MouseButtonPressEvent; -} - -class shared::graphics::events::MouseButtonPressEvent : - public AMouseButtonEvent -{ - public: - MouseButtonPressEvent(MouseButton button, types::Vector2f position) - : AMouseButtonEvent(button, position) {} - ~MouseButtonPressEvent() = default; -}; diff --git a/shared/graphics/events/mouse/MouseButtonReleaseEvent.hpp b/shared/graphics/events/mouse/MouseButtonReleaseEvent.hpp deleted file mode 100644 index 960c6bc..0000000 --- a/shared/graphics/events/mouse/MouseButtonReleaseEvent.hpp +++ /dev/null @@ -1,24 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** IMouseEvent -*/ - -#pragma once - -#include "AMouseButtonEvent.hpp" - -namespace shared::graphics::events -{ - class MouseButtonReleaseEvent; -} - -class shared::graphics::events::MouseButtonReleaseEvent : - public AMouseButtonEvent -{ - public: - MouseButtonReleaseEvent(MouseButton button, types::Vector2f position) - : AMouseButtonEvent(button, position) {} - ~MouseButtonReleaseEvent() = default; -}; diff --git a/shared/graphics/events/mouse/MouseMoveEvent.hpp b/shared/graphics/events/mouse/MouseMoveEvent.hpp deleted file mode 100644 index c0be8db..0000000 --- a/shared/graphics/events/mouse/MouseMoveEvent.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** IMouseEvent -*/ - -#pragma once - -#include "AMouseEvent.hpp" - -namespace shared::graphics::events -{ - class MouseMoveEvent; -} - -class shared::graphics::events::MouseMoveEvent : public AMouseEvent -{ - public: - MouseMoveEvent(types::Vector2f position) : AMouseEvent(position) {} - ~MouseMoveEvent() = default; -}; diff --git a/shared/graphics/events/window/WindowCloseEvent.hpp b/shared/graphics/events/window/WindowCloseEvent.hpp deleted file mode 100644 index dcf9d52..0000000 --- a/shared/graphics/events/window/WindowCloseEvent.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** IWindowCloseEvent -*/ - -#pragma once - -#include "../IEvent.hpp" - -namespace shared::graphics::events { - class WindowCloseEvent; -} - -class shared::graphics::events::WindowCloseEvent: public IEvent { - public: - WindowCloseEvent() = default; - ~WindowCloseEvent() = default; - - /** - * @brief Event type - * - */ - const EventType getType() const noexcept - { - return WINDOW_CLOSE; - } -}; diff --git a/shared/graphics/events/window/WindowResizeEvent.hpp b/shared/graphics/events/window/WindowResizeEvent.hpp deleted file mode 100644 index e8bddce..0000000 --- a/shared/graphics/events/window/WindowResizeEvent.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** IWindowResizeEvent -*/ - -#pragma once - -#include "../IEvent.hpp" -#include "../../../types/types.hpp" - -namespace shared::graphics::events { - class WindowResizeEvent; -} - -class shared::graphics::events::WindowResizeEvent: public IEvent { - public: - WindowResizeEvent(types::Vector2u newSize) : _newSize(newSize) {} - ~WindowResizeEvent() = default; - - /** - * @brief Event type - * - */ - const EventType getType() const noexcept - { - return WINDOW_RESIZE; - } - - /** - * @brief Get the new window size - * - * @return New window size - */ - const types::Vector2u &getNewSize() const noexcept - { - return this->_newSize; - } - - protected: - types::Vector2u _newSize; -}; diff --git a/shared/graphics/export.cpp.example b/shared/graphics/export.cpp.example index d3e00de..d8e1b45 100644 --- a/shared/graphics/export.cpp.example +++ b/shared/graphics/export.cpp.example @@ -5,17 +5,20 @@ ** export */ -#include "IGraphicsFactory.hpp" +#include "IGraphicsProvider.hpp" #include "../types/Libraries.hpp" +using namespace shared::graphics; +using namespace shared::types; + extern "C" { - shared::types::LibraryType SHARED_LIBRARY_TYPE_GETTER_NAME(void) + LibraryType SHARED_LIBRARY_TYPE_GETTER_NAME(void) { - return shared::types::LibraryType::GRAPHIC; + return LibraryType::GRAPHIC; } - std::shared_ptr SHARED_GRAPHICS_PROVIDER_LOADER_NAME(void) + IGraphicsProvider *SHARED_GRAPHICS_PROVIDER_GETTER_NAME(void) { - return std::make_shared(...); + return new YOUR_CLASS(); } } diff --git a/shared/graphics/types/EntityProps.hpp b/shared/graphics/types/EntityProps.hpp deleted file mode 100644 index 2e3b8e5..0000000 --- a/shared/graphics/types/EntityProps.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** Texture -*/ - -#pragma once - -#include - -#include "../ITexture.hpp" -#include "../../types/types.hpp" - -using namespace shared::types; - -namespace shared::graphics -{ - typedef struct - { - const std::shared_ptr texture; // Texture of the entity - const Vector2f binTileSize; // Size of a binary tile - const Vector2u origin; // Origin of the texture - } EntityTextureProps; - - typedef struct - { - EntityTextureProps textureProps; // Properties to use with the texture for the entity - Vector2u size; // Size of the entity - Vector2i position; // Position of the entity - } EntityProps; -} diff --git a/shared/graphics/types/TextProps.hpp b/shared/graphics/types/TextProps.hpp new file mode 100644 index 0000000..9f01dc9 --- /dev/null +++ b/shared/graphics/types/TextProps.hpp @@ -0,0 +1,42 @@ +/* +** EPITECH PROJECT, 2024 +** arcade-shared +** File description: +** Text +*/ + +#pragma once + +#include +#include + +#include "../IFont.hpp" +#include "../../types/Vector.hpp" +#include "../../types/Color.hpp" + +using namespace shared::types; + +namespace shared::graphics { + typedef enum { + LEFT, + CENTER, + RIGHT + } TextAlign; + + typedef enum { + BOTTOM, + MIDDLE, + TOP + } TextVerticalAlign; + + typedef struct { + std::shared_ptr font; // Font of the text + unsigned int fontSize; // Font size + std::string content; // Content of the text + TextAlign align; // Alignment of the text + TextVerticalAlign verticalAlign; // Vertical alignment of the text + types::Color color; // Color of the text + Vector2u size; // Size of the entity + Vector2i position; // Position of the entity + } TextProps; +} diff --git a/shared/graphics/types/TextureProps.hpp b/shared/graphics/types/TextureProps.hpp new file mode 100644 index 0000000..5847f37 --- /dev/null +++ b/shared/graphics/types/TextureProps.hpp @@ -0,0 +1,25 @@ +/* +** EPITECH PROJECT, 2024 +** arcade-shared +** File description: +** Texture +*/ + +#pragma once + +#include + +#include "../ITexture.hpp" +#include "../../types/Vector.hpp" + +using namespace shared::types; + +namespace shared::graphics { + typedef struct { + std::shared_ptr texture; // Texture of the entity + Vector2f binTileSize; // Size of a binary tile + Vector2u origin; // Origin of the texture + Vector2u size; // Size of the entity + Vector2i position; // Position of the entity + } TextureProps; +} diff --git a/shared/types/Color.hpp b/shared/types/Color.hpp new file mode 100644 index 0000000..b6fe6e2 --- /dev/null +++ b/shared/types/Color.hpp @@ -0,0 +1,25 @@ +/* +** EPITECH PROJECT, 2024 +** Color.hpp +** File description: +** Color class +*/ + +#pragma once + +namespace shared::types +{ + typedef struct ColorType { + ColorType( + unsigned char r, + unsigned char g, + unsigned char b, + unsigned char a + ) : r(r), g(g), b(b), a(a) {} + + unsigned char r; + unsigned char g; + unsigned char b; + unsigned char a; + } Color; +} diff --git a/shared/types/Libraries.hpp b/shared/types/Libraries.hpp index 9711994..1d2629f 100644 --- a/shared/types/Libraries.hpp +++ b/shared/types/Libraries.hpp @@ -10,8 +10,8 @@ #include "../games/IGameProvider.hpp" #include "../graphics/IGraphicsProvider.hpp" -#define SHARED_GAME_PROVIDER_LOADER_NAME arcadeLibGetGameProvider -#define SHARED_GRAPHICS_PROVIDER_LOADER_NAME arcadeLibGetGraphicsProvider +#define SHARED_GAME_PROVIDER_GETTER_NAME arcadeLibGetGameProvider +#define SHARED_GRAPHICS_PROVIDER_GETTER_NAME arcadeLibGetGraphicsProvider #define SHARED_LIBRARY_TYPE_GETTER_NAME arcadeLibGetType #define STRINGIFY(x) #x #define SHARED_STRINGIFY(x) STRINGIFY(x) @@ -23,7 +23,7 @@ namespace shared::types GRAPHIC, } LibraryType; - typedef std::shared_ptr (*GameProvider)(void); - typedef std::shared_ptr (*GraphicsProvider)(void); + typedef games::IGameProvider* (*GameProviderGetter)(void); + typedef graphics::IGraphicsProvider* (*GraphicsProviderGetter)(void); typedef LibraryType (*LibraryTypeGetter)(void); } diff --git a/shared/types/UUId.cpp b/shared/types/UUId.cpp deleted file mode 100644 index 87086f2..0000000 --- a/shared/types/UUId.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** UUId -*/ - -#include "UUId.hpp" - - -shared::types::UUId::UUId() -{ - uuid_generate(_uuid); -} - -shared::types::UUId::~UUId() -{ -} - -shared::types::UUId &shared::types::UUId::operator=(const UUId &other) -{ - if (this != &other) - uuid_copy(_uuid, other._uuid); - return *this; -} - -bool shared::types::UUId::operator==(const UUId &other) const -{ - return uuid_compare(_uuid, other._uuid) == 0; -} - -bool shared::types::UUId::operator!=(const UUId &other) const -{ - return uuid_compare(_uuid, other._uuid) != 0; -} - -bool shared::types::UUId::operator<(const UUId &other) const -{ - return uuid_compare(_uuid, other._uuid) < 0; -} - -bool shared::types::UUId::operator>(const UUId &other) const -{ - return uuid_compare(_uuid, other._uuid) > 0; -} - -bool shared::types::UUId::operator<=(const UUId &other) const -{ - return uuid_compare(_uuid, other._uuid) <= 0; -} - -bool shared::types::UUId::operator>=(const UUId &other) const -{ - return uuid_compare(_uuid, other._uuid) >= 0; -} - -std::string shared::types::UUId::toString() const -{ - char str[37]; - - uuid_unparse(_uuid, str); - return std::string(str); -} diff --git a/shared/types/UUId.hpp b/shared/types/UUId.hpp deleted file mode 100644 index 39ad2ad..0000000 --- a/shared/types/UUId.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** UUId -*/ - -#pragma once - -#include - -#include - -namespace shared::types { - class UUId; -} - -class shared::types::UUId -{ - public: - UUId(void); - ~UUId(); - - /** - * @brief Assign same value to this UUId - * - * @param other UUId in whcih value is to be assigned - * @return Passed instance of UUId - */ - UUId &operator=(const UUId &other); - - /** - * @brief Equality operator - * - * @param other UUId to be compared - * @return Equality status - */ - bool operator==(const UUId &other) const; - - /** - * @brief Different operator - * - * @param other UUId to be compared - * @return Difference status - */ - bool operator!=(const UUId &other) const; - - /** - * @brief Operator to compare if current UUId is less than other UUId - * - * @param other Other UUId to be compared - * @return Status of comparison - */ - bool operator<(const UUId &other) const; - - /** - * @brief Operator to compare if current UUId is greter than other UUId - * - * @param other Other UUId to be compared - * @return Status of comparison - */ - bool operator>(const UUId &other) const; - - /** - * @brief Operator to compare if current UUId is less than or equal to other UUId - * - * @param other Other UUId to be compared - * @return Status of comparison - */ - bool operator<=(const UUId &other) const; - - /** - * @brief Operator to compare if current UUId is greater than or equal to other UUId - * - * @param other Other UUId to be compared - * @return Status of comparison - */ - bool operator>=(const UUId &other) const; - - /** - * @brief Convert UUId to string - * - * @return String representation of UUId - */ - std::string toString(void) const; - - private: - uuid_t _uuid; -}; diff --git a/shared/types/types.hpp b/shared/types/types.hpp deleted file mode 100644 index 2fa7a26..0000000 --- a/shared/types/types.hpp +++ /dev/null @@ -1,11 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** arcade-shared -** File description: -** types -*/ - -#pragma once - -#include "Vector.hpp" -#include "UUId.hpp"