Files
orni-attack/source/core/graphics/shape_loader.hpp
T
JailDesigner 682c27c07c refactor: eliminar ShapeLoader::resolvePath i BASE_PATH (codi mort)
Cap caller invocava resolvePath fora de la seua pròpia definició.
A més, BASE_PATH apuntava a "data/shapes/" mentre que load() ja
construeix el path amb el prefix "shapes/" directament — el helper
mai s'hauria activat encara que es cridara.

Hallazgo #18 de CODE_REVIEW.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 16:37:07 +02:00

36 lines
941 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.shp") → busca a "data/shapes/ship.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