blob: 84bb287b4d144ff982753c210ac4f02a2e8d3b7e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#pragma once
#include <string_view>
#include <typeinfo>
class BaseObjectType
{
public:
explicit BaseObjectType(const std::type_info &type_info) noexcept;
bool operator==(const BaseObjectType &object_type) const noexcept;
[[nodiscard]] std::size_t hash() const noexcept;
[[nodiscard]] std::string_view name() const noexcept;
private:
const std::type_info &_type_info;
};
template <class Object>
class ObjectType : public BaseObjectType
{
public:
ObjectType() noexcept : BaseObjectType(typeid(Object)) {}
};
class IObjectTypeHasher
{
public:
virtual std::size_t operator()(const BaseObjectType &object_type) const noexcept = 0;
};
class ObjectTypeHasher : public IObjectTypeHasher
{
public:
std::size_t operator()(const BaseObjectType &object_type) const noexcept override;
};
|