Porytiles
Loading...
Searching...
No Matches
porytiles2::ProjectTilesetArtifactWriter Class Referencefinal

Provides a filesystem-based implementation for TilesetArtifactWriter. More...

#include <project_tileset_artifact_writer.hpp>

Inheritance diagram for porytiles2::ProjectTilesetArtifactWriter:
[legend]
Collaboration diagram for porytiles2::ProjectTilesetArtifactWriter:
[legend]

Public Member Functions

 ProjectTilesetArtifactWriter (gsl::not_null< InfraConfig * > config, std::filesystem::path project_root, gsl::not_null< PngRgbaImageSaver * > png_rgba_saver, gsl::not_null< PngIndexedImageSaver * > png_indexed_saver, gsl::not_null< FilePalSaver * > pal_saver)
 
Result< void > begin_transaction () override
 Begins a new transaction for atomic write operations.
 
ChainableResult< void > commit () override
 Commits all buffered write operations in the current transaction.
 
Result< void > rollback () override
 Rolls back all buffered write operations in the current transaction.
 
ChainableResult< void > write (const ArtifactKey &dest_key, const TilesetArtifact &artifact, const Tileset &src) override
 Writes an artifact from a Tileset to the backing store.
 
- Public Member Functions inherited from porytiles2::TilesetArtifactWriter
virtual ~TilesetArtifactWriter ()=default
 

Detailed Description

Provides a filesystem-based implementation for TilesetArtifactWriter.

This class implements the TilesetArtifactWriter interface to provide writing functionality for tileset artifacts. It operates within the context of a Pokémon Gen III decompilation project on the local filesystem.

Definition at line 21 of file project_tileset_artifact_writer.hpp.

Constructor & Destructor Documentation

◆ ProjectTilesetArtifactWriter()

porytiles2::ProjectTilesetArtifactWriter::ProjectTilesetArtifactWriter ( gsl::not_null< InfraConfig * >  config,
std::filesystem::path  project_root,
gsl::not_null< PngRgbaImageSaver * >  png_rgba_saver,
gsl::not_null< PngIndexedImageSaver * >  png_indexed_saver,
gsl::not_null< FilePalSaver * >  pal_saver 
)
inline

Definition at line 23 of file project_tileset_artifact_writer.hpp.

Member Function Documentation

◆ begin_transaction()

Result< void > porytiles2::ProjectTilesetArtifactWriter::begin_transaction ( )
overridevirtual

Begins a new transaction for atomic write operations.

Starts a transaction that buffers all subsequent write operations until a commit() call. If a transaction is already active, this should return an error.

Returns
Empty Result on success, otherwise an error description

Implements porytiles2::TilesetArtifactWriter.

Definition at line 117 of file project_tileset_artifact_writer.cpp.

◆ commit()

ChainableResult< void > porytiles2::ProjectTilesetArtifactWriter::commit ( )
overridevirtual

Commits all buffered write operations in the current transaction.

Finalizes and persists all write operations that were buffered since begin_transaction() was called. After commit, the transaction is closed and a new one must be started for further transactional writes. If no transaction is active, this should return an error.

Returns
Empty ChainableResult on success, otherwise an error chain

Implements porytiles2::TilesetArtifactWriter.

Definition at line 127 of file project_tileset_artifact_writer.cpp.

◆ rollback()

Result< void > porytiles2::ProjectTilesetArtifactWriter::rollback ( )
overridevirtual

Rolls back all buffered write operations in the current transaction.

Discards all write operations that were buffered since begin_transaction() was called. After rollback, the transaction is closed and a new one must be started for further transactional writes. If no transaction is active, this should return an error.

Returns
Empty Result on success, otherwise an error description

Implements porytiles2::TilesetArtifactWriter.

Definition at line 222 of file project_tileset_artifact_writer.cpp.

◆ write()

ChainableResult< void > porytiles2::ProjectTilesetArtifactWriter::write ( const ArtifactKey dest_key,
const TilesetArtifact artifact,
const Tileset src 
)
overridevirtual

Writes an artifact from a Tileset to the backing store.

This method extracts the appropriate data from the source Tileset object and writes the specified artifact to the backing store location identified by the dest_key. The TilesetArtifact parameter specifies the type and metadata needed to determine what data to extract and how to format it.

The implementation should handle formatting the specific artifact type (PNG images, binary data, etc.) and extracting the correct data from the Tileset components (Porymap or Porytiles components, palettes, animations, etc.).

If a transaction is active (via begin_transaction()), the write should buffer until a commit() call. If no transaction is active, the behavior is implementation-defined (immediate write or error).

Parameters
dest_keyThe ArtifactKey identifying the destination location in the backing store
artifactThe TilesetArtifact specification including type and optional metadata
srcThe Tileset object containing the data to be written
Returns
Empty ChainableResult on success, otherwise an error trace

Implements porytiles2::TilesetArtifactWriter.

Definition at line 242 of file project_tileset_artifact_writer.cpp.


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