sandbox
Loading...
Searching...
No Matches
type_cache.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_SCRIPTING_TYPE_CACHE_HPP_
3#define LIBSBX_SCRIPTING_TYPE_CACHE_HPP_
4
5#include <unordered_map>
6#include <string>
7
8#include <libsbx/containers/stable_vector.hpp>
9
10#include <libsbx/scripting/managed/core.hpp>
11#include <libsbx/scripting/managed/type.hpp>
12
13namespace sbx::scripting::managed::detail {
14
16
17public:
18
19 static auto get() -> type_cache&;
20
21 auto cache_type(type&& InType) -> type*;
22
23 auto get_type_by_name(std::string_view name) const -> type*;
24
25 auto get_type_by_id(type_id id) const -> type*;
26
27 auto clear() -> void;
28
29private:
30
32 std::unordered_map<std::string, type*> _name_cache;
33 std::unordered_map<type_id, type*> _id_cache;
34
35}; // class type_cache
36
37} // namespace sbx::scripting::managed::detail
38
39#endif // LIBSBX_SCRIPTING_TYPE_CACHE_HPP_
Definition: stable_vector.hpp:21
Definition: type_cache.hpp:15
Definition: type.hpp:11