Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 44s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 29s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 46s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 30s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 1m21s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 1m3s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m25s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 1m8s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 1m9s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m34s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 1m13s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 37s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 28s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 57s
Bigfoot / Sonarqube (push) Successful in 6m0s
sonarqube ERROR
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 49s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 30s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 52s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 36s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 1m23s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 44s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 59s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 51s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m5s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 56s
Bigfoot / Clang Format Checks (push) Successful in 13s
Bigfoot / Sonarqube (pull_request) Failing after 5m14s
Implementing an asset management system BigFile is a sqlite database, for toolmode Sasquatch is a custom binary file, for gamemode Assets are built from flatbuffers References allow to get an Asset, from an UUID, from anywhere in the code HardReference refcount the asset and allow automatic removal Reviewed-on: #1 Co-authored-by: Romain BOULLARD <romain.boullard@protonmail.com>
146 lines
4.4 KiB
C++
146 lines
4.4 KiB
C++
/*********************************************************************
|
|
* \file DataAccessor.hpp
|
|
*
|
|
* \author Romain BOULLARD
|
|
* \date August 2026
|
|
*********************************************************************/
|
|
#ifndef BIGFOOT_ENGINE_DATAACCESSOR_DATAACCESSOR_HPP
|
|
#define BIGFOOT_ENGINE_DATAACCESSOR_DATAACCESSOR_HPP
|
|
#include <Engine/Asset/AssetTypeID.hpp>
|
|
|
|
#include <System/Time/Time.hpp>
|
|
#include <System/UUID/UUID.hpp>
|
|
|
|
#include <EASTL/span.h>
|
|
#include <EASTL/string.h>
|
|
#include <EASTL/vector.h>
|
|
|
|
namespace Bigfoot
|
|
{
|
|
class DataAccessor
|
|
{
|
|
public:
|
|
DataAccessor() = default;
|
|
|
|
DataAccessor(const DataAccessor& p_accessor) = default;
|
|
DataAccessor(DataAccessor&& p_accessor) = default;
|
|
|
|
virtual ~DataAccessor() = default;
|
|
|
|
/**
|
|
* Get an Asset flatbuffer
|
|
*
|
|
* \param p_uuid The asset to get the flatbuffer of
|
|
* \return The flatbuffer, or an empty vector if the asset was not found
|
|
*/
|
|
[[nodiscard]]
|
|
virtual eastl::vector<std::byte> GetAssetFlatbuffer(const UUID& p_uuid) const = 0;
|
|
|
|
/**
|
|
* Get several Asset flatbuffers
|
|
*
|
|
* \param p_uuids The assets to get the flatbuffers of
|
|
* \return The flatbuffers that were found
|
|
*/
|
|
[[nodiscard]]
|
|
virtual eastl::vector<eastl::vector<std::byte>> GetAssetFlatbuffers(eastl::span<const UUID> p_uuids) const = 0;
|
|
|
|
/**
|
|
* Get the HardReferences of a given asset
|
|
*
|
|
* \param p_uuid The asset to get the HardReferences of
|
|
* \return The HardReferences of the asset
|
|
*/
|
|
[[nodiscard]]
|
|
virtual eastl::vector<UUID> GetAssetHardReferences(const UUID& p_uuid) const = 0;
|
|
|
|
/**
|
|
* Get the HardReferences of given assets
|
|
*
|
|
* \param p_uuids The assets to get the HardReferences of
|
|
* \return The HardReferences of the assets
|
|
*/
|
|
[[nodiscard]]
|
|
virtual eastl::vector<eastl::vector<UUID>> GetAssetsHardReferences(eastl::span<const UUID> p_uuids) const = 0;
|
|
|
|
/**
|
|
* Save an asset
|
|
*
|
|
* \param p_uuid The UUID
|
|
* \param p_flatbuffer The flatbuffer of the asset
|
|
* \param p_hardReferences The HardReferences the asset points to
|
|
*/
|
|
virtual void SaveAssetFlatbuffer(const UUID& p_uuid,
|
|
const eastl::span<const std::byte> p_flatbuffer,
|
|
const eastl::span<const UUID> p_hardReferences) = 0;
|
|
|
|
/**
|
|
* Save several assets
|
|
*
|
|
* \param p_uuids The UUIDs
|
|
* \param p_flatbuffers The flatbuffers of the assets, matching p_metadatas by index
|
|
* \param p_hardReferences The HardReferences the asset points to
|
|
*/
|
|
virtual void SaveAssetFlatbuffers(const eastl::span<const UUID> p_uuids,
|
|
const eastl::span<const eastl::vector<std::byte>> p_flatbuffers,
|
|
const eastl::span<const eastl::vector<UUID>> p_hardReferences) = 0;
|
|
|
|
/**
|
|
* Check if the Asset exists
|
|
*
|
|
* \param p_uuid The asset to check
|
|
* \param True if it exists, false otherwise
|
|
*/
|
|
[[nodiscard]]
|
|
virtual bool Has(const UUID& p_uuid) const = 0;
|
|
|
|
DataAccessor& operator=(const DataAccessor& p_accessor) = default;
|
|
DataAccessor& operator=(DataAccessor&& p_accessor) = default;
|
|
};
|
|
|
|
/****************************************************************************************/
|
|
|
|
// The global data accessor for Bigfoot
|
|
inline DataAccessor* g_dataAccessor = nullptr;
|
|
|
|
/****************************************************************************************/
|
|
|
|
/*
|
|
* Set the data accessor
|
|
*
|
|
* \param p_dataAccessor The data accessor to set g_dataAccessor to.
|
|
*/
|
|
void SetDataAccessor(DataAccessor* p_dataAccessor);
|
|
|
|
/****************************************************************************************/
|
|
|
|
class ScopedDataAccessor
|
|
{
|
|
public:
|
|
ScopedDataAccessor(DataAccessor* p_dataAccessor):
|
|
m_previous(g_dataAccessor)
|
|
{
|
|
SetDataAccessor(p_dataAccessor);
|
|
}
|
|
|
|
ScopedDataAccessor(const ScopedDataAccessor& p_scopedDataAccessor) = delete;
|
|
ScopedDataAccessor(ScopedDataAccessor&& p_scopedDataAccessor) = delete;
|
|
|
|
~ScopedDataAccessor()
|
|
{
|
|
SetDataAccessor(m_previous);
|
|
}
|
|
|
|
ScopedDataAccessor& operator=(const ScopedDataAccessor& p_scopedDataAccessor) = delete;
|
|
ScopedDataAccessor& operator=(ScopedDataAccessor&& p_scopedDataAccessor) = delete;
|
|
|
|
private:
|
|
/*
|
|
* The previous data accessor.
|
|
*/
|
|
DataAccessor* m_previous = nullptr;
|
|
};
|
|
} // namespace Bigfoot
|
|
|
|
#endif
|