Class ResourceDatabase

Inheritance Relationships

Derived Types

Class Documentation

class ResourceDatabase

Abstract interface for resource metadata storage and file access.

The ResourceDatabase provides filesystem abstraction for the resource system. It discovers resources by scanning directories, extracts and caches metadata, and creates ResourceSource abstractions for reading file data.

Responsibilities:

  • Discovery: Scan filesystem directories to find resource files

  • Metadata: Extract and cache SourceMetadata for each resource

  • Persistence: Save/load metadata to avoid re-scanning on startup

  • Source Creation: Provide ResourceSource objects for reading file bytes

See also

FolderResourceDatabase for the concrete filesystem implementation

See also

ResourceSource for the file reading abstraction

See also

SourceMetadata for what metadata is stored

Subclassed by portal::FolderResourceDatabase, portal::ResourceDatabaseFacade

Public Functions

virtual ~ResourceDatabase() = default
virtual std::expected<SourceMetadata, DatabaseError> find(StringId resource_id) = 0

Find metadata for a resource by its ID.

Parameters:

resource_id – StringId of the resource to find

Returns:

SourceMetadata if found, or DatabaseError explaining why lookup failed

virtual DatabaseError add(StringId resource_id, SourceMetadata meta) = 0

Add a new resource to the database.

Parameters:
  • resource_id – StringId for the new resource

  • meta – Complete metadata for the resource

Returns:

Success or error flags indicating why the operation failed

virtual DatabaseError remove(StringId resource_id) = 0

Remove a resource from the database.

Parameters:

resource_id – StringId of the resource to remove

Returns:

Success if removed, NotFound if resource didn’t exist

virtual std::unique_ptr<resources::ResourceSource> create_source(StringId resource_id, SourceMetadata meta) = 0

Create a ResourceSource for reading resource data.

Parameters:
  • resource_id – StringId of the resource

  • meta – Metadata describing the resource

Returns:

Unique pointer to a ResourceSource for reading bytes

virtual StringId get_name() const = 0