blob: 3910c032075094313a322faeb475e982d290ed59 (
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() : BaseObjectType(typeid(Object)) {}
};
class IObjectTypeHasher
{
public:
virtual std::size_t operator()(const BaseObjectType &object_type) const = 0;
};
class ObjectTypeHasher : public IObjectTypeHasher
{
public:
std::size_t operator()(const BaseObjectType &object_type) const override;
};
|