// Copyright 2010 Jochen Becher
//
// This file is part of MovieSchedule.
//
// MovieSchedule is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MovieSchedule is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MovieSchedule. If not, see .
#ifndef ASYNCCALL_H
#define ASYNCCALL_H
#include "asynccallclient.h"
#include "asynccallproxy.h"
namespace AsyncCallPrivate {
template
class AsyncCall0 : public CallProxyBase
{
public:
AsyncCall0(OBJECT *object, const METHOD &method)
: _object(object),
_method(method)
{
}
void CallClient()
{
AsyncCallClient *client = new AsyncCallClient(_object->thread());
client->Call(this);
}
virtual void Call()
{
(_object->*_method)();
}
private:
OBJECT *_object;
METHOD _method;
};
template
class AsyncCall1 : public CallProxyBase
{
public:
AsyncCall1(OBJECT *object, const METHOD &method, const ARG1 &arg1)
: _object(object),
_method(method),
_arg1(arg1)
{
}
void CallClient()
{
AsyncCallClient *client = new AsyncCallClient(_object->thread());
client->Call(this);
}
virtual void Call()
{
(_object->*_method)(_arg1);
}
private:
OBJECT *_object;
METHOD _method;
ARG1 _arg1;
};
template
class AsyncCall2 : public CallProxyBase
{
public:
AsyncCall2(OBJECT *object, const METHOD &method, const ARG1 &arg1, const ARG2 &arg2)
: _object(object),
_method(method),
_arg1(arg1),
_arg2(arg2)
{
}
void CallClient()
{
AsyncCallClient *client = new AsyncCallClient(_object->thread());
client->Call(this);
}
virtual void Call()
{
(_object->*_method)(_arg1, _arg2);
}
private:
OBJECT *_object;
METHOD _method;
ARG1 _arg1;
ARG2 _arg2;
};
template
class AsyncCall3 : public CallProxyBase
{
public:
AsyncCall3(OBJECT *object, const METHOD &method, const ARG1 &arg1, const ARG2 &arg2, const ARG3 &arg3)
: _object(object),
_method(method),
_arg1(arg1),
_arg2(arg2),
_arg3(arg3)
{
}
void CallClient()
{
AsyncCallClient *client = new AsyncCallClient(_object->thread());
client->Call(this);
}
virtual void Call()
{
(_object->*_method)(_arg1, _arg2, _arg3);
}
private:
OBJECT *_object;
METHOD _method;
ARG1 _arg1;
ARG2 _arg2;
ARG3 _arg3;
};
template
class AsyncCall4 : public CallProxyBase
{
public:
AsyncCall4(OBJECT *object, const METHOD &method, const ARG1 &arg1, const ARG2 &arg2, const ARG3 &arg3, const ARG4 &arg4)
: _object(object),
_method(method),
_arg1(arg1),
_arg2(arg2),
_arg3(arg3),
_arg4(arg4)
{
}
void CallClient()
{
AsyncCallClient *client = new AsyncCallClient(_object->thread());
client->Call(this);
}
virtual void Call()
{
(_object->*_method)(_arg1, _arg2, _arg3, _arg4);
}
private:
OBJECT *_object;
METHOD _method;
ARG1 _arg1;
ARG2 _arg2;
ARG3 _arg3;
ARG4 _arg4;
};
}
template
void CallAsync(OBJECT *object, const METHOD &method)
{
AsyncCallPrivate::AsyncCall0