Porytiles
Loading...
Searching...
No Matches
porytiles::ProjectLayoutMetadataProvider Class Reference

Provides a pokeemerald project filesystem-based implementation for LayoutMetadataProvider. More...

#include <project_layout_metadata_provider.hpp>

Inheritance diagram for porytiles::ProjectLayoutMetadataProvider:
[legend]
Collaboration diagram for porytiles::ProjectLayoutMetadataProvider:
[legend]

Public Member Functions

 ProjectLayoutMetadataProvider (std::filesystem::path project_root, gsl::not_null< const TextFormatter * > format, gsl::not_null< const UserDiagnostics * > diag)
 
bool exists (const std::string &layout_name_or_id) const override
 Checks whether a layout exists in the backing store for the given layout name or ID.
 
ChainableResult< std::size_t > width (const std::string &layout_name_or_id) const override
 Determines the given layout's width in metatiles.
 
ChainableResult< std::size_t > height (const std::string &layout_name_or_id) const override
 Determines the given layout's height in metatiles.
 
ChainableResult< std::string > primary_tileset (const std::string &layout_name_or_id) const override
 Determines the given layout's primary tileset.
 
ChainableResult< std::string > secondary_tileset (const std::string &layout_name_or_id) const override
 Determines the given layout's secondary tileset.
 
ChainableResult< std::set< std::string > > layout_names () const override
 Returns all layout names known to this provider.
 
ChainableResult< std::set< std::string > > layout_ids () const override
 Returns all layout IDs known to this provider.
 
ChainableResult< std::string > layouts_table_label () const
 
ChainableResult< std::filesystem::path > border_filepath (const std::string &layout_name_or_id) const
 Resolves border file path for a layout by parsing layouts.json.
 
ChainableResult< std::filesystem::path > blockdata_filepath (const std::string &layout_name_or_id) const
 Resolves blockdata file path for a layout by parsing layouts.json.
 
void invalidate_metadata_cache () const
 Invalidates the lazy-loaded layout cache, forcing a re-parse on next access.
 
- Public Member Functions inherited from porytiles::LayoutMetadataProvider
virtual ~LayoutMetadataProvider ()=default
 

Detailed Description

Provides a pokeemerald project filesystem-based implementation for LayoutMetadataProvider.

This class parses layout definitions from layouts.json to extract metadata such a layout's width/height, primary tileset, border filepath, etc.

Layout metadata is lazy-loaded and cached for efficiency.

Definition at line 30 of file project_layout_metadata_provider.hpp.

Constructor & Destructor Documentation

◆ ProjectLayoutMetadataProvider()

porytiles::ProjectLayoutMetadataProvider::ProjectLayoutMetadataProvider ( std::filesystem::path  project_root,
gsl::not_null< const TextFormatter * >  format,
gsl::not_null< const UserDiagnostics * >  diag 
)
inline

Definition at line 32 of file project_layout_metadata_provider.hpp.

Member Function Documentation

◆ blockdata_filepath()

ChainableResult< std::filesystem::path > porytiles::ProjectLayoutMetadataProvider::blockdata_filepath ( const std::string &  layout_name_or_id) const

Resolves blockdata file path for a layout by parsing layouts.json.

Parameters
layout_name_or_idThe name or ID of the layout to check (e.g., "PetalburgCity_Layout" or "LAYOUT_PETALBURG_CITY")
Precondition
layout_name_or_id must refer to an existing layout on disk
Returns
The resolved blockdata filepath for the layout

Definition at line 311 of file project_layout_metadata_provider.cpp.

◆ border_filepath()

ChainableResult< std::filesystem::path > porytiles::ProjectLayoutMetadataProvider::border_filepath ( const std::string &  layout_name_or_id) const

Resolves border file path for a layout by parsing layouts.json.

Parameters
layout_name_or_idThe name or ID of the layout to check (e.g., "PetalburgCity_Layout" or "LAYOUT_PETALBURG_CITY")
Precondition
layout_name_or_id must refer to an existing layout on disk
Returns
The resolved border filepath for the layout

Definition at line 294 of file project_layout_metadata_provider.cpp.

◆ exists()

bool porytiles::ProjectLayoutMetadataProvider::exists ( const std::string &  layout_name_or_id) const
overridevirtual

