summaryrefslogtreecommitdiff
path: root/include/caller.h
blob: 328aed2c92aa6fb71157a9a53da98d4610d722dd (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*       +------------------------------------+
 *       | Inspire Internet Relay Chat Daemon |
 *       +------------------------------------+
 *
 *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
 * See: http://www.inspircd.org/wiki/index.php/Credits
 *
 * This program is free but copyrighted software; see
 *            the file COPYING for details.
 *
 * ---------------------------------------------------
 */

#ifndef __CALLER__H__
#define __CALLER__H__

template <typename ReturnType> class CoreExport HandlerBase0
{
 public:
	virtual ReturnType Call() = 0;
	virtual ~HandlerBase0() { }
};

template <typename ReturnType, typename Param1> class CoreExport HandlerBase1
{
 public:
	virtual ReturnType Call(Param1) = 0;
	virtual ~HandlerBase1() { }
};

template <typename ReturnType, typename Param1, typename Param2> class CoreExport HandlerBase2
{
 public:
	virtual ReturnType Call(Param1, Param2) = 0;
	virtual ~HandlerBase2() { }
};

template <typename ReturnType, typename Param1, typename Param2, typename Param3> class CoreExport HandlerBase3
{
 public:
	virtual ReturnType Call(Param1, Param2, Param3) = 0;
	virtual ~HandlerBase3() { }
};

template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4> class CoreExport HandlerBase4
{
 public:
	virtual ReturnType Call(Param1, Param2, Param3, Param4) = 0;
	virtual ~HandlerBase4() { }
};

template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5> class CoreExport HandlerBase5
{
 public:
	virtual ReturnType Call(Param1, Param2, Param3, Param4, Param5) = 0;
	virtual ~HandlerBase5() { }
};

template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5, typename Param6> class CoreExport HandlerBase6
{
 public:
	virtual ReturnType Call(Param1, Param2, Param3, Param4, Param5, Param6) = 0;
	virtual ~HandlerBase6() { }
};

template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5, typename Param6, typename Param7> class CoreExport HandlerBase7
{
 public:
	virtual ReturnType Call(Param1, Param2, Param3, Param4, Param5, Param6, Param7) = 0;
	virtual ~HandlerBase7() { }
};

template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5, typename Param6, typename Param7, typename Param8> class CoreExport HandlerBase8
{
 public:
	virtual ReturnType Call(Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8) = 0;
	virtual ~HandlerBase8() { }
};

template <typename HandlerType> class CoreExport caller
{
 public:
	HandlerType* target;

	caller(HandlerType* initial)
	: target(initial)
	{ }

	virtual ~caller() { }

	caller& operator=(HandlerType* newtarget)
	{
		target = newtarget;
		return *this;
	}
};

template <typename ReturnType> class CoreExport caller0 : public caller< HandlerBase0<ReturnType> >
{
 public:
	caller0(HandlerBase0<ReturnType>* initial)
	: caller< HandlerBase0<ReturnType> >::caller(initial)
	{ }

	virtual ReturnType operator() ()
	{
		return this->target->Call();
	}
};

template <typename ReturnType, typename Param1> class CoreExport caller1 : public caller< HandlerBase1<ReturnType, Param1> >
{
 public:
	caller1(HandlerBase1<ReturnType, Param1>* initial)
	: caller< HandlerBase1<ReturnType, Param1> >::caller(initial)
	{ }

	virtual ReturnType operator() (Param1 param1)
	{
		return this->target->Call(param1);
	}
};

template <typename ReturnType, typename Param1, typename Param2> class CoreExport caller2 : public caller< HandlerBase2<ReturnType, Param1, Param2> >
{
 public:
	caller2(HandlerBase2<ReturnType, Param1, Param2>* initial)
	: caller< HandlerBase2<ReturnType, Param1, Param2> >::caller(initial)
	{ }

	virtual ReturnType operator() (Param1 param1, Param2 param2)
	{
		return this->target->Call(param1, param2);
	}
};

template <typename ReturnType, typename Param1, typename Param2, typename Param3> class CoreExport caller3 : public caller< HandlerBase3<ReturnType, Param1, Param2, Param3> >
{
 public:
	caller3(HandlerBase3<ReturnType, Param1, Param2, Param3>* initial)
	: caller< HandlerBase3<ReturnType, Param1, Param2, Param3> >::caller(initial)
	{ }

	virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3)
	{
		return this->target->Call(param1, param2, param3);
	}
};

template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4> class CoreExport caller4 : public caller< HandlerBase4<ReturnType, Param1, Param2, Param3, Param4> >
{
 public:
	caller4(HandlerBase4<ReturnType, Param1, Param2, Param3, Param4>* initial)
	: caller< HandlerBase4<ReturnType, Param1, Param2, Param3, Param4> >::caller(initial)
	{ }

	virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4)
	{
		return this->target->Call(param1, param2, param3, param4);
	}
};

template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5> class CoreExport caller5 : public caller< HandlerBase5<ReturnType, Param1, Param2, Param3, Param4, Param5> >
{
 public:
	caller5(HandlerBase5<ReturnType, Param1, Param2, Param3, Param4, Param5>* initial)
	: caller< HandlerBase5<ReturnType, Param1, Param2, Param3, Param4, Param5> >::caller(initial)
	{ }

	virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4, Param5 param5)
	{
		return this->target->Call(param1, param2, param3, param4, param5);
	}
};

template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5, typename Param6> class CoreExport caller6 : public caller< HandlerBase6<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6> >
{
 public:
	caller6(HandlerBase6<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6>* initial)
	: caller< HandlerBase6<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6> >::caller(initial)
	{ }

	virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4, Param5 param5, Param6 param6)
	{
		return this->target->Call(param1, param2, param3, param4, param5, param6);
	}
};

template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5, typename Param6, typename Param7> class CoreExport caller7 : public caller< HandlerBase7<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6, Param7> >
{
 public:
	caller7(HandlerBase7<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6, Param7>* initial)
	: caller< HandlerBase7<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6, Param7> >::caller(initial)
	{ }

	virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4, Param5 param5, Param6 param6, Param7 param7)
	{
		return this->target->Call(param1, param2, param3, param4, param5, param6, param7);
	}
};

template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5, typename Param6, typename Param7, typename Param8> class CoreExport caller8 : public caller< HandlerBase8<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8> >
{
 public:
	caller8(HandlerBase8<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8>* initial)
	: caller< HandlerBase8<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8> >::caller(initial)
	{ }

	virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4, Param5 param5, Param6 param6, Param7 param7, Param8 param8)
	{
		return this->target->Call(param1, param2, param3, param4, param5, param6, param7, param8);
	}
};

#endif