Porytiles
Loading...
Searching...
No Matches
porytiles2::TilesetArtifactKeyProvider Class Referenceabstract

Abstract interface for generating keys and discovering tileset artifacts in a backing store. More...

#include <tileset_artifact_key_provider.hpp>

Inheritance diagram for porytiles2::TilesetArtifactKeyProvider:
[legend]

Public Member Functions

virtual ~TilesetArtifactKeyProvider ()=default
 
virtual ArtifactKey key_for (const std::string &tileset_name, const TilesetArtifact &artifact) const =0
 Constructs a key for a given tileset artifact.
 
virtual bool artifact_exists (const ArtifactKey &key) const =0
 Checks whether an artifact exists in the backing store for the given key.
 
virtual bool tileset_exists (const std::string &tileset_name) const =0
 Checks whether a tileset exists in the backing store for the given tileset name.
 
virtual std::set< std::string > discover_porytiles_anims (const std::string &tileset_name) const =0
 Discovers the names of all Porytiles animations available for a tileset.
 
virtual std::set< int > discover_porytiles_anim_frames (const std::string &tileset_name, const std::string &anim_name) const =0
 Discovers the frame indices for a specific Porytiles animation.
 
virtual std::set< std::string > discover_porymap_anims (const std::string &tileset_name) const =0
 Discovers the names of all Porymap animations available for a tileset.
 
virtual std::set< int > discover_porymap_anim_frames (const std::string &tileset_name, const std::string &anim_name) const =0
 Discovers the frame indices for a specific Porymap animation.
 
virtual std::vector< ArtifactKeyget_porytiles_artifact_keys (const std::string &tileset_name) const
 Gets the keys for all Porytiles artifacts present in the given Tileset.
 
virtual std::vector< ArtifactKeyget_porymap_artifact_keys (const std::string &tileset_name) const
 Gets the keys for all Porymap artifacts present in the given Tileset.
 
virtual std::vector< ArtifactKeyget_all_artifact_keys (const std::string &tileset_name) const
 Gets the keys for all tileset artifacts (both Porytiles and Porymap) present in the given Tileset.
 

Detailed Description

Abstract interface for generating keys and discovering tileset artifacts in a backing store.

This interface provides the key generation and discovery functionality needed by the tileset repository system. Implementations handle the specifics of how to organize and access artifacts in different backing stores (filesystem, database, etc.).

The interface separates key generation (which should be fast and stateless) from discovery operations (which may involve I/O to search the backing store). Implementations may choose to cache expensive lookups during construction to optimize performance.

From the interface's perspective, tileset artifact keys are simple strings wrapped by the ArtifactKey class. If a particular implementation requires a complex key type, the implementation must take care to ensure that this key type is string-constructable. Luckily, rich string-based formats like JSON should be able to support almost any imaginable key schema.

Definition at line 28 of file tileset_artifact_key_provider.hpp.

Constructor & Destructor Documentation

◆ ~TilesetArtifactKeyProvider()

virtual porytiles2::TilesetArtifactKeyProvider::~TilesetArtifactKeyProvider ( )
virtualdefault

Member Function Documentation

◆ artifact_exists()

virtual bool porytiles2::TilesetArtifactKeyProvider::artifact_exists ( const ArtifactKey key) const
pure virtual

Checks whether an artifact exists in the backing store for the given key.

This method should perform the actual existence check against the backing store using the provided key. This may involve filesystem operations, database queries, or other I/O depending on the implementation.

Parameters
keyThe key identifying the artifact to check (generated by key_for)
Returns
True if the artifact exists in the backing store, false otherwise

Implemented in porytiles2::ProjectTilesetArtifactKeyProvider.

◆ discover_porymap_anim_frames()

virtual std::set< int > porytiles2::TilesetArtifactKeyProvider::discover_porymap_anim_frames ( const std::string &  tileset_name,
const std::string &  anim_name 
) const
pure virtual

Discovers the frame indices for a specific Porymap animation.

Searches the backing store to find all animation frame files (excluding the key frame and 00.png) for a specific Porymap animation. The returned indices should be consecutive starting from 1. Since frame 0 is required, callers don't need to discover it.

Parameters
tileset_nameThe name of the tileset containing the animation
anim_nameThe name of the animation to search for frames
Returns
Set of frame indices found in the backing store

Implemented in porytiles2::ProjectTilesetArtifactKeyProvider.

◆ discover_porymap_anims()

virtual std::set< std::string > porytiles2::TilesetArtifactKeyProvider::discover_porymap_anims ( const std::string &  tileset_name) const
pure virtual

Discovers the names of all Porymap animations available for a tileset.

Searches the backing store to find all Porymap animation assets for the specified tileset. Porymap animations do not require key frames, only sequential frame files.

Parameters
tileset_nameThe name of the tileset to search for animations
Returns
Set of animation names found in the backing store

Implemented in porytiles2::ProjectTilesetArtifactKeyProvider.

◆ discover_porytiles_anim_frames()

virtual std::set< int > porytiles2::TilesetArtifactKeyProvider::discover_porytiles_anim_frames ( const std::string &  tileset_name,
const std::string &  anim_name 
) const
pure virtual

Discovers the frame indices for a specific Porytiles animation.

Searches the backing store to find all animation frame files (excluding the key frame and 00.png) for a specific Porytiles animation. The returned indices should be consecutive starting from 1. Since frame 0 is required, callers don't need to discover it.

Parameters
tileset_nameThe name of the tileset containing the animation
anim_nameThe name of the animation to search for frames
Returns
Set of frame indices found in the backing store (typically starting from 1)

Implemented in porytiles2::ProjectTilesetArtifactKeyProvider.

◆ discover_porytiles_anims()

virtual std::set< std::string > porytiles2::TilesetArtifactKeyProvider::discover_porytiles_anims ( const std::string &  tileset_name) const
pure virtual

Discovers the names of all Porytiles animations available for a tileset.

Searches the backing store to find all Porytiles animation directories or assets for the specified tileset. Porytiles animations require both a key frame and at least one animation frame (00.png).

Parameters
tileset_nameThe name of the tileset to search for animations
Returns
Set of animation names found in the backing store

Implemented in porytiles2::ProjectTilesetArtifactKeyProvider.

◆ get_all_artifact_keys()

virtual std::vector< ArtifactKey > porytiles2::TilesetArtifactKeyProvider::get_all_artifact_keys ( const std::string &  tileset_name) const
inlinevirtual

Gets the keys for all tileset artifacts (both Porytiles and Porymap) present in the given Tileset.

This method combines the results from both get_porytiles_artifact_keys() and get_porymap_artifact_keys() to provide a comprehensive list of all artifact keys associated with the tileset. This method will only return keys that actually exist in the backing store.

Parameters
tileset_nameThe name of the Tileset for which to get all artifact keys
Returns
A vector containing all Porytiles and Porymap artifact keys for the given Tileset

Definition at line 261 of file tileset_artifact_key_provider.hpp.

◆ get_porymap_artifact_keys()

virtual std::vector< ArtifactKey > porytiles2::TilesetArtifactKeyProvider::get_porymap_artifact_keys ( const std::string &  tileset_name) const
inlinevirtual

Gets the keys for all Porymap artifacts present in the given Tileset.

Each Porymap artifact has a unique key by which the ArtifactChecksumProvider and the TilesetRepo can identify it. The format of these keys and the method for producing them are implementation-defined. This method will only return keys that actually exist in the backing store.

Returns
A vector of Porymap artifact keys for the given Tileset

Definition at line 202 of file tileset_artifact_key_provider.hpp.

◆ get_porytiles_artifact_keys()

virtual std::vector< ArtifactKey > porytiles2::TilesetArtifactKeyProvider::get_porytiles_artifact_keys ( const std::string &  tileset_name) const
inlinevirtual

Gets the keys for all Porytiles artifacts present in the given Tileset.

Each Porytiles artifact has a unique key by which the ArtifactChecksumProvider and the TilesetRepo can identify it. The format of these keys and the method for producing them are implementation-defined. This method will only return keys that actually exist in the backing store.

Returns
A vector of Porytiles artifact keys for the given Tileset

Definition at line 131 of file tileset_artifact_key_provider.hpp.

◆ key_for()

virtual ArtifactKey porytiles2::TilesetArtifactKeyProvider::key_for ( const std::string &  tileset_name,
const TilesetArtifact artifact 
) const
pure virtual

Constructs a key for a given tileset artifact.

This method should focus primarily on building keys from the provided parameters, not on searching the filesystem or backing store. The key generation should be fast and deterministic based on the tileset name and artifact specification.

Parameters
tileset_nameThe name of the tileset for the tileset artifact
artifactThe artifact details specifying type, name, and index as applicable
Returns
The key for the given tileset artifact

Implemented in porytiles2::ProjectTilesetArtifactKeyProvider.

◆ tileset_exists()

virtual bool porytiles2::TilesetArtifactKeyProvider::tileset_exists ( const std::string &  tileset_name) const
pure virtual

Checks whether a tileset exists in the backing store for the given tileset name.

Parameters
tileset_nameThe name of the tileset to check
Returns
True if the tileset exists in the backing store, false otherwise

Implemented in porytiles2::ProjectTilesetArtifactKeyProvider.


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