Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
AeonGames::ResourceId Class Reference

Identifies a resource by its type and path CRC32 hashes. More...

#include <aeongames/ResourceId.hpp>

Collaboration diagram for AeonGames::ResourceId:
Collaboration graph

Public Member Functions

 ResourceId ()=default
 Default constructor.
 ResourceId (const ResourceId &)=default
 Copy constructor.
 ResourceId (uint32_t aType, uint32_t aPath)
 Construct from pre-computed CRC32 hashes.
 ResourceId (const std::string &aType, const std::string &aPath)
 Construct from type and path strings (hashed internally).
 ResourceId (const std::string &aType, uint32_t aPath)
 Construct from a type string and a pre-computed path hash.
 ResourceId (uint32_t aType, const std::string &aPath)
 Construct from a pre-computed type hash and a path string.
 operator bool () const
 Check whether the identified resource is currently loaded.
uint32_t GetType () const
 Get the CRC32 hash of the resource type.
uint32_t GetPath () const
 Get the CRC32 hash of the resource path.
std::string GetPathString () const
 Get the original resource path string from the hash.
template<typename T>
T * Cast () const
 Cast the cached resource to the specified type without loading.
template<typename T>
T * Get () const
 Get the resource, loading and caching it if necessary.
void Store () const
 Construct and store the resource in the cache if not already present.
void Dispose () const
 Remove the resource from the cache if present.

Detailed Description

Identifies a resource by its type and path CRC32 hashes.

Definition at line 29 of file ResourceId.hpp.

Constructor & Destructor Documentation

◆ ResourceId() [1/5]

AeonGames::ResourceId::ResourceId ( )
default

Default constructor.

Creates an empty resource identifier.

◆ ResourceId() [2/5]

AeonGames::ResourceId::ResourceId ( uint32_t aType,
uint32_t aPath )
inline

Construct from pre-computed CRC32 hashes.

Parameters
aTypeCRC32 hash of the resource type.
aPathCRC32 hash of the resource path.

Definition at line 39 of file ResourceId.hpp.

◆ ResourceId() [3/5]

AeonGames::ResourceId::ResourceId ( const std::string & aType,
const std::string & aPath )
inline

Construct from type and path strings (hashed internally).

Parameters
aTypeResource type string.
aPathResource path string.

Definition at line 44 of file ResourceId.hpp.

◆ ResourceId() [4/5]

AeonGames::ResourceId::ResourceId ( const std::string & aType,
uint32_t aPath )
inline

Construct from a type string and a pre-computed path hash.

Parameters
aTypeResource type string.
aPathCRC32 hash of the resource path.

Definition at line 49 of file ResourceId.hpp.

◆ ResourceId() [5/5]

AeonGames::ResourceId::ResourceId ( uint32_t aType,
const std::string & aPath )
inline

Construct from a pre-computed type hash and a path string.

Parameters
aTypeCRC32 hash of the resource type.
aPathResource path string.

Definition at line 54 of file ResourceId.hpp.

Member Function Documentation

◆ Cast()

template<typename T>
T * AeonGames::ResourceId::Cast ( ) const
inline

Cast the cached resource to the specified type without loading.

Template Parameters
TTarget resource type.
Returns
Pointer to the resource, or nullptr if not cached or wrong type.

Definition at line 90 of file ResourceId.hpp.

◆ Dispose()

void AeonGames::ResourceId::Dispose ( ) const
inline

Remove the resource from the cache if present.

Definition at line 120 of file ResourceId.hpp.

◆ Get()

template<typename T>
T * AeonGames::ResourceId::Get ( ) const
inline

Get the resource, loading and caching it if necessary.

Template Parameters
TTarget resource type.
Returns
Pointer to the resource.

Definition at line 99 of file ResourceId.hpp.

◆ GetPath()

uint32_t AeonGames::ResourceId::GetPath ( ) const
inline

Get the CRC32 hash of the resource path.

Returns
Path hash.

Definition at line 74 of file ResourceId.hpp.

◆ GetPathString()

std::string AeonGames::ResourceId::GetPathString ( ) const
inline

Get the original resource path string from the hash.

Returns
Resource path string.

Definition at line 81 of file ResourceId.hpp.

◆ GetType()

uint32_t AeonGames::ResourceId::GetType ( ) const
inline

Get the CRC32 hash of the resource type.

Returns
Type hash.

Definition at line 67 of file ResourceId.hpp.

◆ operator bool()

AeonGames::ResourceId::operator bool ( ) const
inline

Check whether the identified resource is currently loaded.

Returns
True if the resource exists in the cache.

Definition at line 60 of file ResourceId.hpp.

◆ Store()

void AeonGames::ResourceId::Store ( ) const
inline

Construct and store the resource in the cache if not already present.

Definition at line 110 of file ResourceId.hpp.


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