-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallablewrapper.h
More file actions
49 lines (42 loc) · 1.53 KB
/
callablewrapper.h
File metadata and controls
49 lines (42 loc) · 1.53 KB
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
42
43
44
45
46
47
48
49
#ifndef CALLABLEWRAPPER_CALLABLEWRAPPER_H
#define CALLABLEWRAPPER_CALLABLEWRAPPER_H
namespace CallableWrapper {
template<typename ReturnType, typename... Args>
class CallableWrapper
{
public:
CallableWrapper() = default;
virtual ~CallableWrapper(){};
virtual ReturnType operator()(Args... args) = 0;
};
template<typename Callable, typename ReturnType, typename... Args>
class CallableObjWrapper : public CallableWrapper<ReturnType, Args...>
{
public:
CallableObjWrapper(Callable callable);
virtual ~CallableObjWrapper() override = default;
virtual ReturnType operator()(Args... args) override;
private:
Callable callable_;
};
template<typename Callable, typename ReturnType, typename... Args>
class CallablePtrWrapper : public CallableWrapper<ReturnType, Args...>
{
public:
CallablePtrWrapper(Callable callable);
virtual ~CallablePtrWrapper() override = default;
virtual ReturnType operator()(Args... args) override;
private:
Callable callable_;
};
template<typename ReturnType, typename... Args>
class CallableWrapperFactory{
public:
template<typename Callable>
static CallableWrapper<ReturnType, Args...>* create(Callable callable);
private:
CallableWrapperFactory();
};
} // namespace CallableWrapper
#include "callablewrapper.cpp"
#endif // CALLABLEWRAPPER_CALLABLEWRAPPER_H