From 539a278114538feca0b76295250fb2d8f5f84776 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Wed, 30 Sep 2020 18:49:39 +0200 Subject: [PATCH] Make LibrarySettings follow PIMPL, adds documentation. Signed-off-by: Deukhoofd --- src/Library/LibrarySettings.cpp | 22 ++++++++++++++++++++++ src/Library/LibrarySettings.hpp | 23 ++++++++++++++--------- 2 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 src/Library/LibrarySettings.cpp diff --git a/src/Library/LibrarySettings.cpp b/src/Library/LibrarySettings.cpp new file mode 100644 index 0000000..47b45cf --- /dev/null +++ b/src/Library/LibrarySettings.cpp @@ -0,0 +1,22 @@ +#include "LibrarySettings.hpp" + +namespace CreatureLib::Library { + struct LibrarySettings::impl { + level_int_t _maximalLevel; + uint8_t _maximalAttacks; + + public: + impl(level_int_t maximalLevel, uint8_t maximalAttacks) + : _maximalLevel(maximalLevel), _maximalAttacks(maximalAttacks) {} + + [[nodiscard]] inline level_int_t GetMaximalLevel() const noexcept { return _maximalLevel; } + + [[nodiscard]] inline uint8_t GetMaximalAttacks() const noexcept { return _maximalAttacks; } + }; + LibrarySettings::LibrarySettings(level_int_t maximalLevel, uint8_t maximalAttacks) + : _impl(new impl(maximalLevel, maximalAttacks)) {} + LibrarySettings::~LibrarySettings() = default; + + level_int_t LibrarySettings::GetMaximalLevel() const noexcept { return _impl->GetMaximalLevel(); } + uint8_t LibrarySettings::GetMaximalAttacks() const noexcept { return _impl->GetMaximalAttacks(); } +} \ No newline at end of file diff --git a/src/Library/LibrarySettings.hpp b/src/Library/LibrarySettings.hpp index 9907672..b887a5b 100644 --- a/src/Library/LibrarySettings.hpp +++ b/src/Library/LibrarySettings.hpp @@ -1,20 +1,25 @@ #ifndef CREATURELIB_LIBRARYSETTINGS_HPP #define CREATURELIB_LIBRARYSETTINGS_HPP -#include "../Defines.hpp" - namespace CreatureLib::Library { + /// @brief Hold the different runtime settings for a given library. class LibrarySettings { - level_int_t _maximalLevel; - uint8_t _maximalAttacks; + struct impl; + std::unique_ptr _impl; public: - LibrarySettings(level_int_t maximalLevel, uint8_t maximalAttacks) - : _maximalLevel(maximalLevel), _maximalAttacks(maximalAttacks) {} + /// @brief Initialises LibrarySettings. + /// @param maximalLevel The maximal level a creature can be. + /// @param maximalAttacks The maximal number of attacks a creature can have. + LibrarySettings(level_int_t maximalLevel, uint8_t maximalAttacks); + virtual ~LibrarySettings(); - inline level_int_t GetMaximalLevel() const noexcept { return _maximalLevel; } - - inline uint8_t GetMaximalAttacks() const noexcept { return _maximalAttacks; } + /// @brief Returns the maximal level a creature can be in the current library. + /// @return The maximal level a creature can be in the current library. + [[nodiscard]] level_int_t GetMaximalLevel() const noexcept; + /// @brief Returns the maximal number of attacks a creature can have. + /// @return The maximal number of attacks a creature can have. + [[nodiscard]] uint8_t GetMaximalAttacks() const noexcept; }; }