#pragma once #include #include #include namespace engine::runtime { class RuntimeCache { public: bool contains(const std::string & key) const; template void put(std::string key, T value) { cache_[std::move(key)] = std::move(value); } template T * find(const std::string & key) { const auto it = cache_.find(key); if (it == cache_.end()) { return nullptr; } return std::any_cast(&it->second); } template const T * find(const std::string & key) const { const auto it = cache_.find(key); if (it == cache_.end()) { return nullptr; } return std::any_cast(&it->second); } void erase(const std::string & key); void clear(); private: std::unordered_map cache_; }; } // namespace engine::runtime