aboutsummaryrefslogtreecommitdiff
path: root/src/DI/object_type.hpp
blob: f690a6422dce664ddde72254eee5f049d8a7c795 (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
#pragma once

#include <typeinfo>

class BaseObjectType
{
public:
	explicit BaseObjectType(const std::type_info &type_info);

	bool operator==(const BaseObjectType &object_type) const;

	[[nodiscard]] std::size_t hash() const;

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;
};