Class AssetManager

Class Documentation

class AssetManager

AssetManager can store assets and serialize.

Public Functions

AssetManager()
AssetManager(std::string rootPath)
void addExisting(std::vector<std::shared_ptr<Asset>> assets)

Adds all assets in an array to the AssetManager

Parameters:

assets – Vector of assets to add

std::string getRootPath()

Get root path of the asset manager

Returns:

Root path

void setRootPath(const std::string &rootPath)

Set root path of the asset manager

Parameters:

rootPath – Root path

std::shared_ptr<dai::Asset> set(Asset asset)

Adds or overwrites an asset object to AssetManager.

Parameters:

assetAsset to add

Returns:

Shared pointer to asset

std::shared_ptr<dai::Asset> set(const std::string &key, Asset asset)

Adds or overwrites an asset object to AssetManager with a specified key. Key value will be assigned to an Asset as well

Parameters:
  • key – Key under which the asset should be stored

  • assetAsset to store

Returns:

Shared pointer to asset

std::shared_ptr<dai::Asset> set(const std::string &key, const std::filesystem::path &path, int alignment = 64)

Loads file into asset manager under specified key.

Parameters:
  • key – Key under which the asset should be stored

  • path – Path to file which to load as asset

  • alignment – [Optional] alignment of asset data in asset storage. Default is 64B

std::shared_ptr<dai::Asset> set(const std::string &key, const std::vector<std::uint8_t> &data, int alignment = 64)

Loads file into asset manager under specified key.

Parameters:
  • key – Key under which the asset should be stored

  • dataAsset data

  • alignment – [Optional] alignment of asset data in asset storage. Default is 64B

Returns:

Shared pointer to asset

std::shared_ptr<dai::Asset> set(const std::string &key, std::vector<std::uint8_t> &&data, int alignment = 64)
std::shared_ptr<const Asset> get(const std::string &key) const
Returns:

Asset assigned to the specified key or a nullptr otherwise

std::shared_ptr<Asset> get(const std::string &key)
Returns:

Asset assigned to the specified key or a nullptr otherwise

std::vector<std::shared_ptr<const Asset>> getAll() const
Returns:

All asset stored in the AssetManager

std::vector<std::shared_ptr<Asset>> getAll()
Returns:

All asset stored in the AssetManager

std::size_t size() const
Returns:

Number of asset stored in the AssetManager

void remove(const std::string &key)

Removes asset with key

Parameters:

key – Key of asset to remove

void serialize(AssetsMutable &assets, std::vector<std::uint8_t> &assetStorage, std::string prefix = "") const

Serializes.