128 lines
2.9 KiB
C++
128 lines
2.9 KiB
C++
/*
|
|
* @file IEventExtension.h
|
|
* @brief 这个文件定义了事件类型和事件侦听类型
|
|
* @date 2011-06-23
|
|
*/
|
|
#ifndef PAI_FRAME_PLUGIN_IEVENTEXTENSION_H
|
|
#define PAI_FRAME_PLUGIN_IEVENTEXTENSION_H
|
|
|
|
#include "IExtension.h"
|
|
#include "Turtle.h"
|
|
namespace pai
|
|
{
|
|
class IService;
|
|
}
|
|
|
|
namespace pai
|
|
{
|
|
/**
|
|
* @class IEventExtension
|
|
* @brief 事件类型基类
|
|
*/
|
|
class IEventExtension : public IExtension
|
|
{
|
|
public:
|
|
/**
|
|
* @brief 构造函数
|
|
* @param[in] eventTypeID 通常就是IEventExtension派生类的类名
|
|
*/
|
|
IEventExtension(const std::string & eventTypeID) :
|
|
m_EventTypeID(eventTypeID)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* @brief 得到扩展ID,这里的缺省实现就是事件类型ID
|
|
* @return 获取字符串型ID
|
|
*/
|
|
virtual std::string GetStringID() const
|
|
{
|
|
return m_EventTypeID;
|
|
}
|
|
|
|
public:
|
|
std::string m_EventTypeID; ///< 事件类型ID
|
|
};
|
|
|
|
/**
|
|
* @class IEventListener
|
|
* @brief 时间监听器
|
|
*/
|
|
class IEventListener : public IExtension
|
|
{
|
|
};
|
|
|
|
/**
|
|
* @class IServiceEventListener
|
|
* @brief 该类定义了IService类的注册和注销事件的响应函数接口
|
|
*/
|
|
class IServiceEventListener : public IEventListener
|
|
{
|
|
public:
|
|
/**
|
|
* @brief 注册时的响应函数
|
|
* @param[in] pExtension 注册的扩展
|
|
* @param[in] location 注册位置
|
|
*/
|
|
virtual void OnRegistered(IExtension *pExtension, const ILocation & location) = 0;
|
|
|
|
/**
|
|
* @brief 注销时的响应函数
|
|
* @param[in] extensionID 注销的扩展ID
|
|
*/
|
|
virtual void OnUnregistered(const std::string & extensionID) = 0;
|
|
};
|
|
|
|
/**
|
|
* @class ServiceRegisterEvent
|
|
* @brief 注册事件
|
|
*/
|
|
class ServiceRegisterEvent : public IEventExtension
|
|
{
|
|
public:
|
|
/**
|
|
* @brief 构造函数
|
|
* @param[in] pEventSrc 事件源
|
|
* @param[in] pRegistered 注册的拓展对象
|
|
* @param[in] location 注册的位置
|
|
*/
|
|
ServiceRegisterEvent(IService *pEventSrc,IExtension *pRegistered, const ILocation & location )
|
|
:IEventExtension("ServiceRegisterEvent"),
|
|
m_pEventSrc(pEventSrc),
|
|
m_pRegistered(pRegistered),
|
|
m_pLocation(&location)
|
|
{
|
|
}
|
|
|
|
IService *m_pEventSrc; ///< 事件源
|
|
IExtension *m_pRegistered; ///< 注册的扩展
|
|
const ILocation *m_pLocation; ///< 注册位置
|
|
};
|
|
|
|
/**
|
|
* @class ServiceUnregisterEvent
|
|
* @brief 注销事件
|
|
*/
|
|
class ServiceUnregisterEvent : public IEventExtension
|
|
{
|
|
public:
|
|
/**
|
|
* @brief 构造函数
|
|
* @param[in] pEventSrc 事件源
|
|
* @param[in] unregisteredID 注销的拓展ID
|
|
*/
|
|
ServiceUnregisterEvent(IService *pEventSrc, const std::string & unregisteredID)
|
|
:IEventExtension("ServiceUnregisterEvent"),
|
|
m_pEventSrc(pEventSrc),
|
|
m_UnregisteredID(unregisteredID)
|
|
{
|
|
}
|
|
|
|
IService *m_pEventSrc; ///< 事件源
|
|
std::string m_UnregisteredID; ///< 注销的扩展ID
|
|
};
|
|
|
|
}
|
|
|
|
#endif ///< PAI_FRAME_PLUGIN_IEVENTEXTENSION_H
|