| 33 | } |
| 34 | |
| 35 | std::shared_ptr<Poseidon::Model::Model> ModelCache::load(const std::string& filePath) |
| 36 | { |
| 37 | _stats.totalLoads++; |
| 38 | |
| 39 | std::string key = normalizePath(filePath); |
| 40 | |
| 41 | auto it = _cache.find(key); |
| 42 | if (it != _cache.end()) |
| 43 | { |
| 44 | _stats.cacheHits++; |
| 45 | return it->second; |
| 46 | } |
| 47 | |
| 48 | _stats.cacheMisses++; |
| 49 | |
| 50 | auto model = loadFromFile(filePath); |
| 51 | if (!model) |
| 52 | { |
| 53 | _stats.loadFailures++; |
| 54 | return nullptr; |
| 55 | } |
| 56 | |
| 57 | _cache[key] = model; |
| 58 | _stats.cachedModels = _cache.size(); |
| 59 | return model; |
| 60 | } |
| 61 | |
| 62 | std::shared_ptr<Poseidon::Model::Model> ModelCache::loadFromFile(const std::string& filePath) |
| 63 | { |
no test coverage detected