Checks whether a layout exists in the backing store for the given layout name or ID.

Parameters
layout_name_or_idThe name or ID of the layout to check (e.g., "PetalburgCity_Layout" or "LAYOUT_PETALBURG_CITY")
Returns
True if the layout exists in the backing store, false otherwise

Implements porytiles::LayoutMetadataProvider.

Definition at line 178 of file project_layout_metadata_provider.cpp.

◆ height()

ChainableResult< std::size_t > porytiles::ProjectLayoutMetadataProvider::height ( const std::string &  layout_name_or_id) const
overridevirtual

Determines the given layout's height in metatiles.

Parameters
layout_name_or_idThe name or ID of the layout to check (e.g., "PetalburgCity_Layout" or "LAYOUT_PETALBURG_CITY")
Returns
ChainableResult containing height of the layout

Implements porytiles::LayoutMetadataProvider.

Definition at line 204 of file project_layout_metadata_provider.cpp.

◆ invalidate_metadata_cache()

void porytiles::ProjectLayoutMetadataProvider::invalidate_metadata_cache ( ) const

Invalidates the lazy-loaded layout cache, forcing a re-parse on next access.

This is needed when the underlying layouts.json file has been modified on disk since the cache was populated. For example, after creating a new layout entry, the cache must be invalidated so subsequent lookups see the newly written layout.

Definition at line 327 of file project_layout_metadata_provider.cpp.

◆ layout_ids()

ChainableResult< std::set< std::string > > porytiles::ProjectLayoutMetadataProvider::layout_ids ( ) const
overridevirtual

Returns all layout IDs known to this provider.

Enumerates all layout IDs available in the backing store. This enables batch operations, validation, and listing without requiring callers to know layout IDs in advance.

Returns
ChainableResult containing a set of all layout IDs

Implements porytiles::LayoutMetadataProvider.

Definition at line 268 of file project_layout_metadata_provider.cpp.

◆ layout_names()

ChainableResult< std::set< std::string > > porytiles::ProjectLayoutMetadataProvider::layout_names ( ) const
overridevirtual

Returns all layout names known to this provider.

Enumerates all layout names available in the backing store. This enables batch operations, validation, and listing without requiring callers to know layout names in advance.

Returns
ChainableResult containing a set of all layout names

Implements porytiles::LayoutMetadataProvider.

Definition at line 253 of file project_layout_metadata_provider.cpp.

◆ layouts_table_label()

ChainableResult< std::string > porytiles::ProjectLayoutMetadataProvider::layouts_table_label ( ) const

Definition at line 283 of file project_layout_metadata_provider.cpp.

◆ primary_tileset()

ChainableResult< std::string > porytiles::ProjectLayoutMetadataProvider::primary_tileset ( const std::string &  layout_name_or_id) const
overridevirtual

Determines the given layout's primary tileset.

Parameters
layout_name_or_idThe name or ID of the layout to check (e.g., "PetalburgCity_Layout" or "LAYOUT_PETALBURG_CITY")
Returns
ChainableResult containing primary tileset of the layout

Implements porytiles::LayoutMetadataProvider.

Definition at line 220 of file project_layout_metadata_provider.cpp.

◆ secondary_tileset()

ChainableResult< std::string > porytiles::ProjectLayoutMetadataProvider::secondary_tileset ( const std::string &  layout_name_or_id) const
overridevirtual

Determines the given layout's secondary tileset.

Parameters
layout_name_or_idThe name or ID of the layout to check (e.g., "PetalburgCity_Layout" or "LAYOUT_PETALBURG_CITY")
Returns
ChainableResult containing secondary tileset of the layout

Implements porytiles::LayoutMetadataProvider.

Definition at line 237 of file project_layout_metadata_provider.cpp.

◆ width()

ChainableResult< std::size_t > porytiles::ProjectLayoutMetadataProvider::width ( const std::string &  layout_name_or_id) const
overridevirtual

Determines the given layout's width in metatiles.

Parameters
layout_name_or_idThe name or ID of the layout to check (e.g., "PetalburgCity_Layout" or "LAYOUT_PETALBURG_CITY")
Returns
ChainableResult containing width of the layout

Implements porytiles::LayoutMetadataProvider.

Definition at line 188 of file project_layout_metadata_provider.cpp.


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