aboutsummaryrefslogtreecommitdiff
path: root/src/DI/object_type.hpp
blob: 6b27682bd4613fcf2aaf130e8252c55a5618eb8b (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
#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 ObjectTypeHasher
{
public:
	std::size_t operator()(const BaseObjectType &object_type) const noexcept;
};