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

Abstract interface for writing tileset artifacts from a Tileset object to a backing store. More...

#include <tileset_artifact_writer.hpp>

Inheritance diagram for porytiles2::TilesetArtifactWriter:
[legend]

Public Member Functions

virtual ~TilesetArtifactWriter ()=default
 
virtual Result< void > begin_transaction ()=0
 Begins a new transaction for atomic write operations.
 
virtual ChainableResult< void > commit ()=0
 Commits all buffered write operations in the current transaction.
 
virtual Result< void > rollback ()=0
 Rolls back all buffered write operations in the current transaction.
 
virtual ChainableResult< void > write (const ArtifactKey &dest_key, const TilesetArtifact &artifact, const Tileset &src)=0
 Writes an artifact from a Tileset to the backing store.
 

Detailed Description

Abstract interface for writing tileset artifacts from a Tileset object to a backing store.

The TilesetArtifactWriter provides the ability to extract data from a Tileset object and write various types of tileset artifacts (PNG files, binary data, etc.) to their storage locations. This interface abstracts the writing logic from the specific storage format and location.

Implementations handle the details of formatting different artifact types and extracting the appropriate data from the source Tileset components. The interface uses type-erased keys (std::any) to support different backing store implementations (filesystem paths, database keys, URLs, etc.).

Definition at line 25 of file tileset_artifact_writer.hpp.

Constructor & Destructor Documentation

◆ ~TilesetArtifactWriter()

virtual porytiles2::TilesetArtifactWriter::~TilesetArtifactWriter ( )
virtualdefault

Member Function Documentation

◆ begin_transaction()

virtual Result< void > porytiles2::TilesetArtifactWriter::begin_transaction ( )
pure virtual

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

Implemented in porytiles2::ProjectTilesetArtifactWriter.

◆ commit()

virtual ChainableResult< void > porytiles2::TilesetArtifactWriter::commit ( )
pure virtual

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

Implemented in porytiles2::ProjectTilesetArtifactWriter.

◆ rollback()

virtual Result< void > porytiles2::TilesetArtifactWriter::rollback ( )
pure virtual

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

Implemented in porytiles2::ProjectTilesetArtifactWriter.

◆ write()

virtual ChainableResult< void > porytiles2::TilesetArtifactWriter::write ( const ArtifactKey dest_key,
const TilesetArtifact artifact,
const Tileset src 
)
pure virtual

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

Implemented in porytiles2::ProjectTilesetArtifactWriter.


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