#ifndef _CPP_EVENT_
#define _CPP_EVENT_
#include<assert.h>
#include <list>

using namespace std;

struct __declspec(dllexport) null_type{};

template
<
typename RT,
typename T0 = null_type,typename T1 = null_type,typename T2 = null_type,typename T3 = null_type,
typename T4 = null_type,typename T5 = null_type,typename T6 = null_type,typename T7 = null_type,
typename T8 = null_type,typename T9 = null_type,typename T10 = null_type,typename T11 = null_type
>
//函数包装类基类
class __declspec(dllexport) MethodWrappers
{
public:
virtual bool Equal(MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>*event)=0;

virtual~MethodWrappers(){}

virtual RT Invoke()=0;
virtual RT Invoke(T0)=0;
virtual RT Invoke(T0,T1)=0;
virtual RT Invoke(T0,T1,T2)=0;
virtual RT Invoke(T0,T1,T2,T3)=0;
virtual RT Invoke(T0,T1,T2,T3,T4)=0;
virtual RT Invoke(T0,T1,T2,T3,T4,T5)=0;
virtual RT Invoke(T0,T1,T2,T3,T4,T5,T6)=0;
virtual RT Invoke(T0,T1,T2,T3,T4,T5,T6,T7)=0;
virtual RT Invoke(T0,T1,T2,T3,T4,T5,T6,T7,T8)=0;
virtual RT Invoke(T0,T1,T2,T3,T4,T5,T6,T7,T9,T9)=0;
virtual RT Invoke(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10)=0;
virtual RT Invoke(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11)=0;
};

template
<
typename RT,
typename T0 = null_type,typename T1 = null_type,typename T2 = null_type,typename T3 = null_type,
typename T4 = null_type,typename T5 = null_type,typename T6 = null_type,typename T7 = null_type,
typename T8 = null_type,typename T9 = null_type,typename T10 = null_type,typename T11 = null_type
>
//全局函数包装类 GlobaMethodWrappers or StaticMethodWrappers 静态方法 。
class __declspec(dllexport) GlobalAndStaticMethodWrappers:public MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>
{
private:
typedef RT (*FUN0) ();
typedef RT (*FUN1) (T0);
typedef RT (*FUN2) (T0,T1);
typedef RT (*FUN3) (T0,T1,T2);
typedef RT (*FUN4) (T0,T1,T2,T3);
typedef RT (*FUN5) (T0,T1,T2,T3,T4);
typedef RT (*FUN6) (T0,T1,T2,T3,T4,T5);
typedef RT (*FUN7) (T0,T1,T2,T3,T4,T5,T6);
typedef RT (*FUN8) (T0,T1,T2,T3,T4,T5,T6,T7);
typedef RT (*FUN9) (T0,T1,T2,T3,T4,T5,T6,T7,T8);
typedef RT (*FUN10)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9);
typedef RT (*FUN11)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10);
typedef RT (*FUN12)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11);
private:
FUN0 m_Fun0;
FUN1 m_Fun1;
FUN2 m_Fun2;
FUN3 m_Fun3;
FUN4 m_Fun4;
FUN5 m_Fun5;
FUN6 m_Fun6;
FUN7 m_Fun7;
FUN8 m_Fun8;
FUN9 m_Fun9;
FUN10 m_Fun10;
FUN11 m_Fun11;
FUN12 m_Fun12;

void Default()
{
m_Fun0=0;
m_Fun1=0;
m_Fun2=0;
m_Fun3=0;
m_Fun4=0;
m_Fun5=0;
m_Fun6=0;
m_Fun7=0;
m_Fun8=0;
m_Fun9=0;
m_Fun10=0;
m_Fun11=0;
m_Fun12=0;
}
public:
virtual bool Equal(MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>*event)
{
GlobalAndStaticMethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>* ne= dynamic_cast<GlobalAndStaticMethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>*>(event);
if (ne==NULL)
return false;

if( m_Fun0 == ne->m_Fun0 &&
m_Fun1 == ne->m_Fun1 &&
m_Fun2 == ne->m_Fun2 &&
m_Fun3 == ne->m_Fun3 &&
m_Fun4 == ne->m_Fun4 &&
m_Fun5 == ne->m_Fun5 &&
m_Fun6 == ne->m_Fun6 &&
m_Fun7 == ne->m_Fun7 &&
m_Fun8 == ne->m_Fun8 &&
m_Fun9 == ne->m_Fun9 &&
m_Fun10 == ne->m_Fun10 &&
m_Fun11 == ne->m_Fun11 &&
m_Fun12 == ne->m_Fun12)
return true;
return false;
}

