callback.h
来自「The goal of this library is to make ODBC」· C头文件 代码 · 共 1,435 行 · 第 1/4 页
H
1,435 行
public:
CBFunctor3wRet(RHCB_DUMMY_INIT = 0){}
RT operator()(P1 p1,P2 p2,P3 p3)const
{
return RHCB_BC4_RET_BUG(thunk(*this,p1,p2,p3));
}
virtual CBFunctorBase *clone() const // added by MG
{
return new CBFunctor3wRet<P1, P2, P3, RT>(*this);
}
protected:
typedef RT (*Thunk)(const CBFunctorBase &,P1,P2,P3);
CBFunctor3wRet(Thunk t,const void *c,PFunc f,const void *mf,size_t sz):
CBFunctorBase(c,f,mf,sz),thunk(t){}
private:
Thunk thunk;
};
template <class P1,class P2,class P3,
class RT,class Callee, class MemFunc>
class CBMemberTranslator3wRet:public CBFunctor3wRet<P1,P2,P3,RT>{
public:
CBMemberTranslator3wRet(Callee &c,const MemFunc &m):
CBFunctor3wRet<P1,P2,P3,RT>(thunk,&c,0,&m,sizeof(MemFunc)){}
static RT thunk(const CBFunctorBase &ftor,P1 p1,P2 p2,P3 p3)
{
Callee *callee = (Callee *)ftor.getCallee();
MemFunc &memFunc RHCB_CTOR_STYLE_INIT
(*(MemFunc*)(void *)(ftor.getMemFunc()));
return RHCB_BC4_RET_BUG((callee->*memFunc)(p1,p2,p3));
}
};
template <class P1,class P2,class P3,class RT,class Func>
class CBFunctionTranslator3wRet:public CBFunctor3wRet<P1,P2,P3,RT>{
public:
CBFunctionTranslator3wRet(Func f):
CBFunctor3wRet<P1,P2,P3,RT>(thunk,0,(PFunc)f,0,0){}
static RT thunk(const CBFunctorBase &ftor,P1 p1,P2 p2,P3 p3)
{
return (Func(ftor.getFunc()))(p1,p2,p3);
}
};
#if !defined(RHCB_CANT_OVERLOAD_ON_CONSTNESS)
template <class P1,class P2,class P3,class RT,class Callee,
class TRT,class CallType,class TP1,class TP2,class TP3>
inline CBMemberTranslator3wRet<P1,P2,P3,RT,Callee,
TRT (CallType::*)(TP1,TP2,TP3)>
makeFunctor(CBFunctor3wRet<P1,P2,P3,RT>*,Callee &c,
TRT (CallType::* RHCB_CONST_REF f)(TP1,TP2,TP3))
{
typedef TRT (CallType::*MemFunc)(TP1,TP2,TP3);
return CBMemberTranslator3wRet<P1,P2,P3,RT,Callee,MemFunc>(c,f);
}
#endif
template <class P1,class P2,class P3,class RT,class Callee,
class TRT,class CallType,class TP1,class TP2,class TP3>
inline CBMemberTranslator3wRet<P1,P2,P3,RT,const Callee,
TRT (CallType::*)(TP1,TP2,TP3)const>
makeFunctor(CBFunctor3wRet<P1,P2,P3,RT>*,const Callee &c,
TRT (CallType::* RHCB_CONST_REF f)(TP1,TP2,TP3)const)
{
typedef TRT (CallType::*MemFunc)(TP1,TP2,TP3)const;
return CBMemberTranslator3wRet<P1,P2,P3,RT,const Callee,MemFunc>(c,f);
}
template <class P1,class P2,class P3,class RT,
class TRT,class TP1,class TP2,class TP3>
inline CBFunctionTranslator3wRet<P1,P2,P3,RT,TRT (*)(TP1,TP2,TP3)>
makeFunctor(CBFunctor3wRet<P1,P2,P3,RT>*,TRT (*f)(TP1,TP2,TP3))
{
return CBFunctionTranslator3wRet<P1,P2,P3,RT,TRT (*)(TP1,TP2,TP3)>(f);
}
template <class P1,class P2,class P3,class RT,class MemFunc>
class CBMemberOf1stArgTranslator3wRet:public CBFunctor3wRet<P1,P2,P3,RT>{
public:
CBMemberOf1stArgTranslator3wRet(const MemFunc &m):
CBFunctor3wRet<P1,P2,P3,RT>(thunk,(void *)1,0,&m,sizeof(MemFunc)){}
static RT thunk(const CBFunctorBase &ftor,P1 p1,P2 p2,P3 p3)
{
MemFunc &memFunc RHCB_CTOR_STYLE_INIT
(*(MemFunc*)(void *)(ftor.getMemFunc()));
return RHCB_BC4_RET_BUG((p1.*memFunc)(p2,p3));
}
};
#if !defined(RHCB_CANT_OVERLOAD_ON_CONSTNESS)
template <class P1,class P2,class P3,class RT,class TRT,class CallType,
class TP1,class TP2>
inline CBMemberOf1stArgTranslator3wRet<P1,P2,P3,RT,TRT (CallType::*)(TP1,TP2)>
makeFunctor(CBFunctor3wRet<P1,P2,P3,RT>*,
TRT (CallType::* RHCB_CONST_REF f)(TP1,TP2))
{
typedef TRT (CallType::*MemFunc)(TP1,TP2);
return CBMemberOf1stArgTranslator3wRet<P1,P2,P3,RT,MemFunc>(f);
}
#endif
template <class P1,class P2,class P3,class RT,class TRT,class CallType,
class TP1,class TP2>
inline CBMemberOf1stArgTranslator3wRet<P1,P2,P3,RT,
TRT (CallType::*)(TP1,TP2)const>
makeFunctor(CBFunctor3wRet<P1,P2,P3,RT>*,
TRT (CallType::* RHCB_CONST_REF f)(TP1,TP2)const)
{
typedef TRT (CallType::*MemFunc)(TP1,TP2)const;
return CBMemberOf1stArgTranslator3wRet<P1,P2,P3,RT,MemFunc>(f);
}
/************************* four args - no return *******************/
template <class P1,class P2,class P3,class P4>
class CBFunctor4:public CBFunctorBase{
public:
CBFunctor4(RHCB_DUMMY_INIT = 0){}
void operator()(P1 p1,P2 p2,P3 p3,P4 p4)const
{
thunk(*this,p1,p2,p3,p4);
}
virtual CBFunctorBase *clone() const // added by MG
{
return new CBFunctor4<P1, P2, P3, P4>(*this);
}
protected:
typedef void (*Thunk)(const CBFunctorBase &,P1,P2,P3,P4);
CBFunctor4(Thunk t,const void *c,PFunc f,const void *mf,size_t sz):
CBFunctorBase(c,f,mf,sz),thunk(t){}
private:
Thunk thunk;
};
template <class P1,class P2,class P3,class P4,
class Callee, class MemFunc>
class CBMemberTranslator4:public CBFunctor4<P1,P2,P3,P4>{
public:
CBMemberTranslator4(Callee &c,const MemFunc &m):
CBFunctor4<P1,P2,P3,P4>(thunk,&c,0,&m,sizeof(MemFunc)){}
static void thunk(const CBFunctorBase &ftor,P1 p1,P2 p2,P3 p3,P4 p4)
{
Callee *callee = (Callee *)ftor.getCallee();
MemFunc &memFunc RHCB_CTOR_STYLE_INIT
(*(MemFunc*)(void *)(ftor.getMemFunc()));
(callee->*memFunc)(p1,p2,p3,p4);
}
};
template <class P1,class P2,class P3,class P4,class Func>
class CBFunctionTranslator4:public CBFunctor4<P1,P2,P3,P4>{
public:
CBFunctionTranslator4(Func f):
CBFunctor4<P1,P2,P3,P4>(thunk,0,(PFunc)f,0,0){}
static void thunk(const CBFunctorBase &ftor,P1 p1,P2 p2,P3 p3,P4 p4)
{
(Func(ftor.getFunc()))(p1,p2,p3,p4);
}
};
#if !defined(RHCB_CANT_OVERLOAD_ON_CONSTNESS)
template <class P1,class P2,class P3,class P4,class Callee,
class TRT,class CallType,class TP1,class TP2,class TP3,class TP4>
inline CBMemberTranslator4<P1,P2,P3,P4,Callee,
TRT (CallType::*)(TP1,TP2,TP3,TP4)>
makeFunctor(CBFunctor4<P1,P2,P3,P4>*,Callee &c,
TRT (CallType::* RHCB_CONST_REF f)(TP1,TP2,TP3,TP4))
{
typedef TRT (CallType::*MemFunc)(TP1,TP2,TP3,TP4);
return CBMemberTranslator4<P1,P2,P3,P4,Callee,MemFunc>(c,f);
}
#endif
template <class P1,class P2,class P3,class P4,class Callee,
class TRT,class CallType,class TP1,class TP2,class TP3,class TP4>
inline CBMemberTranslator4<P1,P2,P3,P4,const Callee,
TRT (CallType::*)(TP1,TP2,TP3,TP4)const>
makeFunctor(CBFunctor4<P1,P2,P3,P4>*,const Callee &c,
TRT (CallType::* RHCB_CONST_REF f)(TP1,TP2,TP3,TP4)const)
{
typedef TRT (CallType::*MemFunc)(TP1,TP2,TP3,TP4)const;
return CBMemberTranslator4<P1,P2,P3,P4,const Callee,MemFunc>(c,f);
}
template <class P1,class P2,class P3,class P4,
class TRT,class TP1,class TP2,class TP3,class TP4>
inline CBFunctionTranslator4<P1,P2,P3,P4,TRT (*)(TP1,TP2,TP3,TP4)>
makeFunctor(CBFunctor4<P1,P2,P3,P4>*,TRT (*f)(TP1,TP2,TP3,TP4))
{
return CBFunctionTranslator4<P1,P2,P3,P4,TRT (*)(TP1,TP2,TP3,TP4)>(f);
}
template <class P1,class P2,class P3,class P4,class MemFunc>
class CBMemberOf1stArgTranslator4:public CBFunctor4<P1,P2,P3,P4>{
public:
CBMemberOf1stArgTranslator4(const MemFunc &m):
CBFunctor4<P1,P2,P3,P4>(thunk,(void *)1,0,&m,sizeof(MemFunc)){}
static void thunk(const CBFunctorBase &ftor,P1 p1,P2 p2,P3 p3,P4 p4)
{
MemFunc &memFunc RHCB_CTOR_STYLE_INIT
(*(MemFunc*)(void *)(ftor.getMemFunc()));
(p1.*memFunc)(p2,p3,p4);
}
};
#if !defined(RHCB_CANT_OVERLOAD_ON_CONSTNESS)
template <class P1,class P2,class P3,class P4,class TRT,class CallType,
class TP1,class TP2,class TP3>
inline CBMemberOf1stArgTranslator4<P1,P2,P3,P4,TRT (CallType::*)(TP1,TP2,TP3)>
makeFunctor(CBFunctor4<P1,P2,P3,P4>*,
TRT (CallType::* RHCB_CONST_REF f)(TP1,TP2,TP3))
{
typedef TRT (CallType::*MemFunc)(TP1,TP2,TP3);
return CBMemberOf1stArgTranslator4<P1,P2,P3,P4,MemFunc>(f);
}
#endif
template <class P1,class P2,class P3,class P4,class TRT,class CallType,
class TP1,class TP2,class TP3>
inline CBMemberOf1stArgTranslator4<P1,P2,P3,P4,
TRT (CallType::*)(TP1,TP2,TP3)const>
makeFunctor(CBFunctor4<P1,P2,P3,P4>*,
TRT (CallType::* RHCB_CONST_REF f)(TP1,TP2,TP3)const)
{
typedef TRT (CallType::*MemFunc)(TP1,TP2,TP3)const;
return CBMemberOf1stArgTranslator4<P1,P2,P3,P4,MemFunc>(f);
}
/************************* four args - with return *******************/
template <class P1,class P2,class P3,class P4,class RT>
class CBFunctor4wRet:public CBFunctorBase{
public:
CBFunctor4wRet(RHCB_DUMMY_INIT = 0){}
RT operator()(P1 p1,P2 p2,P3 p3,P4 p4)const
{
return RHCB_BC4_RET_BUG(thunk(*this,p1,p2,p3,p4));
}
virtual CBFunctorBase *clone() const // added by MG
{
return new CBFunctor4wRet<P1, P2, P3, P4, RT>(*this);
}
protected:
typedef RT (*Thunk)(const CBFunctorBase &,P1,P2,P3,P4);
CBFunctor4wRet(Thunk t,const void *c,PFunc f,const void *mf,size_t sz):
CBFunctorBase(c,f,mf,sz),thunk(t){}
private:
Thunk thunk;
};
template <class P1,class P2,class P3,class P4,class RT,
class Callee, class MemFunc>
class CBMemberTranslator4wRet:public CBFunctor4wRet<P1,P2,P3,P4,RT>{
public:
CBMemberTranslator4wRet(Callee &c,const MemFunc &m):
CBFunctor4wRet<P1,P2,P3,P4,RT>(thunk,&c,0,&m,sizeof(MemFunc)){}
static RT thunk(const CBFunctorBase &ftor,P1 p1,P2 p2,P3 p3,P4 p4)
{
Callee *callee = (Callee *)ftor.getCallee();
MemFunc &memFunc RHCB_CTOR_STYLE_INIT
(*(MemFunc*)(void *)(ftor.getMemFunc()));
return RHCB_BC4_RET_BUG((callee->*memFunc)(p1,p2,p3,p4));
}
};
template <class P1,class P2,class P3,class P4,class RT,class Func>
class CBFunctionTranslator4wRet:public CBFunctor4wRet<P1,P2,P3,P4,RT>{
public:
CBFunctionTranslator4wRet(Func f):
CBFunctor4wRet<P1,P2,P3,P4,RT>(thunk,0,(PFunc)f,0,0){}
static RT thunk(const CBFunctorBase &ftor,P1 p1,P2 p2,P3 p3,P4 p4)
{
return (Func(ftor.getFunc()))(p1,p2,p3,p4);
}
};
#if !defined(RHCB_CANT_OVERLOAD_ON_CONSTNESS)
template <class P1,class P2,class P3,class P4,class RT,class Callee,
class TRT,class CallType,class TP1,class TP2,class TP3,class TP4>
inline CBMemberTranslator4wRet<P1,P2,P3,P4,RT,Callee,
TRT (CallType::*)(TP1,TP2,TP3,TP4)>
makeFunctor(CBFunctor4wRet<P1,P2,P3,P4,RT>*,Callee &c,
TRT (CallType::* RHCB_CONST_REF f)(TP1,TP2,TP3,TP4))
{
typedef TRT (CallType::*MemFunc)(TP1,TP2,TP3,TP4);
return CBMemberTranslator4wRet<P1,P2,P3,P4,RT,Callee,MemFunc>(c,f);
}
#endif
template <class P1,class P2,class P3,class P4,class RT,class Callee,
class TRT,class CallType,class TP1,class TP2,class TP3,class TP4>
inline CBMemberTranslator4wRet<P1,P2,P3,P4,RT,const Callee,
TRT (CallType::*)(TP1,TP2,TP3,TP4)const>
makeFunctor(CBFunctor4wRet<P1,P2,P3,P4,RT>*,const Callee &c,
TRT (CallType::* RHCB_CONST_REF f)(TP1,TP2,TP3,TP4)const)
{
typedef TRT (CallType::*MemFunc)(TP1,TP2,TP3,TP4)const;
return CBMemberTranslator4wRet<P1,P2,P3,P4,RT,const Callee,MemFunc>(c,f);
}
template <class P1,class P2,class P3,class P4,class RT,
class TRT,class TP1,class TP2,class TP3,class TP4>
inline CBFunctionTranslator4wRet<P1,P2,P3,P4,RT,TRT (*)(TP1,TP2,TP3,TP4)>
makeFunctor(CBFunctor4wRet<P1,P2,P3,P4,RT>*,TRT (*f)(TP1,TP2,TP3,TP4))
{
return CBFunctionTranslator4wRet
<P1,P2,P3,P4,RT,TRT (*)(TP1,TP2,TP3,TP4)>(f);
}
template <class P1,class P2,class P3,class P4,class RT,class MemFunc>
class CBMemberOf1stArgTranslator4wRet:public CBFunctor4wRet<P1,P2,P3,P4,RT>{
public:
CBMemberOf1stArgTranslator4wRet(const MemFunc &m):
CBFunctor4wRet<P1,P2,P3,P4,RT>(thunk,(void *)1,0,&m,sizeof(MemFunc)){}
static RT thunk(const CBFunctorBase &ftor,P1 p1,P2 p2,P3 p3,P4 p4)
{
MemFunc &memFunc RHCB_CTOR_STYLE_INIT
(*(MemFunc*)(void *)(ftor.getMemFunc()));
return RHCB_BC4_RET_BUG((p1.*memFunc)(p2,p3,p4));
}
};
#if !defined(RHCB_CANT_OVERLOAD_ON_CONSTNESS)
template <class P1,class P2,class P3,class P4,class RT,class TRT,
class CallType,class TP1,class TP2,class TP3>
inline CBMemberOf1stArgTranslator4wRet<P1,P2,P3,P4,RT,
TRT (CallType::*)(TP1,TP2,TP3)>
makeFunctor(CBFunctor4wRet<P1,P2,P3,P4,RT>*,
TRT (CallType::* RHCB_CONST_REF f)(TP1,TP2,TP3))
{
typedef TRT (CallType::*MemFunc)(TP1,TP2,TP3);
return CBMemberOf1stArgTranslator4wRet<P1,P2,P3,P4,RT,MemFunc>(f);
}
#endif
template <class P1,class P2,class P3,class P4,class RT,class TRT,
class CallType,class TP1,class TP2,class TP3>
inline CBMemberOf1stArgTranslator4wRet<P1,P2,P3,P4,RT,
TRT (CallType::*)(TP1,TP2,TP3)const>
makeFunctor(CBFunctor4wRet<P1,P2,P3,P4,RT>*,
TRT (CallType::* RHCB_CONST_REF f)(TP1,TP2,TP3)const)
{
typedef TRT (CallType::*MemFunc)(TP1,TP2,TP3)const;
return CBMemberOf1stArgTranslator4wRet<P1,P2,P3,P4,RT,MemFunc>(f);
}
END_DTL_NAMESPACE
#endif //CALLBACK_HPP
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?