From 3a2a9b84629af29a43d28166996357e166bbf338 Mon Sep 17 00:00:00 2001 From: roby2014 Date: Mon, 16 Oct 2023 16:16:30 +0100 Subject: [PATCH] feat(engine): implemented equality operator for AnyAsset --- engine/include/cubos/engine/assets/asset.hpp | 5 +++++ engine/src/cubos/engine/assets/asset.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/engine/include/cubos/engine/assets/asset.hpp b/engine/include/cubos/engine/assets/asset.hpp index a2949cebe..349b6c070 100644 --- a/engine/include/cubos/engine/assets/asset.hpp +++ b/engine/include/cubos/engine/assets/asset.hpp @@ -70,6 +70,11 @@ namespace cubos::engine /// @param other Handle to move. AnyAsset& operator=(AnyAsset&& other) noexcept; + /// @brief Equality operator for comparing two AnyAsset objects. + /// @param other The other AnyAsset to compare. + /// @return True if the two AnyAsset objects have the same UUID , otherwise false. + bool operator==(const AnyAsset& other) const; + /// @brief Gets the version of the asset last seen by this handle. /// @return Asset version. int getVersion() const; diff --git a/engine/src/cubos/engine/assets/asset.cpp b/engine/src/cubos/engine/assets/asset.cpp index abc6a086c..a27e758af 100644 --- a/engine/src/cubos/engine/assets/asset.cpp +++ b/engine/src/cubos/engine/assets/asset.cpp @@ -89,6 +89,11 @@ AnyAsset& AnyAsset::operator=(AnyAsset&& other) noexcept return *this; } +bool AnyAsset::operator==(const AnyAsset& other) const +{ + return this->getId() == other.getId(); +} + int AnyAsset::getVersion() const { return reflectedId == mId ? mVersion : 0;