Add AssetDumperContext to bundle context fields for dumping

(cherry picked from commit ed8331280392ef3a2b4657c5dbd0880463d85f2c)
This commit is contained in:
Jan
2021-03-05 18:11:56 +01:00
parent 88c48e8107
commit abb268a819
56 changed files with 191 additions and 156 deletions

View File

@ -7,15 +7,15 @@
#include <iostream>
template<class T>
class AbstractAssetDumper : public IAssetDumper<T>
class AbstractFileDumper : public IAssetDumper<T>
{
protected:
virtual bool ShouldDump(XAssetInfo<T>* asset) = 0;
virtual std::string GetFileNameForAsset(Zone* zone, XAssetInfo<T>* asset) = 0;
virtual void DumpAsset(Zone* zone, XAssetInfo<T>* asset, std::ostream& stream) = 0;
virtual void DumpAsset(AssetDumpingContext& context, XAssetInfo<T>* asset, std::ostream& stream) = 0;
public:
void DumpPool(Zone* zone, AssetPool<T>* pool, const std::string& basePath) override
void DumpPool(AssetDumpingContext& context, AssetPool<T>* pool) override
{
for(auto assetInfo : *pool)
{
@ -25,8 +25,8 @@ public:
continue;
}
std::filesystem::path assetFilePath(basePath);
assetFilePath.append(GetFileNameForAsset(zone, assetInfo));
std::filesystem::path assetFilePath(context.m_base_path);
assetFilePath.append(GetFileNameForAsset(context.m_zone, assetInfo));
auto assetFileFolder(assetFilePath);
assetFileFolder.replace_filename("");
@ -35,7 +35,7 @@ public:
std::ofstream file(assetFilePath, std::fstream::out | std::fstream::binary);
if(file.is_open())
{
DumpAsset(zone, assetInfo, file);
DumpAsset(context, assetInfo, file);
file.close();
}

View File

@ -0,0 +1,12 @@
#pragma once
#include <string>
#include "Zone/Zone.h"
class AssetDumpingContext
{
public:
Zone* m_zone;
std::string m_base_path;
};

View File

@ -1,13 +1,18 @@
#pragma once
#include "Zone/Zone.h"
#include "AssetDumpingContext.h"
#include "Pool/AssetPool.h"
template<class T>
class IAssetDumper
{
public:
IAssetDumper() = default;
virtual ~IAssetDumper() = default;
IAssetDumper(const IAssetDumper& other) = default;
IAssetDumper(IAssetDumper&& other) noexcept = default;
IAssetDumper& operator=(const IAssetDumper& other) = default;
IAssetDumper& operator=(IAssetDumper&& other) noexcept = default;
virtual void DumpPool(Zone* zone, AssetPool<T>* pool, const std::string& basePath) = 0;
virtual void DumpPool(AssetDumpingContext& context, AssetPool<T>* pool) = 0;
};

View File

@ -1,12 +1,17 @@
#pragma once
#include "Zone/Zone.h"
#include "AssetDumpingContext.h"
class IZoneDumper
{
public:
IZoneDumper() = default;
virtual ~IZoneDumper() = default;
IZoneDumper(const IZoneDumper& other) = default;
IZoneDumper(IZoneDumper&& other) noexcept = default;
IZoneDumper& operator=(const IZoneDumper& other) = default;
IZoneDumper& operator=(IZoneDumper&& other) noexcept = default;
virtual bool CanHandleZone(Zone* zone) const = 0;
virtual bool DumpZone(Zone* zone, const std::string& basePath) const = 0;
virtual bool CanHandleZone(AssetDumpingContext& assetDumpingContext) const = 0;
virtual bool DumpZone(AssetDumpingContext& assetDumpingContext) const = 0;
};