Skip to content

Commit

Permalink
feat(engine): implemented equality operator for AnyAsset
Browse files Browse the repository at this point in the history
  • Loading branch information
roby2014 committed Oct 15, 2023
1 parent ad2b8cc commit b04cfd5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions engine/include/cubos/engine/assets/asset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ 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 and version, 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;
Expand Down
5 changes: 5 additions & 0 deletions engine/src/cubos/engine/assets/asset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ AnyAsset& AnyAsset::operator=(AnyAsset&& other) noexcept
return *this;
}

bool AnyAsset::operator==(const AnyAsset& other) const
{
return this->getId() == other.getId() && this->getVersion() == other.getVersion();
}

int AnyAsset::getVersion() const
{
return reflectedId == mId ? mVersion : 0;
Expand Down

0 comments on commit b04cfd5

Please sign in to comment.