soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SNotifyCenter Class Reference

通知中心类,管理事件的注册、注销和触发 More...

#include <SNotifyCenter.h>

Inheritance diagram for SNotifyCenter:
SSingleton2< SNotifyCenter > SEventSet INotifyCallback

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线程中异步运行一个闭包
 
- Public Member Functions inherited from SSingleton2< SNotifyCenter >
 SSingleton2 (void)
 Constructor for SSingleton2.
 
virtual ~SSingleton2 (void)
 Destructor for SSingleton2.
 
- Public Member Functions inherited from SEventSet
 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 ()
 触发多个事件
 
- Protected Member Functions inherited from SEventSet
SEventGetEventObject (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
 
- Protected Attributes inherited from SEventSet
SArray< SEvent * > m_evtArr
 事件数组
 
int m_nMuted
 静音状态计数
 

Additional Inherited Members

- Static Public Member Functions inherited from SSingleton2< SNotifyCenter >
static SNotifyCentergetSingleton (void)
 Gets the singleton instance.
 
static SNotifyCentergetSingletonPtr (void)
 Gets the pointer to the singleton instance.
 

Detailed Description

通知中心类,管理事件的注册、注销和触发

Definition at line 100 of file SNotifyCenter.h.

Member Function Documentation

◆ FireEventAsync()

void SNotifyCenter::FireEventAsync ( IEvtArgs * e)

触发一个异步通知事件

Parameters
e事件参数对象

可以在非UI线程中调用,EventArgs *e必须是从堆上分配的内存,调用后使用Release释放引用计数

Definition at line 92 of file SNotifyCenter.cpp.

◆ FireEventSync()

void SNotifyCenter::FireEventSync ( IEvtArgs * e)

触发一个同步通知事件

Parameters
e事件参数对象

只能在UI线程中调用

Definition at line 85 of file SNotifyCenter.cpp.

◆ OnFireEvent()

void SNotifyCenter::OnFireEvent ( IEvtArgs * e)
protectedvirtual

触发事件

Parameters
e事件参数对象

Implements INotifyCallback.

Definition at line 104 of file SNotifyCenter.cpp.

◆ OnFireEvts()

void SNotifyCenter::OnFireEvts ( )
protectedvirtual

触发多个事件

Implements INotifyCallback.

Definition at line 123 of file SNotifyCenter.cpp.

◆ RegisterEventMap()

BOOL SNotifyCenter::RegisterEventMap ( const IEvtSlot * slot)

注册一个处理通知的对象

Parameters
slot事件处理对象
Returns
成功返回TRUE,失败返回FALSE

Definition at line 153 of file SNotifyCenter.cpp.

◆ RunOnUI()

void SNotifyCenter::RunOnUI ( IRunnable * pRunnable,
BOOL bSync )

在UI线程中运行一个可运行对象

Parameters
pRunnable可运行对象
bSync同步执行标志

Definition at line 181 of file SNotifyCenter.cpp.

◆ RunOnUI2()

void SNotifyCenter::RunOnUI2 ( FunRunOnUI fun,
WPARAM wp,
LPARAM lp,
BOOL bSync )

在UI线程中运行一个函数

Parameters
fun函数指针
wpWPARAM参数
lpLPARAM参数
bSync同步执行标志

Definition at line 199 of file SNotifyCenter.cpp.

◆ RunOnUIAsync()

void SNotifyCenter::RunOnUIAsync ( std::function< void(void)> fn)

在UI线程中异步运行一个闭包

Parameters
fn闭包函数

Definition at line 214 of file SNotifyCenter.cpp.

◆ RunOnUISync()

void SNotifyCenter::RunOnUISync ( std::function< void(void)> fn)

在UI线程中同步运行一个闭包

Parameters
fn闭包函数

Definition at line 207 of file SNotifyCenter.cpp.

◆ UnregisterEventMap()

BOOL SNotifyCenter::UnregisterEventMap ( const IEvtSlot * slot)

注销一个处理通知的对象

Parameters
slot事件处理对象
Returns
成功返回TRUE,失败返回FALSE

Definition at line 165 of file SNotifyCenter.cpp.

Member Data Documentation

◆ m_asyncRunnable

SList<SAutoRefPtr<IRunnable> > SNotifyCenter::m_asyncRunnable
protected

Definition at line 205 of file SNotifyCenter.h.

◆ m_ayncEvent

SList<IEvtArgs *> SNotifyCenter::m_ayncEvent
protected

Definition at line 201 of file SNotifyCenter.h.

◆ m_bRunning

BOOL SNotifyCenter::m_bRunning
protected

Definition at line 202 of file SNotifyCenter.h.

◆ m_cs

SCriticalSection SNotifyCenter::m_cs
protected

Definition at line 200 of file SNotifyCenter.h.

◆ m_dwMainTrdID

tid_t SNotifyCenter::m_dwMainTrdID
protected

Definition at line 194 of file SNotifyCenter.h.

◆ m_evtHandlerMap

SList<IEvtSlot *> SNotifyCenter::m_evtHandlerMap
protected

Definition at line 196 of file SNotifyCenter.h.

◆ m_nInterval

int SNotifyCenter::m_nInterval
protected

Definition at line 203 of file SNotifyCenter.h.

◆ m_pReceiver

SNotifyReceiver* SNotifyCenter::m_pReceiver
protected

Definition at line 198 of file SNotifyCenter.h.


The documentation for this class was generated from the following files: