cubos::engine::AssetBridge class

Bridges are the objects responsible for loading and saving assets from/to disk. They form the bridge between the asset manager and the virtual file system.

Not all bridges need to implement the save method. You could have an asset type which could be loaded but not saved, for example.

Bridges should take into account that the asset manager calls them from a different thread than the one that created them.

Derived classes

class FileBridge
Abstract bridge type defined to reduce boilerplate code in bridge implementations which open a single file to load and save assets.

Constructors, destructors, conversion operators

AssetBridge(const core::reflection::Type& type, bool asynchronous = true) explicit
Constructs a bridge.

Public functions

auto load(Assets& assets, const AnyAsset& handle) -> bool pure virtual
Loads an asset.
auto save(const Assets& assets, const AnyAsset& handle) -> bool virtual
Saves an asset.
auto assetType() const -> const core::reflection::Type&
Gets the type of the assets the bridge loads.
auto asynchronous() const -> bool
Whether the bridge should load assets asynchronously.

Function documentation

cubos::engine::AssetBridge::AssetBridge(const core::reflection::Type& type, bool asynchronous = true) explicit

Constructs a bridge.

Parameters
type Type of assets loaded by the bridge.
asynchronous Whether the bridge should load assets asynchronously.

bool cubos::engine::AssetBridge::load(Assets& assets, const AnyAsset& handle) pure virtual

Loads an asset.

Parameters
assets Manager to write into.
handle Handle of the asset being loaded.
Returns Whether the asset was successfully loaded.

The metadata of the given asset should already be present in the asset manager.

bool cubos::engine::AssetBridge::save(const Assets& assets, const AnyAsset& handle) virtual

Saves an asset.

Parameters
assets Manager to read from.
handle Handle of the asset being saved.
Returns Whether the asset was successfully saved.

The asset should be loaded in the asset manager.

const core::reflection::Type& cubos::engine::AssetBridge::assetType() const

Gets the type of the assets the bridge loads.

Returns Type of the asset.

bool cubos::engine::AssetBridge::asynchronous() const

Whether the bridge should load assets asynchronously.

Returns Whether the bridge should load assets asynchronously.