2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-01-12 11:41:50 +00:00

chore: generalize IAssetDumper interface

This commit is contained in:
Jan Laupetin
2025-10-15 20:06:01 +01:00
parent c6e9cbedda
commit 6a84d1ea68
152 changed files with 1051 additions and 586 deletions

View File

@@ -1,18 +1,24 @@
#pragma once
#include "Game/IAsset.h"
#include "IAssetDumper.h"
#include "Pool/AssetPool.h"
template<class T> class AbstractAssetDumper : public IAssetDumper<T>
template<class AssetType> class AbstractAssetDumper : public IAssetDumper
{
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
public:
[[nodiscard]] size_t GetProgressTotalCount(const AssetPool<T>& pool) const override
using AssetType_t = AssetType;
[[nodiscard]] size_t GetProgressTotalCount() const override
{
return pool.m_asset_lookup.size();
return m_pool.m_asset_lookup.size();
}
void DumpPool(AssetDumpingContext& context, const AssetPool<T>& pool) override
void Dump(AssetDumpingContext& context) override
{
for (const auto* assetInfo : pool)
for (const auto* assetInfo : m_pool)
{
if (assetInfo->m_name[0] == ',' || !ShouldDump(*assetInfo))
{
@@ -26,10 +32,38 @@ public:
}
protected:
virtual bool ShouldDump(const XAssetInfo<T>& asset)
explicit AbstractAssetDumper(const AssetPool<typename AssetType::Type>& pool)
: m_pool(pool)
{
}
virtual bool ShouldDump(const XAssetInfo<typename AssetType::Type>& asset)
{
return true;
}
virtual void DumpAsset(AssetDumpingContext& context, const XAssetInfo<T>& asset) = 0;
virtual void DumpAsset(AssetDumpingContext& context, const XAssetInfo<typename AssetType::Type>& asset) = 0;
const AssetPool<typename AssetType::Type>& m_pool;
};
template<class AssetType> class AbstractSingleProgressAssetDumper : public IAssetDumper
{
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
public:
using AssetType_t = AssetType;
[[nodiscard]] size_t GetProgressTotalCount() const override
{
return m_pool.m_asset_lookup.empty() ? 0uz : 1uz;
}
protected:
explicit AbstractSingleProgressAssetDumper(const AssetPool<typename AssetType::Type>& pool)
: m_pool(pool)
{
}
const AssetPool<typename AssetType::Type>& m_pool;
};

View File

@@ -1,9 +1,8 @@
#pragma once
#include "AssetDumpingContext.h"
#include "Pool/AssetPool.h"
template<class T> class IAssetDumper
class IAssetDumper
{
public:
IAssetDumper() = default;
@@ -13,6 +12,6 @@ public:
IAssetDumper& operator=(const IAssetDumper& other) = default;
IAssetDumper& operator=(IAssetDumper&& other) noexcept = default;
[[nodiscard]] virtual size_t GetProgressTotalCount(const AssetPool<T>& pool) const = 0;
virtual void DumpPool(AssetDumpingContext& context, const AssetPool<T>& pool) = 0;
[[nodiscard]] virtual size_t GetProgressTotalCount() const = 0;
virtual void Dump(AssetDumpingContext& context) = 0;
};