1 // Copyright 2010 Jochen Becher
3 // This file is part of MovieSchedule.
5 // MovieSchedule is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // MovieSchedule is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with MovieSchedule. If not, see <http://www.gnu.org/licenses/>.
21 #include "asynccallclient.h"
22 #include "asynccallproxy.h"
24 namespace AsyncCallPrivate {
26 template<class OBJECT, typename METHOD>
27 class AsyncCall0 : public CallProxyBase
30 AsyncCall0(OBJECT *object, const METHOD &method)
38 AsyncCallClient *client = new AsyncCallClient(_object->thread());
44 (_object->*_method)();
52 template<class OBJECT, typename METHOD, typename ARG1>
53 class AsyncCall1 : public CallProxyBase
56 AsyncCall1(OBJECT *object, const METHOD &method, const ARG1 &arg1)
65 AsyncCallClient *client = new AsyncCallClient(_object->thread());
71 (_object->*_method)(_arg1);
80 template<class OBJECT, typename METHOD, typename ARG1, typename ARG2>
81 class AsyncCall2 : public CallProxyBase
84 AsyncCall2(OBJECT *object, const METHOD &method, const ARG1 &arg1, const ARG2 &arg2)
94 AsyncCallClient *client = new AsyncCallClient(_object->thread());
100 (_object->*_method)(_arg1, _arg2);
110 template<class OBJECT, typename METHOD, typename ARG1, typename ARG2, typename ARG3>
111 class AsyncCall3 : public CallProxyBase
114 AsyncCall3(OBJECT *object, const METHOD &method, const ARG1 &arg1, const ARG2 &arg2, const ARG3 &arg3)
125 AsyncCallClient *client = new AsyncCallClient(_object->thread());
131 (_object->*_method)(_arg1, _arg2, _arg3);
142 template<class OBJECT, typename METHOD, typename ARG1, typename ARG2, typename ARG3, typename ARG4>
143 class AsyncCall4 : public CallProxyBase
146 AsyncCall4(OBJECT *object, const METHOD &method, const ARG1 &arg1, const ARG2 &arg2, const ARG3 &arg3, const ARG4 &arg4)
158 AsyncCallClient *client = new AsyncCallClient(_object->thread());
164 (_object->*_method)(_arg1, _arg2, _arg3, _arg4);
177 template<class OBJECT, typename METHOD>
178 void CallAsync(OBJECT *object, const METHOD &method)
180 AsyncCallPrivate::AsyncCall0<OBJECT, METHOD> *async_call = new AsyncCallPrivate::AsyncCall0<OBJECT, METHOD>(object, method);
181 async_call->CallClient();
184 template<class OBJECT, typename METHOD, typename ARG1>
185 void CallAsync(OBJECT *object, const METHOD &method, const ARG1 &arg1)
187 AsyncCallPrivate::AsyncCall1<OBJECT, METHOD, ARG1> *async_call = new AsyncCallPrivate::AsyncCall1<OBJECT, METHOD, ARG1>(object, method, arg1);
188 async_call->CallClient();
191 template<class OBJECT, typename METHOD, typename ARG1, typename ARG2>
192 void CallAsync(OBJECT *object, const METHOD &method, const ARG1 &arg1, const ARG2 &arg2)
194 AsyncCallPrivate::AsyncCall2<OBJECT, METHOD, ARG1, ARG2> *async_call = new AsyncCallPrivate::AsyncCall2<OBJECT, METHOD, ARG1, ARG2>(object, method, arg1, arg2);
195 async_call->CallClient();
198 template<class OBJECT, typename METHOD, typename ARG1, typename ARG2, typename ARG3>
199 void CallAsync(OBJECT *object, const METHOD &method, const ARG1 &arg1, const ARG2 &arg2, const ARG3 &arg3)
201 AsyncCallPrivate::AsyncCall3<OBJECT, METHOD, ARG1, ARG2, ARG3> *async_call = new AsyncCallPrivate::AsyncCall3<OBJECT, METHOD, ARG1, ARG2, ARG3>(object, method, arg1, arg2, arg3);
202 async_call->CallClient();
205 template<class OBJECT, typename METHOD, typename ARG1, typename ARG2, typename ARG3, typename ARG4>
206 void CallAsync(OBJECT *object, const METHOD &method, const ARG1 &arg1, const ARG2 &arg2, const ARG3 &arg3, const ARG4 &arg4)
208 AsyncCallPrivate::AsyncCall4<OBJECT, METHOD, ARG1, ARG2, ARG3, ARG4> *async_call = new AsyncCallPrivate::AsyncCall4<OBJECT, METHOD, ARG1, ARG2, ARG3, ARG4>(object, method, arg1, arg2, arg3, arg4);
209 async_call->CallClient();
212 #endif // ASYNCCALL_H