GlobalAndStaticMethodWrappers(FUN0 Fun)
{
assert(Fun!=0);
Default();
m_Fun0=Fun;
}

GlobalAndStaticMethodWrappers(FUN1 Fun)
{
assert(Fun!=0);
Default();
m_Fun1=Fun;
}

GlobalAndStaticMethodWrappers(FUN2 Fun)
{
assert(Fun!=0);
Default();
m_Fun2=Fun;
}

GlobalAndStaticMethodWrappers(FUN3 Fun)
{
assert(Fun!=0);
Default();
m_Fun3=Fun;
}

GlobalAndStaticMethodWrappers(FUN4 Fun)
{
assert(Fun!=0);
Default();
m_Fun4=Fun;
}

GlobalAndStaticMethodWrappers(FUN5 Fun)
{
assert(Fun!=0);
Default();
m_Fun5=Fun;
}

GlobalAndStaticMethodWrappers(FUN6 Fun)
{
assert(Fun!=0);
Default();
m_Fun6=Fun;
}

GlobalAndStaticMethodWrappers(FUN7 Fun)
{
assert(Fun!=0);
Default();
m_Fun7=Fun;
}

GlobalAndStaticMethodWrappers(FUN8 Fun)
{
assert(Fun!=0);
Default();
m_Fun8=Fun;
}

GlobalAndStaticMethodWrappers(FUN9 Fun)
{
assert(Fun!=0);
Default();
m_Fun9=Fun;
}

GlobalAndStaticMethodWrappers(FUN10 Fun)
{
assert(Fun!=0);
Default();
m_Fun10=Fun;
}

GlobalAndStaticMethodWrappers(FUN11 Fun)
{
assert(Fun!=0);
Default();
m_Fun11=Fun;
}

GlobalAndStaticMethodWrappers(FUN12 Fun)
{
assert(Fun!=0);
Default();
m_Fun12=Fun;
}

virtual RT Invoke()
{
assert(m_Fun0!=0);
return (*m_Fun0)();
}

virtual RT Invoke(T0 _0)
{
assert(m_Fun1!=0);
return(*m_Fun1)(_0);
}

