mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-12-27 12:31:50 +00:00
chore: make marker reusable with visitor pattern
This commit is contained in:
@@ -146,6 +146,8 @@ namespace
|
|||||||
LINEF("#include \"{0}_load_db.h\"", Lower(m_env.m_asset->m_definition->m_name))
|
LINEF("#include \"{0}_load_db.h\"", Lower(m_env.m_asset->m_definition->m_name))
|
||||||
LINE("")
|
LINE("")
|
||||||
LINEF("#include \"{0}_mark_db.h\"", Lower(m_env.m_asset->m_definition->m_name))
|
LINEF("#include \"{0}_mark_db.h\"", Lower(m_env.m_asset->m_definition->m_name))
|
||||||
|
LINE("")
|
||||||
|
LINE("#include \"Loading/AssetInfoCollector.h\"")
|
||||||
|
|
||||||
if (!m_env.m_referenced_assets.empty())
|
if (!m_env.m_referenced_assets.empty())
|
||||||
{
|
{
|
||||||
@@ -2155,14 +2157,16 @@ namespace
|
|||||||
|
|
||||||
LINE("assert(pAsset != nullptr);")
|
LINE("assert(pAsset != nullptr);")
|
||||||
LINE("")
|
LINE("")
|
||||||
LINEF("{0} marker(m_zone);", MarkerClassName(m_env.m_asset))
|
LINE("AssetInfoCollector assetInfo(m_zone);")
|
||||||
|
LINEF("{0} marker(assetInfo);", MarkerClassName(m_env.m_asset))
|
||||||
LINE("marker.Mark(*pAsset);")
|
LINE("marker.Mark(*pAsset);")
|
||||||
LINE("")
|
LINE("")
|
||||||
LINEF("auto* reallocatedAsset = m_zone.Memory().Alloc<{0}>();", info->m_definition->GetFullName())
|
LINEF("auto* reallocatedAsset = m_zone.Memory().Alloc<{0}>();", info->m_definition->GetFullName())
|
||||||
LINEF("std::memcpy(reallocatedAsset, *pAsset, sizeof({0}));", info->m_definition->GetFullName())
|
LINEF("std::memcpy(reallocatedAsset, *pAsset, sizeof({0}));", info->m_definition->GetFullName())
|
||||||
LINE("")
|
LINE("")
|
||||||
LINEF("m_asset_info = reinterpret_cast<XAssetInfo<{0}>*>(LinkAsset(AssetNameAccessor<{1}>()(**pAsset), reallocatedAsset, marker.GetDependencies(), "
|
LINEF("m_asset_info = reinterpret_cast<XAssetInfo<{0}>*>(LinkAsset(AssetNameAccessor<{1}>()(**pAsset), reallocatedAsset, "
|
||||||
"marker.GetUsedScriptStrings(), marker.GetIndirectAssetReferences()));",
|
"assetInfo.GetDependencies(), "
|
||||||
|
"assetInfo.GetUsedScriptStrings(), assetInfo.GetIndirectAssetReferences()));",
|
||||||
info->m_definition->GetFullName(),
|
info->m_definition->GetFullName(),
|
||||||
info->m_asset_name)
|
info->m_asset_name)
|
||||||
LINE("*pAsset = m_asset_info->Asset();")
|
LINE("*pAsset = m_asset_info->Asset();")
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ namespace
|
|||||||
LINE("")
|
LINE("")
|
||||||
LINEF("#include \"Game/{0}/{0}.h\"", m_env.m_game)
|
LINEF("#include \"Game/{0}/{0}.h\"", m_env.m_game)
|
||||||
LINE("#include \"Marking/AssetMarker.h\"")
|
LINE("#include \"Marking/AssetMarker.h\"")
|
||||||
|
LINE("#include \"Marking/AssetVisitor.h\"")
|
||||||
LINE("")
|
LINE("")
|
||||||
LINE("#include <string>")
|
LINE("#include <string>")
|
||||||
LINE("")
|
LINE("")
|
||||||
@@ -48,7 +49,6 @@ namespace
|
|||||||
m_intendation++;
|
m_intendation++;
|
||||||
PrintHeaderConstructor();
|
PrintHeaderConstructor();
|
||||||
PrintHeaderMainMarkMethodDeclaration(m_env.m_asset);
|
PrintHeaderMainMarkMethodDeclaration(m_env.m_asset);
|
||||||
PrintHeaderGetAssetInfoMethodDeclaration(m_env.m_asset);
|
|
||||||
LINE("")
|
LINE("")
|
||||||
|
|
||||||
m_intendation--;
|
m_intendation--;
|
||||||
@@ -136,8 +136,6 @@ namespace
|
|||||||
PrintConstructorMethod();
|
PrintConstructorMethod();
|
||||||
LINE("")
|
LINE("")
|
||||||
PrintMainMarkMethod();
|
PrintMainMarkMethod();
|
||||||
LINE("")
|
|
||||||
PrintGetAssetInfoMethod();
|
|
||||||
|
|
||||||
for (const auto* type : m_env.m_used_types)
|
for (const auto* type : m_env.m_used_types)
|
||||||
{
|
{
|
||||||
@@ -210,14 +208,9 @@ namespace
|
|||||||
LINEF("void Mark_{0}();", MakeSafeTypeName(info->m_definition))
|
LINEF("void Mark_{0}();", MakeSafeTypeName(info->m_definition))
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintHeaderGetAssetInfoMethodDeclaration(const StructureInformation* info) const
|
|
||||||
{
|
|
||||||
LINEF("XAssetInfo<{0}>* GetAssetInfo({0}* pAsset) const;", info->m_definition->GetFullName())
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintHeaderConstructor() const
|
void PrintHeaderConstructor() const
|
||||||
{
|
{
|
||||||
LINEF("{0}(Zone& zone);", MarkerClassName(m_env.m_asset))
|
LINEF("explicit {0}(AssetVisitor& visitor);", MarkerClassName(m_env.m_asset))
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintHeaderMainMarkMethodDeclaration(const StructureInformation* info) const
|
void PrintHeaderMainMarkMethodDeclaration(const StructureInformation* info) const
|
||||||
@@ -237,10 +230,10 @@ namespace
|
|||||||
|
|
||||||
void PrintConstructorMethod()
|
void PrintConstructorMethod()
|
||||||
{
|
{
|
||||||
LINEF("{0}::{0}(Zone& zone)", MarkerClassName(m_env.m_asset))
|
LINEF("{0}::{0}(AssetVisitor& visitor)", MarkerClassName(m_env.m_asset))
|
||||||
|
|
||||||
m_intendation++;
|
m_intendation++;
|
||||||
LINEF(": AssetMarker({0}::EnumEntry, zone)", m_env.m_asset->m_asset_name)
|
LINE(": AssetMarker(visitor)")
|
||||||
m_intendation--;
|
m_intendation--;
|
||||||
|
|
||||||
LINE("{")
|
LINE("{")
|
||||||
@@ -286,7 +279,7 @@ namespace
|
|||||||
|
|
||||||
if (info && StructureComputations(info).IsAsset())
|
if (info && StructureComputations(info).IsAsset())
|
||||||
{
|
{
|
||||||
LINEF("AddDependency({0}(m_zone).GetAssetInfo(*{1}));", MarkerClassName(info), MakeTypePtrVarName(def))
|
LINEF("Mark_Dependency<{0}>(*{1});", info->m_asset_name, MakeTypePtrVarName(def))
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -413,7 +406,7 @@ namespace
|
|||||||
{
|
{
|
||||||
if (loadType == MemberLoadType::SINGLE_POINTER)
|
if (loadType == MemberLoadType::SINGLE_POINTER)
|
||||||
{
|
{
|
||||||
LINEF("AddDependency({0}(m_zone).GetAssetInfo({1}));", MarkerClassName(member->m_type), MakeMemberAccess(info, member, modifier))
|
LINEF("Mark_Dependency<{0}>({1});", member->m_type->m_asset_name, MakeMemberAccess(info, member, modifier))
|
||||||
}
|
}
|
||||||
else if (loadType == MemberLoadType::POINTER_ARRAY)
|
else if (loadType == MemberLoadType::POINTER_ARRAY)
|
||||||
{
|
{
|
||||||
@@ -752,20 +745,6 @@ namespace
|
|||||||
LINE("}")
|
LINE("}")
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintGetAssetInfoMethod()
|
|
||||||
{
|
|
||||||
LINEF("XAssetInfo<{0}>* {1}::GetAssetInfo({0}* pAsset) const", m_env.m_asset->m_definition->GetFullName(), MarkerClassName(m_env.m_asset))
|
|
||||||
LINE("{")
|
|
||||||
m_intendation++;
|
|
||||||
|
|
||||||
LINEF("return reinterpret_cast<XAssetInfo<{0}>*>(GetAssetInfoByName(AssetNameAccessor<{1}>()(*pAsset)));",
|
|
||||||
m_env.m_asset->m_definition->GetFullName(),
|
|
||||||
m_env.m_asset->m_asset_name)
|
|
||||||
|
|
||||||
m_intendation--;
|
|
||||||
LINE("}")
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintMainMarkMethod()
|
void PrintMainMarkMethod()
|
||||||
{
|
{
|
||||||
LINEF("void {0}::Mark({1}* pAsset)", MarkerClassName(m_env.m_asset), m_env.m_asset->m_definition->GetFullName())
|
LINEF("void {0}::Mark({1}* pAsset)", MarkerClassName(m_env.m_asset), m_env.m_asset->m_definition->GetFullName())
|
||||||
|
|||||||
@@ -3,100 +3,35 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
AssetMarker::AssetMarker(const asset_type_t assetType, Zone& zone)
|
AssetMarker::AssetMarker(AssetVisitor& visitor)
|
||||||
: m_zone(zone),
|
: m_visitor(visitor)
|
||||||
m_asset_type(assetType)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetMarker::AddDependency(XAssetInfoGeneric* assetInfo)
|
void AssetMarker::Mark_ScriptString(scr_string_t& scriptString) const
|
||||||
{
|
{
|
||||||
if (assetInfo == nullptr)
|
const auto result = m_visitor.Visit_ScriptString(scriptString);
|
||||||
return;
|
if (result.has_value())
|
||||||
|
scriptString = *result;
|
||||||
const auto existingEntry = m_dependencies.find(assetInfo);
|
|
||||||
if (existingEntry != m_dependencies.end())
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_dependencies.emplace(assetInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetMarker::Mark_ScriptString(const scr_string_t scrString)
|
void AssetMarker::MarkArray_ScriptString(scr_string_t* scriptStringArray, const size_t count) const
|
||||||
{
|
{
|
||||||
assert(scrString < m_zone.m_script_strings.Count());
|
assert(scriptStringArray != nullptr);
|
||||||
|
|
||||||
if (scrString >= m_zone.m_script_strings.Count())
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_used_script_strings.emplace(scrString);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AssetMarker::MarkArray_ScriptString(const scr_string_t* scrStringArray, const size_t count)
|
|
||||||
{
|
|
||||||
assert(scrStringArray != nullptr);
|
|
||||||
|
|
||||||
for (size_t index = 0; index < count; index++)
|
for (size_t index = 0; index < count; index++)
|
||||||
Mark_ScriptString(scrStringArray[index]);
|
Mark_ScriptString(scriptStringArray[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetMarker::Mark_IndirectAssetRef(asset_type_t type, const char* assetRefName)
|
void AssetMarker::Mark_IndirectAssetRef(const asset_type_t assetType, const char* assetName) const
|
||||||
{
|
{
|
||||||
if (!assetRefName || !assetRefName[0])
|
m_visitor.Visit_IndirectAssetRef(assetType, assetName);
|
||||||
return;
|
|
||||||
|
|
||||||
m_indirect_asset_references.emplace(type, assetRefName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetMarker::MarkArray_IndirectAssetRef(const asset_type_t type, const char** assetRefNames, const size_t count)
|
void AssetMarker::MarkArray_IndirectAssetRef(const asset_type_t assetType, const char** assetNames, const size_t count) const
|
||||||
{
|
{
|
||||||
assert(assetRefNames != nullptr);
|
assert(assetNames != nullptr);
|
||||||
|
|
||||||
for (size_t index = 0; index < count; index++)
|
for (size_t index = 0; index < count; index++)
|
||||||
Mark_IndirectAssetRef(type, assetRefNames[index]);
|
Mark_IndirectAssetRef(assetType, assetNames[index]);
|
||||||
}
|
|
||||||
|
|
||||||
XAssetInfoGeneric* AssetMarker::GetAssetInfoByName(const std::string& name) const
|
|
||||||
{
|
|
||||||
return m_zone.m_pools->GetAsset(m_asset_type, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<XAssetInfoGeneric*> AssetMarker::GetDependencies() const
|
|
||||||
{
|
|
||||||
std::vector<XAssetInfoGeneric*> dependencies;
|
|
||||||
if (!m_dependencies.empty())
|
|
||||||
{
|
|
||||||
dependencies.reserve(m_dependencies.size());
|
|
||||||
for (auto dependency : m_dependencies)
|
|
||||||
dependencies.push_back(dependency);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<scr_string_t> AssetMarker::GetUsedScriptStrings() const
|
|
||||||
{
|
|
||||||
std::vector<scr_string_t> usedScriptStrings;
|
|
||||||
if (!m_used_script_strings.empty())
|
|
||||||
{
|
|
||||||
usedScriptStrings.reserve(m_used_script_strings.size());
|
|
||||||
for (auto scrString : m_used_script_strings)
|
|
||||||
usedScriptStrings.push_back(scrString);
|
|
||||||
|
|
||||||
std::ranges::sort(usedScriptStrings);
|
|
||||||
}
|
|
||||||
|
|
||||||
return usedScriptStrings;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<IndirectAssetReference> AssetMarker::GetIndirectAssetReferences() const
|
|
||||||
{
|
|
||||||
std::vector<IndirectAssetReference> assetReferences;
|
|
||||||
if (!m_indirect_asset_references.empty())
|
|
||||||
{
|
|
||||||
assetReferences.reserve(m_indirect_asset_references.size());
|
|
||||||
for (const auto& assetReference : m_indirect_asset_references)
|
|
||||||
assetReferences.emplace_back(assetReference);
|
|
||||||
}
|
|
||||||
|
|
||||||
return assetReferences;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,30 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Pool/XAssetInfo.h"
|
#include "Game/IAsset.h"
|
||||||
|
#include "Marking/AssetVisitor.h"
|
||||||
#include "Zone/ZoneTypes.h"
|
#include "Zone/ZoneTypes.h"
|
||||||
|
|
||||||
#include <unordered_set>
|
#include <type_traits>
|
||||||
|
|
||||||
class AssetMarker
|
class AssetMarker
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
[[nodiscard]] std::vector<XAssetInfoGeneric*> GetDependencies() const;
|
|
||||||
[[nodiscard]] std::vector<scr_string_t> GetUsedScriptStrings() const;
|
|
||||||
[[nodiscard]] std::vector<IndirectAssetReference> GetIndirectAssetReferences() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AssetMarker(asset_type_t assetType, Zone& zone);
|
explicit AssetMarker(AssetVisitor& visitor);
|
||||||
|
|
||||||
void AddDependency(XAssetInfoGeneric* assetInfo);
|
template<typename AssetType> void Mark_Dependency(std::add_lvalue_reference_t<std::add_pointer_t<typename AssetType::Type>> asset)
|
||||||
|
{
|
||||||
|
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
|
||||||
|
|
||||||
void Mark_ScriptString(scr_string_t scrString);
|
const auto result = m_visitor.Visit_Dependency(AssetType::EnumEntry, AssetNameAccessor<AssetType>()(*asset));
|
||||||
void MarkArray_ScriptString(const scr_string_t* scrStringArray, size_t count);
|
if (result.has_value())
|
||||||
|
asset = static_cast<std::add_pointer_t<typename AssetType::Type>>(result->m_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
void Mark_IndirectAssetRef(asset_type_t type, const char* assetRefName);
|
void Mark_ScriptString(scr_string_t& scriptString) const;
|
||||||
void MarkArray_IndirectAssetRef(asset_type_t type, const char** assetRefNames, size_t count);
|
void MarkArray_ScriptString(scr_string_t* scriptStringArray, size_t count) const;
|
||||||
|
|
||||||
[[nodiscard]] XAssetInfoGeneric* GetAssetInfoByName(const std::string& name) const;
|
void Mark_IndirectAssetRef(asset_type_t assetType, const char* assetName) const;
|
||||||
|
void MarkArray_IndirectAssetRef(asset_type_t assetType, const char** assetNames, size_t count) const;
|
||||||
|
|
||||||
Zone& m_zone;
|
AssetVisitor& m_visitor;
|
||||||
|
|
||||||
private:
|
|
||||||
asset_type_t m_asset_type;
|
|
||||||
|
|
||||||
std::unordered_set<XAssetInfoGeneric*> m_dependencies;
|
|
||||||
std::unordered_set<scr_string_t> m_used_script_strings;
|
|
||||||
std::unordered_set<IndirectAssetReference> m_indirect_asset_references;
|
|
||||||
};
|
};
|
||||||
|
|||||||
29
src/ZoneCommon/Marking/AssetVisitor.h
Normal file
29
src/ZoneCommon/Marking/AssetVisitor.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Pool/XAssetInfo.h"
|
||||||
|
#include "Zone/ZoneTypes.h"
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
class AssetVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~AssetVisitor() = default;
|
||||||
|
|
||||||
|
virtual std::optional<XAssetInfoGeneric> Visit_Dependency(asset_type_t assetType, const char* assetName)
|
||||||
|
{
|
||||||
|
// Do nothing by default
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual std::optional<scr_string_t> Visit_ScriptString(scr_string_t scriptString)
|
||||||
|
{
|
||||||
|
// Do nothing by default
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Visit_IndirectAssetRef(asset_type_t assetType, const char* assetName)
|
||||||
|
{
|
||||||
|
// Do nothing by default
|
||||||
|
}
|
||||||
|
};
|
||||||
85
src/ZoneLoading/Loading/AssetInfoCollector.cpp
Normal file
85
src/ZoneLoading/Loading/AssetInfoCollector.cpp
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
#include "AssetInfoCollector.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
AssetInfoCollector::AssetInfoCollector(Zone& zone)
|
||||||
|
: m_zone(zone)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<XAssetInfoGeneric*> AssetInfoCollector::GetDependencies() const
|
||||||
|
{
|
||||||
|
std::vector<XAssetInfoGeneric*> dependencies;
|
||||||
|
if (!m_dependencies.empty())
|
||||||
|
{
|
||||||
|
dependencies.reserve(m_dependencies.size());
|
||||||
|
for (auto dependency : m_dependencies)
|
||||||
|
dependencies.push_back(dependency);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<scr_string_t> AssetInfoCollector::GetUsedScriptStrings() const
|
||||||
|
{
|
||||||
|
std::vector<scr_string_t> usedScriptStrings;
|
||||||
|
if (!m_used_script_strings.empty())
|
||||||
|
{
|
||||||
|
usedScriptStrings.reserve(m_used_script_strings.size());
|
||||||
|
for (auto scrString : m_used_script_strings)
|
||||||
|
usedScriptStrings.push_back(scrString);
|
||||||
|
|
||||||
|
std::ranges::sort(usedScriptStrings);
|
||||||
|
}
|
||||||
|
|
||||||
|
return usedScriptStrings;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<IndirectAssetReference> AssetInfoCollector::GetIndirectAssetReferences() const
|
||||||
|
{
|
||||||
|
std::vector<IndirectAssetReference> assetReferences;
|
||||||
|
if (!m_indirect_asset_references.empty())
|
||||||
|
{
|
||||||
|
assetReferences.reserve(m_indirect_asset_references.size());
|
||||||
|
for (const auto& assetReference : m_indirect_asset_references)
|
||||||
|
assetReferences.emplace_back(assetReference);
|
||||||
|
}
|
||||||
|
|
||||||
|
return assetReferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<XAssetInfoGeneric> AssetInfoCollector::Visit_Dependency(const asset_type_t assetType, const char* assetName)
|
||||||
|
{
|
||||||
|
auto* assetInfo = m_zone.m_pools->GetAsset(assetType, assetName);
|
||||||
|
if (assetInfo == nullptr)
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
|
const auto existingEntry = m_dependencies.find(assetInfo);
|
||||||
|
if (existingEntry != m_dependencies.end())
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
|
m_dependencies.emplace(assetInfo);
|
||||||
|
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<scr_string_t> AssetInfoCollector::Visit_ScriptString(scr_string_t scriptString)
|
||||||
|
{
|
||||||
|
assert(scriptString < m_zone.m_script_strings.Count());
|
||||||
|
|
||||||
|
if (scriptString >= m_zone.m_script_strings.Count())
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
|
m_used_script_strings.emplace(scriptString);
|
||||||
|
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AssetInfoCollector::Visit_IndirectAssetRef(asset_type_t assetType, const char* assetName)
|
||||||
|
{
|
||||||
|
if (!assetName || !assetName[0])
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_indirect_asset_references.emplace(assetType, assetName);
|
||||||
|
}
|
||||||
31
src/ZoneLoading/Loading/AssetInfoCollector.h
Normal file
31
src/ZoneLoading/Loading/AssetInfoCollector.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Marking/AssetVisitor.h"
|
||||||
|
#include "Pool/XAssetInfo.h"
|
||||||
|
#include "Zone/ZoneTypes.h"
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class AssetInfoCollector : public AssetVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit AssetInfoCollector(Zone& zone);
|
||||||
|
~AssetInfoCollector() override = default;
|
||||||
|
|
||||||
|
[[nodiscard]] std::vector<XAssetInfoGeneric*> GetDependencies() const;
|
||||||
|
[[nodiscard]] std::vector<scr_string_t> GetUsedScriptStrings() const;
|
||||||
|
[[nodiscard]] std::vector<IndirectAssetReference> GetIndirectAssetReferences() const;
|
||||||
|
|
||||||
|
std::optional<XAssetInfoGeneric> Visit_Dependency(asset_type_t assetType, const char* assetName) override;
|
||||||
|
std::optional<scr_string_t> Visit_ScriptString(scr_string_t scriptString) override;
|
||||||
|
void Visit_IndirectAssetRef(asset_type_t assetType, const char* assetName) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unordered_set<XAssetInfoGeneric*> m_dependencies;
|
||||||
|
std::unordered_set<scr_string_t> m_used_script_strings;
|
||||||
|
std::unordered_set<IndirectAssetReference> m_indirect_asset_references;
|
||||||
|
|
||||||
|
Zone& m_zone;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user