通知中心类,管理事件的注册、注销和触发 More...
#include <SNotifyCenter.h>
Public Member Functions | |
void | FireEventSync (IEvtArgs *e) OVERRIDE |
触发一个同步通知事件 | |
void | FireEventAsync (IEvtArgs *e) OVERRIDE |
触发一个异步通知事件 | |
BOOL | RegisterEventMap (const IEvtSlot *slot) OVERRIDE |
注册一个处理通知的对象 | |
BOOL | UnregisterEventMap (const IEvtSlot *slot) OVERRIDE |
注销一个处理通知的对象 | |
void | RunOnUI (IRunnable *pRunnable, BOOL bSync) OVERRIDE |
在UI线程中运行一个可运行对象 | |
void | RunOnUI2 (FunRunOnUI fun, WPARAM wp, LPARAM lp, BOOL bSync) OVERRIDE |
在UI线程中运行一个函数 | |
void | RunOnUISync (std::function< void(void)> fn) |
在UI线程中同步运行一个闭包 | |
void | RunOnUIAsync (std::function< void(void)> fn) |
在UI线程中异步运行一个闭包 | |
![]() | |
SSingleton2 (void) | |
Constructor for SSingleton2. | |
virtual | ~SSingleton2 (void) |
Destructor for SSingleton2. | |
![]() | |
SEventSet (void) | |
构造函数 | |
virtual | ~SEventSet (void) |
析构函数 | |
BOOL | addEvent (DWORD dwEventID, LPCWSTR pszEventHandlerName) |
添加一个新事件到事件集 | |
BOOL | removeEvent (DWORD dwEventID) |
移除指定ID的事件 | |
void | removeAllEvents (void) |
移除所有事件对象 | |
BOOL | isEventPresent (DWORD dwEventID) |
检查事件集是否包含指定ID的事件 | |
BOOL | setEventScriptHandler (const SStringW &strEventName, const SStringA strScriptHandler) |
设置事件的脚本处理程序 | |
SStringA | getEventScriptHandler (const SStringW &strEventName) const |
获取事件的脚本处理程序 | |
BOOL | subscribeEvent (DWORD dwEventID, const IEvtSlot &subscriber) |
订阅事件 | |
BOOL | subscribeEvent (DWORD dwEventID, const IEvtSlot *subscriber) |
订阅事件 | |
template<typename T, typename A> | |
BOOL | subscribeEvent (BOOL(T::*pFn)(A *), T *pObject) |
订阅事件(模板函数) | |
template<typename A> | |
BOOL | subscribeEvent (BOOL(*pFn)(A *)) |
订阅事件(模板函数) | |
template<typename T> | |
BOOL | subscribeEvent (DWORD dwEventID, BOOL(T::*pFn)(IEvtArgs *), T *pObject) |
订阅事件(模板函数) | |
BOOL | unsubscribeEvent (DWORD dwEventID, const IEvtSlot *subscriber) |
取消订阅事件 | |
BOOL | unsubscribeEvent (DWORD dwEventID, const IEvtSlot &subscriber) |
取消订阅事件 | |
template<typename T, typename A> | |
BOOL | unsubscribeEvent (BOOL(T::*pFn)(A *), T *pObject) |
取消订阅事件(模板函数) | |
template<typename A> | |
BOOL | unsubscribeEvent (BOOL(*pFn)(A *)) |
取消订阅事件(模板函数) | |
template<typename T> | |
BOOL | unsubscribeEvent (DWORD dwEventID, BOOL(T::*pFn)(IEvtArgs *), T *pObject) |
取消订阅事件(模板函数) | |
void | FireEvent (IEvtArgs *args) |
触发事件 | |
BOOL | isMuted (void) const |
检查事件集是否被静音 | |
void | setMutedState (BOOL setting) |
设置事件集的静音状态 | |
Protected Member Functions | |
virtual void | OnFireEvent (IEvtArgs *e) |
触发事件 | |
virtual void | OnFireEvts () |
触发多个事件 | |
![]() | |
SEvent * | GetEventObject (const DWORD dwEventID) |
获取事件对象 | |
Protected Attributes | |
tid_t | m_dwMainTrdID |
SList< IEvtSlot * > | m_evtHandlerMap |
SNotifyReceiver * | m_pReceiver |
SCriticalSection | m_cs |
SList< IEvtArgs * > | m_ayncEvent |
BOOL | m_bRunning |
int | m_nInterval |
SList< SAutoRefPtr< IRunnable > > | m_asyncRunnable |
![]() | |
SArray< SEvent * > | m_evtArr |
事件数组 | |
int | m_nMuted |
静音状态计数 | |
Additional Inherited Members | |
![]() | |
static SNotifyCenter & | getSingleton (void) |
Gets the singleton instance. | |
static SNotifyCenter * | getSingletonPtr (void) |
Gets the pointer to the singleton instance. | |
通知中心类,管理事件的注册、注销和触发
Definition at line 100 of file SNotifyCenter.h.
void SNotifyCenter::FireEventAsync | ( | IEvtArgs * | e | ) |
触发一个异步通知事件
e | 事件参数对象 |
可以在非UI线程中调用,EventArgs *e必须是从堆上分配的内存,调用后使用Release释放引用计数
Definition at line 92 of file SNotifyCenter.cpp.
void SNotifyCenter::FireEventSync | ( | IEvtArgs * | e | ) |
|
protectedvirtual |
触发事件
e | 事件参数对象 |
Implements INotifyCallback.
Definition at line 104 of file SNotifyCenter.cpp.
|
protectedvirtual |
BOOL SNotifyCenter::RegisterEventMap | ( | const IEvtSlot * | slot | ) |
注册一个处理通知的对象
slot | 事件处理对象 |
Definition at line 153 of file SNotifyCenter.cpp.
void SNotifyCenter::RunOnUI | ( | IRunnable * | pRunnable, |
BOOL | bSync ) |
在UI线程中运行一个可运行对象
pRunnable | 可运行对象 |
bSync | 同步执行标志 |
Definition at line 181 of file SNotifyCenter.cpp.
void SNotifyCenter::RunOnUI2 | ( | FunRunOnUI | fun, |
WPARAM | wp, | ||
LPARAM | lp, | ||
BOOL | bSync ) |
在UI线程中运行一个函数
fun | 函数指针 |
wp | WPARAM参数 |
lp | LPARAM参数 |
bSync | 同步执行标志 |
Definition at line 199 of file SNotifyCenter.cpp.
void SNotifyCenter::RunOnUIAsync | ( | std::function< void(void)> | fn | ) |
void SNotifyCenter::RunOnUISync | ( | std::function< void(void)> | fn | ) |
BOOL SNotifyCenter::UnregisterEventMap | ( | const IEvtSlot * | slot | ) |
注销一个处理通知的对象
slot | 事件处理对象 |
Definition at line 165 of file SNotifyCenter.cpp.
|
protected |
Definition at line 205 of file SNotifyCenter.h.
|
protected |
Definition at line 201 of file SNotifyCenter.h.
|
protected |
Definition at line 202 of file SNotifyCenter.h.
|
protected |
Definition at line 200 of file SNotifyCenter.h.
|
protected |
Definition at line 194 of file SNotifyCenter.h.
|
protected |
Definition at line 196 of file SNotifyCenter.h.
|
protected |
Definition at line 203 of file SNotifyCenter.h.
|
protected |
Definition at line 198 of file SNotifyCenter.h.