Loading...
Searching...
No Matches
hellfire::AssetRegistry Class Reference

Registry for storing assets. More...

#include <AssetRegistry.h>

Collaboration diagram for hellfire::AssetRegistry:

Public Member Functions

 AssetRegistry (const std::filesystem::path &registry_file, const std::filesystem::path &project_root)
 
 ~AssetRegistry ()
 
AssetID register_asset (const std::filesystem::path &filepath)
 
AssetID register_asset (const std::filesystem::path &filepath, AssetType type)
 
void unregister_asset (AssetID uuid)
 
std::vector< AssetIDregister_directory (const std::filesystem::path &directory_path, bool recursive)
 
void refresh_assets ()
 
std::optional< AssetMetadataget_asset (AssetID uuid) const
 
std::optional< AssetIDget_uuid_by_path (const std::filesystem::path &filepath)
 
std::vector< AssetMetadataget_assets_by_type (AssetType type)
 
std::vector< AssetMetadataget_all_assets () const
 
bool asset_exists (AssetID uuid) const
 
std::filesystem::path get_absolute_path (AssetID uuid)
 
std::filesystem::path get_relative_path (AssetID uuid)
 
bool has_asset_changed (AssetID uuid) const
 
std::vector< AssetIDget_modified_assets () const
 
void save ()
 
bool load ()
 
void clear ()
 
size_t get_asset_count () const
 
void set_project_root (const std::filesystem::path &project_root)
 
const std::filesystem::path & get_project_root ()
 

Static Public Member Functions

static AssetType get_type_from_extension (const std::filesystem::path &filepath)
 

Private Member Functions

AssetID generate_uuid (const std::filesystem::path &filepath)
 
std::filesystem::path to_relative_path (const std::filesystem::path &absolute_path) const
 
std::filesystem::path to_absolute_path (const std::filesystem::path &relative_path) const
 
void rebuild_path_map ()
 
uint64_t get_file_last_modified (const std::filesystem::path &filepath) const
 

Private Attributes

std::unordered_map< AssetID, AssetMetadataassets_
 
std::unordered_map< std::filesystem::path, AssetIDpath_to_uuid_
 
std::filesystem::path registry_file_
 
std::filesystem::path project_root_
 

Detailed Description

Registry for storing assets.

Definition at line 35 of file AssetRegistry.h.

Constructor & Destructor Documentation

◆ AssetRegistry()

hellfire::AssetRegistry::AssetRegistry ( const std::filesystem::path &  registry_file,
const std::filesystem::path &  project_root 
)
explicit

Definition at line 15 of file AssetRegistry.cpp.

◆ ~AssetRegistry()

hellfire::AssetRegistry::~AssetRegistry ( )

Definition at line 19 of file AssetRegistry.cpp.

Member Function Documentation

◆ asset_exists()

bool hellfire::AssetRegistry::asset_exists ( AssetID  uuid) const

Definition at line 133 of file AssetRegistry.cpp.

◆ clear()

void hellfire::AssetRegistry::clear ( )

Definition at line 223 of file AssetRegistry.cpp.

◆ generate_uuid()

AssetID hellfire::AssetRegistry::generate_uuid ( const std::filesystem::path &  filepath)
private

Definition at line 258 of file AssetRegistry.cpp.

◆ get_absolute_path()

std::filesystem::path hellfire::AssetRegistry::get_absolute_path ( AssetID  uuid)

Definition at line 137 of file AssetRegistry.cpp.

◆ get_all_assets()

std::vector< AssetMetadata > hellfire::AssetRegistry::get_all_assets ( ) const

Definition at line 124 of file AssetRegistry.cpp.

◆ get_asset()

std::optional< AssetMetadata > hellfire::AssetRegistry::get_asset ( AssetID  uuid) const

Definition at line 97 of file AssetRegistry.cpp.

◆ get_asset_count()

size_t hellfire::AssetRegistry::get_asset_count ( ) const
inline

Definition at line 69 of file AssetRegistry.h.

◆ get_assets_by_type()

std::vector< AssetMetadata > hellfire::AssetRegistry::get_assets_by_type ( AssetType  type)

Definition at line 114 of file AssetRegistry.cpp.

◆ get_file_last_modified()

AssetID hellfire::AssetRegistry::get_file_last_modified ( const std::filesystem::path &  filepath) const
private

Definition at line 279 of file AssetRegistry.cpp.

◆ get_modified_assets()

std::vector< AssetID > hellfire::AssetRegistry::get_modified_assets ( ) const

Definition at line 163 of file AssetRegistry.cpp.

◆ get_project_root()

const std::filesystem::path & hellfire::AssetRegistry::get_project_root ( )
inline

Definition at line 73 of file AssetRegistry.h.

◆ get_relative_path()

std::filesystem::path hellfire::AssetRegistry::get_relative_path ( AssetID  uuid)

Definition at line 144 of file AssetRegistry.cpp.

◆ get_type_from_extension()

AssetType hellfire::AssetRegistry::get_type_from_extension ( const std::filesystem::path &  filepath)
static

Definition at line 232 of file AssetRegistry.cpp.

◆ get_uuid_by_path()

std::optional< uint64_t > hellfire::AssetRegistry::get_uuid_by_path ( const std::filesystem::path &  filepath)

Definition at line 105 of file AssetRegistry.cpp.

◆ has_asset_changed()

bool hellfire::AssetRegistry::has_asset_changed ( AssetID  uuid) const

Definition at line 151 of file AssetRegistry.cpp.

◆ load()

bool hellfire::AssetRegistry::load ( )

Definition at line 192 of file AssetRegistry.cpp.

◆ rebuild_path_map()

void hellfire::AssetRegistry::rebuild_path_map ( )
private

Definition at line 272 of file AssetRegistry.cpp.

◆ refresh_assets()

void hellfire::AssetRegistry::refresh_assets ( )

Definition at line 88 of file AssetRegistry.cpp.

◆ register_asset() [1/2]

AssetID hellfire::AssetRegistry::register_asset ( const std::filesystem::path &  filepath)

Definition at line 23 of file AssetRegistry.cpp.

◆ register_asset() [2/2]

AssetID hellfire::AssetRegistry::register_asset ( const std::filesystem::path &  filepath,
AssetType  type 
)

Definition at line 28 of file AssetRegistry.cpp.

◆ register_directory()

std::vector< AssetID > hellfire::AssetRegistry::register_directory ( const std::filesystem::path &  directory_path,
bool  recursive 
)

Definition at line 66 of file AssetRegistry.cpp.

◆ save()

void hellfire::AssetRegistry::save ( )

Definition at line 173 of file AssetRegistry.cpp.

◆ set_project_root()

void hellfire::AssetRegistry::set_project_root ( const std::filesystem::path &  project_root)

Definition at line 228 of file AssetRegistry.cpp.

◆ to_absolute_path()

std::filesystem::path hellfire::AssetRegistry::to_absolute_path ( const std::filesystem::path &  relative_path) const
private

Definition at line 268 of file AssetRegistry.cpp.

◆ to_relative_path()

std::filesystem::path hellfire::AssetRegistry::to_relative_path ( const std::filesystem::path &  absolute_path) const
private

Definition at line 264 of file AssetRegistry.cpp.

◆ unregister_asset()

void hellfire::AssetRegistry::unregister_asset ( AssetID  uuid)

Definition at line 59 of file AssetRegistry.cpp.

Member Data Documentation

◆ assets_

std::unordered_map<AssetID, AssetMetadata> hellfire::AssetRegistry::assets_
private

Definition at line 77 of file AssetRegistry.h.

◆ path_to_uuid_

std::unordered_map<std::filesystem::path, AssetID> hellfire::AssetRegistry::path_to_uuid_
private

Definition at line 78 of file AssetRegistry.h.

◆ project_root_

std::filesystem::path hellfire::AssetRegistry::project_root_
private

Definition at line 80 of file AssetRegistry.h.

◆ registry_file_

std::filesystem::path hellfire::AssetRegistry::registry_file_
private

Definition at line 79 of file AssetRegistry.h.


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