Files
aee-arcade/source/core/resources/resource_cache.hpp
T

41 lines
1.4 KiB
C++

#pragma once
#include <memory>
#include <string>
#include <vector>
#include "core/resources/resource_types.hpp"
namespace Resource {
// Cache mínim per a la fase 2: només surfaces i animacions, càrrega
// explícita per nom + path. Per ara la cerca és lineal sobre vector.
// Meyers singleton: la destrucció estàtica només toca smart pointers, no
// depén d'SDL ni de Screen, així que és segura sense ordenació explícita.
class Cache {
public:
static auto get() -> Cache&;
Cache(const Cache&) = delete;
Cache(Cache&&) = delete;
auto operator=(const Cache&) -> Cache& = delete;
auto operator=(Cache&&) -> Cache& = delete;
// Carrega una surface des de fitxer i la registra amb el nom donat.
void loadSurface(const std::string& name, const std::string& file_path);
// Llig el YAML d'animació en cru i el registra amb el nom donat.
void loadAnimation(const std::string& name, const std::string& file_path);
auto getSurface(const std::string& name) -> std::shared_ptr<Surface>;
auto getAnimationData(const std::string& name) -> const AnimationResource&;
private:
Cache() = default;
~Cache() = default;
std::vector<SurfaceResource> surfaces_;
std::vector<AnimationResource> animations_;
};
} // namespace Resource