class
#include <engine/assets/bridges/file.hpp>
FileBridge Abstract bridge type defined to reduce boilerplate code in bridge implementations which open a single file to load and save assets.
This bridge should be used as a base class for bridges which load and save assets. Child classes must implement the loadFromFile() and saveToFile() methods, which are called with a file stream to load and save the asset from and to, respectively.
Base classes
- class AssetBridge
- 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.
Derived classes
- class ImageBridge
- Bridge which loads and saves Image assets.
-
template<typename T>class JSONBridge
- Bridge for loading and saving assets which are serialized to and from a JSON file.
- class SceneBridge
- Bridge which loads and saves Scene assets.
- class ShaderBridge
- Bridge for loading shader assets.
- class VoxelGridBridge
- Bridge which loads and saves Grid assets.
- class VoxelPaletteBridge
- Bridge which loads and saves Palette assets.
Constructors, destructors, conversion operators
-
FileBridge(const core::
reflection:: Type& type, bool asynchronous = true) explicit - Constructs a bridge.
Public functions
Protected functions
-
auto loadFromFile(Assets& assets,
const AnyAsset& handle,
core::
memory:: Stream& stream) -> bool pure virtual - Loads an asset from a file stream.
-
auto saveToFile(const Assets& assets,
const AnyAsset& handle,
core::
memory:: Stream& stream) -> bool pure virtual - Saves an asset to a file stream.
Function documentation
cubos:: engine:: FileBridge:: FileBridge(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:: FileBridge:: load(Assets& assets,
const AnyAsset& handle) final
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:: FileBridge:: loadFromFile(Assets& assets,
const AnyAsset& handle,
core:: memory:: Stream& stream) pure virtual protected
Loads an asset from a file stream.
Parameters | |
---|---|
assets | Manager to write into. |
handle | Handle of the asset being loaded. |
stream | File stream. |
Returns | Whether the asset was successfully loaded. |
bool cubos:: engine:: FileBridge:: saveToFile(const Assets& assets,
const AnyAsset& handle,
core:: memory:: Stream& stream) pure virtual protected
Saves an asset to a file stream.
Parameters | |
---|---|
assets | Manager to read from. |
handle | Handle of the asset being saved. |
stream | File stream. |
Returns | Whether the asset was successfully saved. |