libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
Ship::Resource< T > Class Template Referenceabstract

Typed resource base class that provides a strongly-typed pointer accessor. More...

#include <Resource.h>

Inheritance diagram for Ship::Resource< T >:
[legend]
Collaboration diagram for Ship::Resource< T >:
[legend]

Public Member Functions

virtual T * GetPointer ()=0
 Returns a typed pointer to the resource payload.
 
void * GetRawPointer () override
 Returns a type-erased raw pointer to the underlying resource data.
 
 IResource (std::shared_ptr< ResourceInitData > initData)
 Constructs an IResource with the given initialization data.
 
- Public Member Functions inherited from Ship::IResource
 IResource (std::shared_ptr< ResourceInitData > initData)
 Constructs an IResource with the given initialization data.
 
virtual ~IResource ()
 
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.
 

Additional Inherited Members

- Static Public Attributes inherited from Ship::IResource
static const std::string gAltAssetPrefix = "alt/"
 Path prefix that identifies an "alt asset" override.
 

Detailed Description

template<class T>
class Ship::Resource< T >

Typed resource base class that provides a strongly-typed pointer accessor.

Extend this class (rather than IResource directly) when implementing a concrete resource type so that consumers can retrieve the payload without casting.

Template Parameters
TThe concrete payload type exposed by GetPointer().

Member Function Documentation

◆ GetPointer()

template<class T >
virtual T * Ship::Resource< T >::GetPointer ( )
pure virtual

Returns a typed pointer to the resource payload.

Returns
Pointer to T; never null for a successfully loaded resource.

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

◆ GetRawPointer()

template<class T >
void * Ship::Resource< T >::GetRawPointer ( )
inlineoverridevirtual

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.

Implements Ship::IResource.

◆ IResource()

template<class T >
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, …).

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