aboutsummaryrefslogtreecommitdiff
path: root/src/DI/interfaces/copyable_functor.hpp
blob: 46b75882cc2f540ea0e811d25aa0d59a4af5b316 (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
39
40
41
#pragma once

#include <typeinfo>

/**
 * A copyable function object.
 */
template <class Function>
class ICopyableFunctor;

template <class Return, class... Args>
class ICopyableFunctor<Return(Args...)>
{
public:
	ICopyableFunctor() = default;

	ICopyableFunctor(const ICopyableFunctor &) = delete;

	ICopyableFunctor(ICopyableFunctor &&) = delete;

	virtual ~ICopyableFunctor() = default;

	[[nodiscard]] virtual auto clone() const -> ICopyableFunctor * = 0;

	virtual void clone(ICopyableFunctor *) const = 0;

	virtual void destroy() noexcept = 0;

	virtual void destroy_deallocate() noexcept = 0;

	virtual auto operator()(Args &&...) -> Return = 0;

	auto operator=(const ICopyableFunctor &) = delete;

	auto operator=(ICopyableFunctor &&) = delete;

	[[nodiscard]] virtual auto target(const std::type_info &) const noexcept -> const
		void * = 0;

	[[nodiscard]] virtual auto target_type() const noexcept -> const std::type_info & = 0;
};