chore: refactor pool allocation and add indirect references

This commit is contained in:
Jan
2024-02-06 23:03:40 +01:00
parent 1e5475e5ce
commit ac0d8a83a0
24 changed files with 1001 additions and 1083 deletions

View File

@ -7,20 +7,82 @@
class Zone;
// An indirect asset reference is a reference that is not done per pointer but by mentioning the asset
// in a string or requiring the asset to exist in some other way
class IndirectAssetReference
{
public:
asset_type_t m_type;
std::string m_name;
IndirectAssetReference();
IndirectAssetReference(asset_type_t type, std::string name);
};
class XAssetInfoGeneric
{
public:
asset_type_t m_type = -1;
asset_type_t m_type;
std::string m_name;
Zone* m_zone;
void* m_ptr;
std::vector<XAssetInfoGeneric*> m_dependencies;
std::vector<scr_string_t> m_used_script_strings;
void* m_ptr;
std::vector<IndirectAssetReference> m_indirect_asset_references;
Zone* m_zone;
XAssetInfoGeneric();
XAssetInfoGeneric(asset_type_t type, std::string name, void* ptr);
XAssetInfoGeneric(
asset_type_t type, std::string name, void* ptr, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings);
XAssetInfoGeneric(asset_type_t type,
std::string name,
void* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences,
Zone* zone);
~XAssetInfoGeneric() = default;
XAssetInfoGeneric(const XAssetInfoGeneric& other) = default;
XAssetInfoGeneric(XAssetInfoGeneric&& other) noexcept = default;
XAssetInfoGeneric& operator=(const XAssetInfoGeneric& other) = default;
XAssetInfoGeneric& operator=(XAssetInfoGeneric&& other) noexcept = default;
};
template<typename T> class XAssetInfo : public XAssetInfoGeneric
{
public:
XAssetInfo() = default;
XAssetInfo(const asset_type_t type, std::string name, T* ptr)
: XAssetInfoGeneric(type, std::move(name), static_cast<void*>(ptr))
{
}
XAssetInfo(const asset_type_t type, std::string name, T* ptr, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings)
: XAssetInfoGeneric(type, std::move(name), static_cast<void*>(ptr), std::move(dependencies), std::move(usedScriptStrings))
{
}
XAssetInfo(const asset_type_t type,
std::string name,
T* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences,
Zone* zone)
: XAssetInfoGeneric(
type, std::move(name), static_cast<void*>(ptr), std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences), zone)
{
}
~XAssetInfo() = default;
XAssetInfo(const XAssetInfo& other) = default;
XAssetInfo(XAssetInfo&& other) noexcept = default;
XAssetInfo& operator=(const XAssetInfo& other) = default;
XAssetInfo& operator=(XAssetInfo&& other) noexcept = default;
T* Asset()
{
return static_cast<T*>(m_ptr);