Assets: Add equality operators to AssetWeakReference

This commit is contained in:
Hans Goudey
2024-05-01 13:24:39 -04:00
parent 9c1fe82e06
commit 4dbdd925d4
2 changed files with 20 additions and 0 deletions

View File

@@ -73,6 +73,20 @@ AssetWeakReference &AssetWeakReference::operator=(AssetWeakReference &&other)
return *this;
}
bool operator==(const AssetWeakReference &a, const AssetWeakReference &b)
{
if (a.asset_library_type != b.asset_library_type) {
return false;
}
if (StringRef(a.asset_library_identifier) != StringRef(b.asset_library_identifier)) {
return false;
}
if (StringRef(a.relative_asset_identifier) != StringRef(b.relative_asset_identifier)) {
return false;
}
return true;
}
AssetWeakReference AssetWeakReference::make_reference(
const asset_system::AssetLibrary &library,
const asset_system::AssetIdentifier &asset_identifier)

View File

@@ -174,6 +174,12 @@ typedef struct AssetWeakReference {
AssetWeakReference &operator=(AssetWeakReference &&);
~AssetWeakReference();
friend bool operator==(const AssetWeakReference &a, const AssetWeakReference &b);
friend bool operator!=(const AssetWeakReference &a, const AssetWeakReference &b)
{
return !(a == b);
}
/**
* See AssetRepresentation::make_weak_reference().
*/