2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-06-06 16:52:35 +00:00

chore: generalize default asset creators

This commit is contained in:
Jan
2024-12-24 00:58:53 +01:00
parent c524cb007a
commit 9ebea5034a
18 changed files with 193 additions and 182 deletions
+26
View File
@@ -2,6 +2,9 @@
#include "Zone/ZoneTypes.h"
#include <stdexcept>
#include <type_traits>
struct IAssetBase
{
};
@@ -12,3 +15,26 @@ public:
static constexpr auto EnumEntry = AssetTypeEnum;
using Type = AssetType;
};
template<typename AssetType> struct AssetNameAccessor
{
public:
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
const char*& operator()(AssetType::Type& asset)
{
throw std::runtime_error();
}
};
#define DEFINE_ASSET_NAME_ACCESSOR(assetType, nameProperty) \
template<> struct AssetNameAccessor<assetType> \
{ \
public: \
static_assert(std::is_base_of_v<IAssetBase, assetType>); \
\
const char*& operator()(assetType::Type& asset) \
{ \
return asset.nameProperty; \
} \
}