virtual RT Invoke(T0 _0 , T1 _1)
{
assert(m_Fun2!=0);
return(*m_Fun2)(_0,_1);
}
virtual RT Invoke(T0 _0 , T1 _1 , T2 _2)
{
assert(m_Fun3!=0);
return(*m_Fun3)(_0,_1,_2);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3)
{
assert(m_Fun4!=0);
return(*m_Fun4)(_0,_1,_2,_3);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4)
{
assert(m_Fun5!=0);
return(*m_Fun5)(_0,_1,_2,_3,_4);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5)
{
assert(m_Fun6!=0);
return(*m_Fun6)(_0,_1,_2,_3,_4,_5);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6)
{
assert(m_Fun7!=0);
return(*m_Fun7)(_0,_1,_2,_3,_4,_5,_6);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7)
{
assert(m_Fun8!=0);
return(*m_Fun8)(_0,_1,_2,_3,_4,_5,_6,_7);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8)
{
assert(m_Fun9!=0);
return(*m_Fun9)(_0,_1,_2,_3,_4,_5,_6,_7,_8);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9)
{
assert(m_Fun10!=0);
return(*m_Fun10)(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9 , T10 _10)
{
assert(m_Fun11!=0);
return(*m_Fun11)(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9 , T10 _10 , T11 _11)
{
assert(m_Fun12!=0);
return(*m_Fun12)(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11);
}
};



template
<
typename RT
>
MethodWrappers<RT>*EventHandler(RT (*fun)())
{
return new GlobalAndStaticMethodWrappers<RT>(fun);
}

template
<
typename RT,typename T0
>
MethodWrappers<RT,T0>*EventHandler(RT (*fun)(T0))
{
return new GlobalAndStaticMethodWrappers<RT,T0>(fun);
}

template
<
typename RT,typename T0,typename T1
>
MethodWrappers<RT,T0,T1>*EventHandler(RT (*fun)(T0,T1))
{
return new GlobalAndStaticMethodWrappers<RT,T0,T1>(fun);
}

template
<
typename RT,typename T0,typename T1,typename T2
>
MethodWrappers<RT,T0,T1,T2>*EventHandler(RT (*fun)(T0,T1,T2))
{
return new GlobalAndStaticMethodWrappers<RT,T0,T1,T2>(fun);
}

template
<
typename RT,typename T0,typename T1,typename T2,typename T3
>
MethodWrappers<RT,T0,T1,T2,T3>*EventHandler(RT (*fun)(T0,T1,T2,T3))
{
return new GlobalAndStaticMethodWrappers<RT,T0,T1,T2,T3>(fun);
}

template
<
typename RT,
typename T0,typename T1,typename T2,typename T3,typename T4
>
MethodWrappers<RT,T0,T1,T2,T3,T4>*EventHandler(RT (*fun)(T0,T1,T2,T3,T4))
{
return new GlobalAndStaticMethodWrappers<RT,T0,T1,T2,T3,T4>(fun);
}

template
<
typename RT,
typename T0,typename T1,typename T2,typename T3,typename T4,
typename T5
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5>*EventHandler(RT (*fun)(T0,T1,T2,T3,T4,T5))
{
return new GlobalAndStaticMethodWrappers<RT,T0,T1,T2,T3,T4,T5>(fun);
}

template
<
typename RT,
typename T0,typename T1,typename T2,typename T3,typename T4,
typename T5,typename T6
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6>*EventHandler(RT (*fun)(T0,T1,T2,T3,T4,T5,T6))
{
return new GlobalAndStaticMethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6>(fun);
}

template
<
typename RT,
typename T0,typename T1,typename T2,typename T3,typename T4,
typename T5,typename T6,typename T7
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7>*EventHandler(RT (*fun)(T0,T1,T2,T3,T4,T5,T6,T7))
{
return new GlobalAndStaticMethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7>(fun);
}

template
<
typename RT,
typename T0,typename T1,typename T2,typename T3,typename T4,
typename T5,typename T6,typename T7,typename T8
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8>*EventHandler(RT (*fun)(T0,T1,T2,T3,T4,T5,T6,T7,T8))
{
return new GlobalAndStaticMethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8>(fun);
}

template
<
typename RT,
typename T0,typename T1,typename T2,typename T3,typename T4,
typename T5,typename T6,typename T7,typename T8,typename T9
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>*EventHandler(RT (*fun)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9))
{
return new GlobalAndStaticMethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>(fun);
}

template
<
typename RT,
typename T0,typename T1,typename T2,typename T3,typename T4,
typename T5,typename T6,typename T7,typename T8,typename T9,
typename T10
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>*EventHandler(RT (*fun)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10))
{
return new GlobalAndStaticMethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(fun);
}

template
<
typename RT,
typename T0,typename T1,typename T2,typename T3,typename T4,
typename T5,typename T6,typename T7,typename T8,typename T9,
typename T10,typename T11
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>*EventHandler(RT (*fun)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11))
{
return new GlobalAndStaticMethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(fun);
}
//////////////////////////////////////////////////////////////////////////
template
<
typename C,
typename RT,
typename T0 = null_type,typename T1 = null_type,typename T2 = null_type,typename T3 = null_type,
typename T4 = null_type,typename T5 = null_type,typename T6 = null_type,typename T7 = null_type,
typename T8 = null_type,typename T9 = null_type,typename T10 = null_type,typename T11 = null_type
>
//对象方法包装类。
class __declspec(dllexport) ObjectMemberMethodWrappers:public MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>
{
private:
typedef RT (C::*FUN0) ();
typedef RT (C::*FUN1) (T0);
typedef RT (C::*FUN2) (T0,T1);
typedef RT (C::*FUN3) (T0,T1,T2);
typedef RT (C::*FUN4) (T0,T1,T2,T3);
typedef RT (C::*FUN5) (T0,T1,T2,T3,T4);
typedef RT (C::*FUN6) (T0,T1,T2,T3,T4,T5);
typedef RT (C::*FUN7) (T0,T1,T2,T3,T4,T5,T6);
typedef RT (C::*FUN8) (T0,T1,T2,T3,T4,T5,T6,T7);
typedef RT (C::*FUN9) (T0,T1,T2,T3,T4,T5,T6,T7,T8);
typedef RT (C::*FUN10)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9);
typedef RT (C::*FUN11)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10);
typedef RT (C::*FUN12)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11);
private:
FUN0 m_Fun0;
FUN1 m_Fun1;
FUN2 m_Fun2;
FUN3 m_Fun3;
FUN4 m_Fun4;
FUN5 m_Fun5;
FUN6 m_Fun6;
FUN7 m_Fun7;
FUN8 m_Fun8;
FUN9 m_Fun9;
FUN10 m_Fun10;
FUN11 m_Fun11;
FUN12 m_Fun12;

C *m_Object;

void Default()
{
m_Fun0=0;
m_Fun1=0;
m_Fun2=0;
m_Fun3=0;
m_Fun4=0;
m_Fun5=0;
m_Fun6=0;
m_Fun7=0;
m_Fun8=0;
m_Fun9=0;
m_Fun10=0;
m_Fun11=0;
m_Fun12=0;

m_Object=0;
}

public:
virtual bool Equal(MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>*event)
{
ObjectMemberMethodWrappers<C,RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>* me= dynamic_cast<ObjectMemberMethodWrappers<C,RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>*>(event);

if (me==NULL)
return false;

if( m_Fun0 == me->m_Fun0 &&
m_Fun1 == me->m_Fun1 &&
m_Fun2 == me->m_Fun2 &&
m_Fun3 == me->m_Fun3 &&
m_Fun4 == me->m_Fun4 &&
m_Fun5 == me->m_Fun5 &&
m_Fun6 == me->m_Fun6 &&
m_Fun7 == me->m_Fun7 &&
m_Fun8 == me->m_Fun8 &&
m_Fun9 == me->m_Fun9 &&
m_Fun10 == me->m_Fun10 &&
m_Fun11 == me->m_Fun11 &&
m_Fun12 == me->m_Fun12 &&
m_Object == me->m_Object)
return true;
return false;
}

ObjectMemberMethodWrappers(C*pObject,FUN0 Fun)
{
assert(pObject!=0 && Fun!=0);
Default();
m_Fun0=Fun;
m_Object=pObject;
}

ObjectMemberMethodWrappers(C*pObject,FUN1 Fun)
{
assert(pObject!=0 && Fun!=0);
Default();
m_Fun1=Fun;
m_Object=pObject;
}

ObjectMemberMethodWrappers(C*pObject,FUN2 Fun)
{
assert(pObject!=0 && Fun!=0);
Default();
m_Fun2=Fun;
m_Object=pObject;
}

ObjectMemberMethodWrappers(C*pObject,FUN3 Fun)
{
assert(pObject!=0 && Fun!=0);
Default();
m_Fun3=Fun;
m_Object=pObject;
}

ObjectMemberMethodWrappers(C*pObject,FUN4 Fun)
{
assert(pObject!=0 && Fun!=0);
Default();
m_Fun4=Fun;
m_Object=pObject;
}
ObjectMemberMethodWrappers(C*pObject,FUN5 Fun)
{
assert(pObject!=0 && Fun!=0);
Default();
m_Fun5=Fun;
m_Object=pObject;
}
ObjectMemberMethodWrappers(C*pObject,FUN6 Fun)
{
assert(pObject!=0 && Fun!=0);
Default();
m_Fun6=Fun;
m_Object=pObject;
}
ObjectMemberMethodWrappers(C*pObject,FUN7 Fun)
{
assert(pObject!=0 && Fun!=0);
Default();
m_Fun7=Fun;
m_Object=pObject;
}
ObjectMemberMethodWrappers(C*pObject,FUN8 Fun)
{
assert(pObject!=0 && Fun!=0);
Default();
m_Fun8=Fun;
m_Object=pObject;
}
ObjectMemberMethodWrappers(C*pObject,FUN9 Fun)
{
assert(pObject!=0 && Fun!=0);
Default();
m_Fun9=Fun;
m_Object=pObject;
}
ObjectMemberMethodWrappers(C*pObject,FUN10 Fun)
{
assert(pObject!=0 && Fun!=0);
Default();
m_Fun10=Fun;
m_Object=pObject;
}
ObjectMemberMethodWrappers(C*pObject,FUN11 Fun)
{
assert(pObject!=0 && Fun!=0);
Default();
m_Fun11=Fun;
m_Object=pObject;
}
ObjectMemberMethodWrappers(C*pObject,FUN12 Fun)
{
assert(pObject!=0 && Fun!=0);
Default();
m_Fun12=Fun;
m_Object=pObject;
}

virtual RT Invoke()
{
assert(m_Object!=0);
assert(m_Fun0!=0);
return (m_Object->*m_Fun0)();
}

virtual RT Invoke(T0 _0)
{
assert(m_Object!=0);
assert(m_Fun1!=0);
return(m_Object->*m_Fun1)(_0);
}

virtual RT Invoke(T0 _0 , T1 _1)
{
assert(m_Object!=0);
assert(m_Fun2!=0);
return(m_Object->*m_Fun2)(_0,_1);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2)
{
assert(m_Object!=0);
assert(m_Fun3!=0);
return(m_Object->*m_Fun3)(_0,_1,_2);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3)
{
assert(m_Object!=0);
assert(m_Fun4!=0);
return(m_Object->*m_Fun4)(_0,_1,_2,_3);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4)
{
assert(m_Object!=0);
assert(m_Fun5!=0);
return(m_Object->*m_Fun5)(_0,_1,_2,_3,_4);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5)
{
assert(m_Object!=0);
assert(m_Fun6!=0);
return(m_Object->*m_Fun6)(_0,_1,_2,_3,_4,_5);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6)
{
assert(m_Object!=0);
assert(m_Fun7!=0);
return(m_Object->*m_Fun7)(_0,_1,_2,_3,_4,_5,_6);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7)
{
assert(m_Object!=0);
assert(m_Fun8!=0);
return(m_Object->*m_Fun8)(_0,_1,_2,_3,_4,_5,_6,_7);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8)
{
assert(m_Object!=0);
assert(m_Fun9!=0);
return(m_Object->*m_Fun9)(_0,_1,_2,_3,_4,_5,_6,_7,_8);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9)
{
assert(m_Object!=0);
assert(m_Fun10!=0);
return(m_Object->*m_Fun10)(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9);
}

virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9 , T10 _10)
{
assert(m_Object!=0);
assert(m_Fun11!=0);
return(m_Object->*m_Fun11)(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10);
}



virtual RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9 , T10 _10 , T11 _11)
{
assert(m_Object!=0);
assert(m_Fun12!=0);
return(m_Object->*m_Fun12)(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11);
}
};

template
<
typename C,typename RT
>
MethodWrappers<RT>*EventHandler(C*obj,RT (C::*fun)())
{
return new ObjectMemberMethodWrappers<C,RT>(obj,fun);
}

template
<
typename C,typename RT,typename T0
>
MethodWrappers<RT,T0>*EventHandler(C*obj,RT (C::*fun)(T0))
{
return new ObjectMemberMethodWrappers<C,RT,T0>(obj,fun);
}

template
<
typename C,typename RT,typename T0,typename T1
>
MethodWrappers<RT,T0,T1>*EventHandler(C*obj,RT (C::*fun)(T0,T1))
{
return new ObjectMemberMethodWrappers<C,RT,T0,T1>(obj,fun);
}

template
<
typename C,typename RT,typename T0,typename T1,typename T2
>
MethodWrappers<RT,T0,T1,T2>*EventHandler(C*obj,RT (C::*fun)(T0,T1,T2))
{
return new ObjectMemberMethodWrappers<C,RT,T0,T1,T2>(obj,fun);
}

template
<
typename C,typename RT,typename T0,typename T1,typename T2,typename T3
>
MethodWrappers<RT,T0,T1,T2,T3>*EventHandler(C*obj,RT (C::*fun)(T0,T1,T2,T3))
{
return new ObjectMemberMethodWrappers<C,RT,T0,T1,T2,T3>(obj,fun);
}

template
<
typename C,typename RT,typename T0,typename T1,typename T2,typename T3,
typename T4
>
MethodWrappers<RT,T0,T1,T2,T3,T4>*EventHandler(C*obj,RT (C::*fun)(T0,T1,T2,T3,T4))
{
return new ObjectMemberMethodWrappers<C,RT,T0,T1,T2,T3,T4>(obj,fun);
}

template
<
typename C,typename RT,typename T0,typename T1,typename T2,typename T3,
typename T4,typename T5
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5>*EventHandler(C*obj,RT (C::*fun)(T0,T1,T2,T3,T4,T5))
{
return new ObjectMemberMethodWrappers<C,RT,T0,T1,T2,T3,T4,T5>(obj,fun);
}

template
<
typename C,typename RT,typename T0,typename T1,typename T2,typename T3,
typename T4,typename T5,typename T6
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6>*EventHandler(C*obj,RT (C::*fun)(T0,T1,T2,T3,T4,T5,T6))
{
return new ObjectMemberMethodWrappers<C,RT,T0,T1,T2,T3,T4,T5,T6>(obj,fun);
}

template
<
typename C,typename RT,typename T0,typename T1,typename T2,typename T3,
typename T4,typename T5,typename T6,typename T7
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7>*EventHandler(C*obj,RT (C::*fun)(T0,T1,T2,T3,T4,T5,T6,T7))
{
return new ObjectMemberMethodWrappers<C,RT,T0,T1,T2,T3,T4,T5,T6,T7>(obj,fun);
}

template
<
typename C,typename RT,typename T0,typename T1,typename T2,typename T3,
typename T4,typename T5,typename T6,typename T7,typename T8
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8>*EventHandler(C*obj,RT (C::*fun)(T0,T1,T2,T3,T4,T5,T6,T7,T8))
{
return new ObjectMemberMethodWrappers<C,RT,T0,T1,T2,T3,T4,T5,T6,T7,T8>(obj,fun);
}

template
<
typename C,typename RT,typename T0,typename T1,typename T2,typename T3,
typename T4,typename T5,typename T6,typename T7,typename T8,typename T9
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>*EventHandler(C*obj,RT (C::*fun)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9))
{
return new ObjectMemberMethodWrappers<C,RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>(obj,fun);
}

template
<
typename C,typename RT,typename T0,typename T1,typename T2,typename T3,
typename T4,typename T5,typename T6,typename T7,typename T8,typename T9,
typename T10
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>*EventHandler(C*obj,RT (C::*fun)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10))
{
return new ObjectMemberMethodWrappers<C,RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(obj,fun);
}

template
<
typename C,typename RT,typename T0,typename T1,typename T2,typename T3,
typename T4,typename T5,typename T6,typename T7,typename T8,typename T9,
typename T10,typename T11
>
MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>*EventHandler(C*obj,RT (C::*fun)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11))
{
return new ObjectMemberMethodWrappers<C,RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(obj,fun);
}

//FunctorMethodsWrappers 函数对象(待实现)。

//template
//<
//typename RT,
//typename T0 = null_event,typename T1 = null_event,typename T2 = null_event,typename T3 = null_event,
//typename T4 = null_event,typename T5 = null_event,typename T6 = null_event,typename T7 = null_event,
//typename T8 = null_event,typename T9 = null_event,typename T10 = null_event,typename T11 = null_event
//>
//class FunctorMethodsWrappers
//{
//
//};


//////////////////////////////////////////////////////////////////////////
template
<
typename RT,
typename T0 = null_type,typename T1 = null_type,typename T2 = null_type,typename T3 = null_type,
typename T4 = null_type,typename T5 = null_type,typename T6 = null_type,typename T7 = null_type,
typename T8 = null_type,typename T9 = null_type,typename T10 = null_type,typename T11 = null_type
>
class __declspec(dllexport) __Delegate
{
typedef MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>*eventHandler;
private:
eventHandler m_EventHandler;

public:
bool IsValid()const
{
if(m_EventHandler!=0)
return true;
else
return false;
}
public:
__Delegate()
{
m_EventHandler=0;
}

virtual ~__Delegate()
{
if(m_EventHandler!=0)
{
delete m_EventHandler;
m_EventHandler=0;
}
}

void operator=(MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>*event)
{
if(m_EventHandler!=0)
delete m_EventHandler;
m_EventHandler=event;
}

RT Invoke()
{
if (m_EventHandler!=NULL)
return m_EventHandler->Invoke();
}

RT Invoke(T0 _0)
{
if (m_EventHandler!=NULL)
return m_EventHandler->Invoke(_0);
}

RT Invoke(T0 _0 , T1 _1)
{
if (m_EventHandler!=NULL)
return m_EventHandler->Invoke(_0,_1);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2)
{
if (m_EventHandler!=NULL)
return m_EventHandler->Invoke(_0,_1,_2);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3)
{
if (m_EventHandler!=NULL)
return m_EventHandler->Invoke(_0,_1,_2,_3);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4)
{
if (m_EventHandler!=NULL)
return m_EventHandler->Invoke(_0,_1,_2,_3,_4);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5)
{
if (m_EventHandler!=NULL)
return m_EventHandler->Invoke(_0,_1,_2,_3,_4,_5);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6)
{
if (m_EventHandler!=NULL)
return m_EventHandler->Invoke(_0,_1,_2,_3,_4,_5,_6);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7)
{
if (m_EventHandler!=NULL)
return m_EventHandler->Invoke(_0,_1,_2,_3,_4,_5,_6,_7);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8)
{
if (m_EventHandler!=NULL)
return m_EventHandler->Invoke(_0,_1,_2,_3,_4,_5,_6,_7,_8);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9)
{
if (m_EventHandler!=NULL)
return m_EventHandler->Invoke(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9 , T10 _10)
{
if (m_EventHandler!=NULL)
return m_EventHandler->Invoke(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9 , T10 _10 , T11 _11)
{
if (m_EventHandler!=NULL)
return m_EventHandler->Invoke(_0,_1,_2,_3 ,_4,_5,_6,_7,_8,_9,_10,_11);
}

RT operator()()
{
if(m_EventHandler!=0)
m_EventHandler->Invoke();
}

RT operator()(T0 _0)
{
if(m_EventHandler!=0)
m_EventHandler->Invoke(_0);
}

RT operator()(T0 _0 , T1 _1)
{
if(m_EventHandler!=0)
m_EventHandler->Invoke(_0,_1);
}

RT operator()(T0 _0 , T1 _1 , T2 _2)
{
if(m_EventHandler!=0)
m_EventHandler->Invoke(_0,_1,_2);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3)
{
if(m_EventHandler!=0)
m_EventHandler->Invoke(_0,_1,_2,_3);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4)
{
if(m_EventHandler!=0)
m_EventHandler->Invoke(_0,_1,_2,_3,_4);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5)
{
if(m_EventHandler!=0)
m_EventHandler->Invoke(_0,_1,_2,_3,_4,_5);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6)
{
if(m_EventHandler!=0)
m_EventHandler->Invoke(_0,_1,_2,_3,_4,_5,_6);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7)
{
if(m_EventHandler!=0)
m_EventHandler->Invoke(_0,_1,_2,_3,_4,_5,_6,_7);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8)
{
if(m_EventHandler!=0)
m_EventHandler->Invoke(_0,_1,_2,_3,_4,_5,_6,_7,_8);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9)
{
if(m_EventHandler!=0)
m_EventHandler->Invoke(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9 , T10 _10)
{
if(m_EventHandler!=0)
m_EventHandler->Invoke(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9 , T10 _10 , T11 _11)
{
if(m_EventHandler!=0)
m_EventHandler->Invoke(_0,_1,_2,_3 ,_4,_5,_6,_7,_8,_9,_10,_11);
}
};


template
<
typename RT,
typename T0 = null_type,typename T1 = null_type,typename T2 = null_type,typename T3 = null_type,
typename T4 = null_type,typename T5 = null_type,typename T6 = null_type,typename T7 = null_type,
typename T8 = null_type,typename T9 = null_type,typename T10 = null_type,typename T11 = null_type
>

class __declspec(dllexport) __Event
{
typedef MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>*eventHandler;
private:
list<eventHandler> m_EventHandlerList;

public:
bool IsEmpty()const
{
return m_EventHandlerList.size()==0;
}

int DelegateCount()
{
return m_EventHandlerList.size();
}
public:
__Event()
{

}

virtual ~__Event()
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
{
if ((*i)!=NULL) delete (*i);
}
}

void operator+=(MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>*event)
{
m_EventHandlerList.push_back(event);
}

void operator-=(MethodWrappers<RT,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>*event)
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
{
if ((*i)->Equal(event))
{
m_EventHandlerList.remove((*i));
break;
}
}
}

RT Invoke()
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
(*i)->Invoke();
}

RT Invoke(T0 _0)
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
(*i)->Invoke(_0);
}

RT Invoke(T0 _0 , T1 _1)
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
(*i)->Invoke(_0,_1);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2)
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
(*i)->Invoke(_0,_1,_2);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3)
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
(*i)->Invoke(_0,_1,_2,_3);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4)
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
(*i)->Invoke(_0,_1,_2,_3,_4);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5)
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
(*i)->Invoke(_0,_1,_2,_3,_4,_5);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6)
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
(*i)->Invoke(_0,_1,_2,_3,_4,_5,_6);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7)
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
(*i)->Invoke(_0,_1,_2,_3,_4,_5,_6,_7);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8)
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
(*i)->Invoke(_0,_1,_2,_3,_4,_5,_6,_7,_8);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9)
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
(*i)->Invoke(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9 , T10 _10)
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
(*i)->Invoke(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10);
}

RT Invoke(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9 , T10 _10 , T11 _11)
{
for (list<eventHandler>::iterator i = m_EventHandlerList.begin();i != m_EventHandlerList.end();i++)
(*i)->Invoke(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11);
}

RT operator()()
{
Invoke();
}

RT operator()(T0 _0)
{
Invoke(_0);
}

RT operator()(T0 _0 , T1 _1)
{
Invoke(_0,_1);
}

RT operator()(T0 _0 , T1 _1 , T2 _2)
{
Invoke(_0,_1,_2);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3)
{
Invoke(_0,_1,_2,_3);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4)
{
Invoke(_0,_1,_2,_3,_4);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5)
{
Invoke(_0,_1,_2,_3,_4,_5);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6)
{
Invoke(_0,_1,_2,_3,_4,_5,_6);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7)
{
Invoke(_0,_1,_2,_3,_4,_5,_6,_7);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8)
{
Invoke(_0,_1,_2,_3,_4,_5,_6,_7,_8);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9)
{
Invoke(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9 , T10 _10)
{
Invoke(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10);
}

RT operator()(T0 _0 , T1 _1 , T2 _2 , T3 _3 , T4 _4 , T5 _5 , T6 _6 , T7 _7 , T8 _8 , T9 _9 , T10 _10 , T11 _11)
{
Invoke(_0,_1,_2,_3 ,_4,_5,_6,_7,_8,_9,_10,_11);
}
};

#endif//_CPP_EVENT_
拒绝显摆。