Files
orni-attack/source/core/graphics/shape_loader.hpp
T

36 lines
953 B
C++

// shape_loader.hpp - Carregador estàtic de formes con caché
// © 2026 JailDesigner
#pragma once
#include <memory>
#include <string>
#include <unordered_map>
#include "core/graphics/shape.hpp"
namespace Graphics {
// Carregador estàtic de formes con caché
class ShapeLoader {
public:
// No instanciable (tot estàtic)
ShapeLoader() = delete;
// Carregar shape desde file (con caché)
// Retorna punter compartit (nullptr si error)
// Exemple: load("ship/arrow.shp") → busca a "data/shapes/ship/arrow.shp"
static auto load(const std::string& filename) -> std::shared_ptr<Shape>;
// Netejar caché (útil per debug/recàrrega)
static void clearCache();
// Estadístiques (debug)
static auto getCacheSize() -> size_t;
private:
static std::unordered_map<std::string, std::shared_ptr<Shape>> cache;
};
} // namespace Graphics