From c95a05a4996fc71a709b34f5d93c0cb1a2fe0fb2 Mon Sep 17 00:00:00 2001 From: SimonMaracine Date: Fri, 5 Apr 2024 19:30:41 +0300 Subject: [PATCH] Remove unnecessary include in cache and make the class use the rule of 0 --- src/resmanager/detail/cache.hpp | 22 +++------------------- src/resmanager/detail/hashing.hpp | 2 +- src/resmanager/detail/version.hpp | 2 +- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/resmanager/detail/cache.hpp b/src/resmanager/detail/cache.hpp index d7b8812..96ba65c 100644 --- a/src/resmanager/detail/cache.hpp +++ b/src/resmanager/detail/cache.hpp @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include @@ -14,22 +13,7 @@ namespace resmanager { public: using ResourceType = typename L::ResourceType; - Cache() = default; - ~Cache() = default; - Cache(const Cache&) = default; - Cache& operator=(const Cache&) = default; - - Cache(Cache&& other) noexcept { - cache = std::move(other.cache); - } - - Cache& operator=(Cache&& other) noexcept { - cache = std::move(other.cache); - - return *this; - } - - // If already present, return the resource directly, otherwise load it + // If already present, return the resource directly, otherwise load and then return it template ResourceType load(const K id, Args&&... args) { if (auto iter = cache.find(id); iter != cache.end()) { @@ -53,9 +37,9 @@ namespace resmanager { return resource; } - // Get the resource + // Get the resource; throws std::out_of_range, if resource is not found ResourceType operator[](const K id) const { - return cache.at(id); + return cache.at(id); // TODO maybe handle exception here and return null } // Check if the resource is present diff --git a/src/resmanager/detail/hashing.hpp b/src/resmanager/detail/hashing.hpp index b687d1d..8fda2a6 100644 --- a/src/resmanager/detail/hashing.hpp +++ b/src/resmanager/detail/hashing.hpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include // For std::hash // Implements the Fowler-Noll-Vo hash algorithm, or more exactly FNV-1a diff --git a/src/resmanager/detail/version.hpp b/src/resmanager/detail/version.hpp index d9b7558..ea4ea72 100644 --- a/src/resmanager/detail/version.hpp +++ b/src/resmanager/detail/version.hpp @@ -3,5 +3,5 @@ namespace resmanager { inline constexpr unsigned int VERSION_MAJOR = 0; inline constexpr unsigned int VERSION_MINOR = 8; - inline constexpr unsigned int VERSION_PATCH = 1; + inline constexpr unsigned int VERSION_PATCH = 2; }