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

chore: add generic default asset constructors for all games

This commit is contained in:
Jan
2024-12-24 10:00:52 +01:00
parent 9ebea5034a
commit 4f585c6aa7
11 changed files with 364 additions and 159 deletions
+20 -4
View File
@@ -20,11 +20,12 @@ template<typename AssetType> struct AssetNameAccessor
{
public:
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
// static constexpr bool IS_SINGLETON = false;
const char*& operator()(AssetType::Type& asset)
{
throw std::runtime_error();
}
// const char*& operator()(AssetType::Type& asset)
// {
// throw std::runtime_error("Not implemented");
// }
};
#define DEFINE_ASSET_NAME_ACCESSOR(assetType, nameProperty) \
@@ -32,9 +33,24 @@ public:
{ \
public: \
static_assert(std::is_base_of_v<IAssetBase, assetType>); \
static constexpr bool IS_SINGLETON = false; \
\
const char*& operator()(assetType::Type& asset) \
{ \
return asset.nameProperty; \
} \
}
#define DEFINE_ASSET_NAME_ACCESSOR_SINGLETON(assetType, singletonName) \
template<> struct AssetNameAccessor<assetType> \
{ \
public: \
static_assert(std::is_base_of_v<IAssetBase, assetType>); \
static constexpr bool IS_SINGLETON = true; \
\
const char* const& operator()(assetType::Type& asset) \
{ \
static const char* NAME = singletonName; \
return NAME; \
} \
}