Porytiles
Loading...
Searching...
No Matches
project_tileset_metadata_provider.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <filesystem>
4#include <map>
5#include <set>
6#include <string>
7#include <utility>
8
9#include "gsl/pointers"
10
17
18namespace porytiles {
19
31 public:
33 std::filesystem::path project_root,
34 gsl::not_null<const TextFormatter *> format,
35 gsl::not_null<const UserDiagnostics *> diag)
36 : project_root_{std::move(project_root)}, format_{format}, diag_{diag}
37 {
38 }
39
40 [[nodiscard]] bool exists(const std::string &tileset_name) const override;
41
42 [[nodiscard]] ChainableResult<bool> is_secondary(const std::string &tileset_name) const override;
43
44 [[nodiscard]] ChainableResult<bool> has_animations(const std::string &tileset_name) const override;
45
46 [[nodiscard]] ChainableResult<std::set<std::string>> tilesets() const override;
47
59 [[nodiscard]] ChainableResult<ProjectTilesetMetadata> metadata_for(const std::string &tileset_name) const;
60
73 artifact_paths_for(const std::string &tileset_name) const;
74
83 void invalidate_metadata_cache() const;
84
85 private:
86 std::filesystem::path project_root_;
87 const TextFormatter *format_;
88 const UserDiagnostics *diag_;
89
90 // Lazy-loaded cache for parsed tileset metadata (mutable for const methods)
91 mutable bool metadata_parsed_{false};
92 mutable std::map<std::string, ProjectTilesetMetadata> tileset_metadata_;
93
94 // Lazy-loaded cache for resolved tileset artifact paths (mutable for const methods)
95 mutable bool artifact_paths_parsed_{false};
96 mutable std::map<std::string, ProjectTilesetArtifactPaths> tileset_artifact_paths_;
97};
98
99} // namespace porytiles
A result type that maintains a chainable sequence of errors for debugging and error reporting.
Provides a pokeemerald project filesystem-based implementation for TilesetMetadataProvider.
void invalidate_metadata_cache() const
Invalidates the lazy-loaded metadata and artifact paths caches, forcing a re-parse on next access.
ChainableResult< ProjectTilesetArtifactPaths > artifact_paths_for(const std::string &tileset_name) const
Resolves artifact paths for a tileset by parsing INCBIN declarations.
ChainableResult< std::set< std::string > > tilesets() const override
Returns all tileset names known to this provider.
bool exists(const std::string &tileset_name) const override
Checks whether a tileset exists in the backing store for the given tileset name.
ChainableResult< ProjectTilesetMetadata > metadata_for(const std::string &tileset_name) const
Retrieves metadata for a specific tileset from the struct cache.
ProjectTilesetMetadataProvider(std::filesystem::path project_root, gsl::not_null< const TextFormatter * > format, gsl::not_null< const UserDiagnostics * > diag)
ChainableResult< bool > has_animations(const std::string &tileset_name) const override
Determines whether a tileset has animation support.
ChainableResult< bool > is_secondary(const std::string &tileset_name) const override
Determines whether a tileset is a secondary tileset.
Abstract base class for applying text styling with context-aware formatting.
Abstract interface for querying tileset metadata by name.
Abstract class for structured error reporting and diagnostic output.