simplifying templates

Posted by Lodle on Stack Overflow See other posts from Stack Overflow or by Lodle
Published on 2010-04-08T04:30:32Z Indexed on 2010/04/08 4:33 UTC
Read the original article Hit count: 643

Filed under:
|

I have a bunch of templates that are used for rpc and was wondering if there is a way to simplify them down as it repeats it self allot. I know varags for templates is coming in the next standard but can you do default values for templates?

Also is there a way to handle void functions as normal functions? Atm i have to separate them and treat them as two different things every where.

template <typename R>
R functionCall(IPC::IPCClass* c, const char* name)
{
 IPC::IPCParameterI* r = c->callFunction( name, false );
 return handleReturn<R>(r);
}

template <typename R, typename A>
R functionCall(IPC::IPCClass* cl, const char* name, A a)
{
 IPC::IPCParameterI* r = cl->callFunction( name, false, IPC::getParameter(a));
 return handleReturn<R>(r);
}

template <typename R, typename A, typename B>
R functionCall(IPC::IPCClass* cl, const char* name, A a, B b)
{
 IPC::IPCParameterI* r = cl->callFunction( name, false, IPC::getParameter(a), IPC::getParameter(b) );
 return handleReturn<R>(r);
}

template <typename R, typename A, typename B, typename C>
R functionCall(IPC::IPCClass* cl, const char* name, A a, B b, C c)
{
 IPC::IPCParameterI* r = cl->callFunction( name, false, IPC::getParameter(a), IPC::getParameter(b), IPC::getParameter(c) );
 return handleReturn<R>(r);
}

template <typename R, typename A, typename B, typename C, typename D>
R functionCall(IPC::IPCClass* cl, const char* name, A a, B b, C c, D d)
{
 IPC::IPCParameterI* r = cl->callFunction( name, false, IPC::getParameter(a), IPC::getParameter(b), IPC::getParameter(c), IPC::getParameter(d) );
 return handleReturn<R>(r);
}

template <typename R, typename A, typename B, typename C, typename D, typename E>
R functionCall(IPC::IPCClass* cl, const char* name, A a, B b, C c, D d, E e)
{
 IPC::IPCParameterI* r = cl->callFunction( name, false, IPC::getParameter(a), IPC::getParameter(b), IPC::getParameter(c), IPC::getParameter(d), IPC::getParameter(e) );
 return handleReturn<R>(r);
}

template <typename R, typename A, typename B, typename C, typename D, typename E, typename F>
R functionCall(IPC::IPCClass* cl, const char* name, A a, B b, C c, D d, E e, F f)
{
 IPC::IPCParameterI* r = cl->callFunction( name, false, IPC::getParameter(a), IPC::getParameter(b), IPC::getParameter(c), IPC::getParameter(d), IPC::getParameter(e), IPC::getParameter(f) );
 return handleReturn<R>(r);
}








inline void functionCallV(IPC::IPCClass* cl, const char* name)
{
 IPC::IPCParameterI* r = cl->callFunction( name, false );
 handleReturnV(r);
}

template <typename A>
void functionCallV(IPC::IPCClass* cl, const char* name, A a)
{
 IPC::IPCParameterI* r = cl->callFunction( name, false, IPC::getParameter(a));
 handleReturnV(r);
}

template <typename A, typename B>
void functionCallV(IPC::IPCClass* cl, const char* name, A a, B b)
{
 IPC::IPCParameterI* r = cl->callFunction( name, false, IPC::getParameter(a), IPC::getParameter(b) );
 handleReturnV(r);
}

template <typename A, typename B, typename C>
void functionCallV(IPC::IPCClass* cl, const char* name, A a, B b, C c)
{
 IPC::IPCParameterI* r = cl->callFunction( name, false, IPC::getParameter(a), IPC::getParameter(b), IPC::getParameter(c) );
 handleReturnV(r);
}

template <typename A, typename B, typename C, typename D>
void functionCallV(IPC::IPCClass* cl, const char* name, A a, B b, C c, D d)
{
 IPC::IPCParameterI* r = cl->callFunction( name, false, IPC::getParameter(a), IPC::getParameter(b), IPC::getParameter(c), IPC::getParameter(d) );
 handleReturnV(r);
}

template <typename A, typename B, typename C, typename D, typename E>
void functionCallV(IPC::IPCClass* cl, const char* name, A a, B b, C c, D d, E e)
{
 IPC::IPCParameterI* r = cl->callFunction( name, false, IPC::getParameter(a), IPC::getParameter(b), IPC::getParameter(c), IPC::getParameter(d), IPC::getParameter(e) );
 handleReturnV(r);
}

template <typename A, typename B, typename C, typename D, typename E, typename F>
void functionCallV(IPC::IPCClass* cl, const char* name, A a, B b, C c, D d, E e, F f)
{
 IPC::IPCParameterI* r = cl->callFunction( name, false, IPC::getParameter(a), IPC::getParameter(b), IPC::getParameter(c), IPC::getParameter(d), IPC::getParameter(e), IPC::getParameter(f) );
 handleReturnV(r);
}










inline void functionCallAsync(IPC::IPCClass* cl, const char* name)
{
 IPC::IPCParameterI* r = cl->callFunction( name, true );
 handleReturnV(r);
}

template <typename A>
void functionCallAsync(IPC::IPCClass* cl, const char* name, A a)
{
 IPC::IPCParameterI* r = cl->callFunction( name, true, IPC::getParameter(a));
 handleReturnV(r);
}

template <typename A, typename B>
void functionCallAsync(IPC::IPCClass* cl, const char* name, A a, B b)
{
 IPC::IPCParameterI* r = cl->callFunction( name, true, IPC::getParameter(a), IPC::getParameter(b) );
 handleReturnV(r);
}

template <typename A, typename B, typename C>
void functionCallAsync(IPC::IPCClass* cl, const char* name, A a, B b, C c)
{
 IPC::IPCParameterI* r = cl->callFunction( name, true, IPC::getParameter(a), IPC::getParameter(b), IPC::getParameter(c) );
 handleReturnV(r);
}

template <typename A, typename B, typename C, typename D>
void functionCallAsync(IPC::IPCClass* cl, const char* name, A a, B b, C c, D d)
{
 IPC::IPCParameterI* r = cl->callFunction( name, true, IPC::getParameter(a), IPC::getParameter(b), IPC::getParameter(c), IPC::getParameter(d) );
 handleReturnV(r);
}

template <typename A, typename B, typename C, typename D, typename E>
void functionCallAsync(IPC::IPCClass* cl, const char* name, A a, B b, C c, D d, E e)
{
 IPC::IPCParameterI* r = cl->callFunction( name, true, IPC::getParameter(a), IPC::getParameter(b), IPC::getParameter(c), IPC::getParameter(d), IPC::getParameter(e) );
 handleReturnV(r);
}

template <typename A, typename B, typename C, typename D, typename E, typename F>
void functionCallAsync(IPC::IPCClass* cl, const char* name, A a, B b, C c, D d, E e, F f)
{
 IPC::IPCParameterI* r = cl->callFunction( name, true, IPC::getParameter(a), IPC::getParameter(b), IPC::getParameter(c), IPC::getParameter(d), IPC::getParameter(e), IPC::getParameter(f) );
 handleReturnV(r);
}

© Stack Overflow or respective owner

Related posts about c++

Related posts about template