VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
visutwin::canvas::Asset Class Reference

Loadable resource wrapper supporting textures, containers (GLB), and fonts. More...

#include <framework/assets/asset.h>

Inheritance diagram for visutwin::canvas::Asset:
[legend]

Public Member Functions

 Asset (const std::string &name, const std::string &type, const std::string &file, const AssetData &data={})
const AssetDatadata () const
const std::string & file () const
void loadAsync (ResourceLoader &loader, std::function< void(std::optional< Resource >)> callback)
const std::string & name () const
bool preload () const
std::optional< Resourceresource ()
 Synchronous load — blocks until the resource is ready.
const std::string & type () const
void unload ()
Public Member Functions inherited from visutwin::canvas::EventHandler
template<typename... Args>
EventHandlerfire (const std::string &name, Args &&... args)
bool hasEvent (const std::string &name) const
void initEventHandler ()
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleroff (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleroff (const std::string &name="", const HandleEventCallback &callback=HandleEventCallback(), void *scope=nullptr)
EventHandleroffByHandle (EventHandle *handle)
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleon (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleon (const std::string &name, HandleEventCallback callback, void *scope=nullptr)
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleonce (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleonce (const std::string &name, HandleEventCallback callback, void *scope=nullptr)
virtual ~EventHandler ()=default

Static Public Member Functions

static void setDefaultGraphicsDevice (const std::shared_ptr< GraphicsDevice > &graphicsDevice)

Additional Inherited Members

Protected Member Functions inherited from visutwin::canvas::EventHandler
EventHandleaddCallback (const std::string &name, HandleEventCallback callback, void *scope=nullptr, bool once=false)

Detailed Description

Loadable resource wrapper supporting textures, containers (GLB), and fonts.

Asset wraps a typed Resource (Texture, ContainerResource, or FontResource) and provides synchronous and asynchronous loading via the ResourceLoader. Assets are registered in the AssetRegistry and referenced by name or ID.

Definition at line 70 of file asset.h.

Constructor & Destructor Documentation

◆ Asset()

visutwin::canvas::Asset::Asset ( const std::string & name,
const std::string & type,
const std::string & file,
const AssetData & data = {} )

Definition at line 25 of file asset.cpp.

References data(), file(), name(), and type().

Member Function Documentation

◆ data()

const AssetData & visutwin::canvas::Asset::data ( ) const
inline

Definition at line 82 of file asset.h.

Referenced by Asset(), and loadAsync().

◆ file()

const std::string & visutwin::canvas::Asset::file ( ) const
inline

Definition at line 81 of file asset.h.

Referenced by Asset(), and loadAsync().

◆ loadAsync()

void visutwin::canvas::Asset::loadAsync ( ResourceLoader & loader,
std::function< void(std::optional< Resource >)> callback )

◆ name()

const std::string & visutwin::canvas::Asset::name ( ) const
inline

Definition at line 79 of file asset.h.

Referenced by Asset(), and loadAsync().

◆ preload()

bool visutwin::canvas::Asset::preload ( ) const
inline

Definition at line 77 of file asset.h.

◆ resource()

◆ setDefaultGraphicsDevice()

void visutwin::canvas::Asset::setDefaultGraphicsDevice ( const std::shared_ptr< GraphicsDevice > & graphicsDevice)
static

Definition at line 30 of file asset.cpp.

Referenced by visutwin::canvas::Engine::init().

◆ type()

const std::string & visutwin::canvas::Asset::type ( ) const
inline

Definition at line 80 of file asset.h.

Referenced by Asset(), and loadAsync().

◆ unload()

void visutwin::canvas::Asset::unload ( )

Definition at line 35 of file asset.cpp.

References resource().


The documentation for this class was generated from the following files: