1#ifndef __SEVENTSLOT__H__
2#define __SEVENTSLOT__H__
4#include <interface/SEvtArgs-i.h>
5#include <helper/obj-ref-impl.hpp>
7#if !defined(_WIN32) || _MSC_VER >= 1700
8#define ENABLE_STDFUNCTOR 1
10#define ENABLE_STDFUNCTOR 0
53 STDMETHOD_(BOOL,
Run)(THIS_ IEvtArgs *pArg) OVERRIDE
55 return d_function(pArg, d_ctx);
62 STDMETHOD_(IEvtSlot *,
Clone)(THIS) SCONST OVERRIDE
72 STDMETHOD_(BOOL,
Equal)(THIS_
const IEvtSlot *sour) SCONST OVERRIDE
74 if (sour->GetSlotType() != SLOT_FUN)
78 return psour->d_function == d_function && psour->d_ctx == d_ctx;
91 FunCallback d_function;
96typedef std::function<BOOL(IEvtArgs *)> StdFunCallback;
118 STDMETHOD_(BOOL,
Run)(THIS_ IEvtArgs *pArg) OVERRIDE
120 return d_function(pArg);
127 STDMETHOD_(IEvtSlot *,
Clone)(THIS) SCONST OVERRIDE
137 STDMETHOD_(BOOL,
Equal)(THIS_
const IEvtSlot *sour) SCONST OVERRIDE
140 if (sour->GetSlotType() != SLOT_STDFUNCTOR)
153 return SLOT_STDFUNCTOR;
157 StdFunCallback d_function;
167template <
typename T,
typename A>
191 STDMETHOD_(BOOL,
Run)(THIS_ IEvtArgs *pArg) OVERRIDE
193 return (d_object->*d_function)(
static_cast<A *
>(pArg));
200 STDMETHOD_(IEvtSlot *,
Clone)(THIS) SCONST OVERRIDE
210 STDMETHOD_(BOOL,
Equal)(THIS_
const IEvtSlot *sour) SCONST OVERRIDE
217 return psour->d_function == d_function && psour->d_object == d_object;
234template <
typename T,
typename A = IEvtArgs>
245template <
class T,
class A>
FreeFunctionSlot(FunCallback func, void *ctx)
构造函数
UINT GetSlotType() SCONST OVERRIDE
获取槽函数类型
BOOL Run(IEvtArgs *pArg) OVERRIDE
运行槽函数
BOOL Equal(const IEvtSlot *sour) SCONST OVERRIDE
比较两个槽函数对象是否相等
IEvtSlot * Clone() SCONST OVERRIDE
克隆槽函数对象
BOOL(T::* MemberFunctionType)(A *)
成员函数槽类型
MemberFunctionSlot(MemberFunctionType func, T *obj)
构造函数
BOOL Equal(const IEvtSlot *sour) SCONST OVERRIDE
比较两个槽函数对象是否相等
UINT GetSlotType() SCONST OVERRIDE
获取槽函数类型
BOOL Run(IEvtArgs *pArg) OVERRIDE
运行槽函数
IEvtSlot * Clone() SCONST OVERRIDE
克隆槽函数对象
BOOL Run(IEvtArgs *pArg) OVERRIDE
运行槽函数
IEvtSlot * Clone() SCONST OVERRIDE
克隆槽函数对象
StdFunctionSlot(const StdFunCallback &fun)
构造函数
BOOL Equal(const IEvtSlot *sour) SCONST OVERRIDE
比较两个槽函数对象是否相等
UINT GetSlotType() SCONST OVERRIDE
获取槽函数类型