📄 icepublishsubscribe.h
字号:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Contains code for the publish-subscribe design pattern (a.k.a. dispatcher, decoupler, etc)
* \file IcePublishSubscribe.h
* \author Pierre Terdiman
* \date September, 15, 2001
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Include Guard
#ifndef __ICEPUBLISHSUBSCRIBE_H__
#define __ICEPUBLISHSUBSCRIBE_H__
class ICECORE_API IceEvent : public SmartContainer
{
DECLARE_ICE_CLASS(IceEvent, SmartContainer);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Subscribes a given object to the event. The object is first validated before registration.
* \param object [in] object interested in the event
* \return true if success
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline_ bool Subscribe(Cell* object) { return Add(object); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Subscribes a given object to the event, if it's not already done.
* \param object [in] object interested in the event
* \return true if success
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool SubscribeUnique(Cell* object);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Unsubscribes a given object from the event.
* \param object [in] object to unsubscribe
* \return true if success
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline_ bool Unsubscribe(Cell* object) { return Remove(object); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Publishes the event, i.e. notifies all subscribers.
* \param user_data [in] user-defined and event-dependent data
* \return true if success
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual bool Publish(udword user_data=0) = 0;
};
#endif // __ICEPUBLISHSUBSCRIBE_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -