libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
Ship::IResource Class Referenceabstract

Non-templated base interface for all resources managed by the ResourceManager. More...

#include <Resource.h>

Inheritance diagram for Ship::IResource:
[legend]

Public Member Functions

 IResource (std::shared_ptr< ResourceInitData > initData)
 Constructs an IResource with the given initialization data.
 
virtual ~IResource ()
 
virtual void * GetRawPointer ()=0
 Returns a type-erased raw pointer to the underlying resource data.
 
virtual size_t GetPointerSize ()=0
 Returns the size (in bytes) of the type pointed to by GetRawPointer().
 
bool IsDirty ()
 Returns true if the resource has been marked dirty.
 
void Dirty ()
 Marks the resource as dirty.
 
std::shared_ptr< ResourceInitDataGetInitData ()
 Returns the initialization data used to load this resource.
 

Static Public Attributes

static const std::string gAltAssetPrefix = "alt/"
 Path prefix that identifies an "alt asset" override.
 

Detailed Description

Non-templated base interface for all resources managed by the ResourceManager.

IResource stores the initialization metadata that was used to load the underlying data and exposes a type-erased pointer to that data. The dirty flag is used to signal that the resource needs to be reloaded or regenerated (e.g. when the source archive changes).

Constructor & Destructor Documentation

◆ IResource()

Ship::IResource::IResource ( std::shared_ptr< ResourceInitData initData)

Constructs an IResource with the given initialization data.

Parameters
initDataMetadata describing how this resource was loaded (path, type, version, …).

◆ ~IResource()

virtual Ship::IResource::~IResource ( )
virtual

Member Function Documentation

◆ Dirty()

void Ship::IResource::Dirty ( )

Marks the resource as dirty.

Callers (e.g. the ResourceManager) use this to signal that the cached data is no longer up-to-date and should be reloaded before next use.

◆ GetInitData()

std::shared_ptr< ResourceInitData > Ship::IResource::GetInitData ( )

Returns the initialization data used to load this resource.

Returns
Shared pointer to the ResourceInitData.

◆ GetPointerSize()

virtual size_t Ship::IResource::GetPointerSize ( )
pure virtual

Returns the size (in bytes) of the type pointed to by GetRawPointer().

Returns
Size in bytes.

Implemented in Fast::Light, Fast::DisplayList, Fast::Matrix, Fast::Texture, Fast::Vertex, Ship::Blob, Ship::Json, Ship::Shader, Ship::Font, and Ship::GuiTexture.

◆ GetRawPointer()

virtual void * Ship::IResource::GetRawPointer ( )
pure virtual

Returns a type-erased raw pointer to the underlying resource data.

Returns
Void pointer to the resource payload; never null for a successfully loaded resource.

Implemented in Ship::Resource< T >, Ship::Resource< Gfx >, Ship::Resource< LightEntry >, Ship::Resource< Mtx >, Ship::Resource< uint8_t >, Ship::Resource< void >, and Ship::Resource< Vtx >.

◆ IsDirty()

bool Ship::IResource::IsDirty ( )

Returns true if the resource has been marked dirty.

A dirty resource should be considered stale and may need to be reloaded.

Member Data Documentation

◆ gAltAssetPrefix

const std::string Ship::IResource::gAltAssetPrefix = "alt/"
inlinestatic

Path prefix that identifies an "alt asset" override.


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