-
2009-07-07
事件处理
#pragma once
#include <atlstr.h>
class CUccEvent;
class CUccEventHandler
{
public:
CUccEventHandler(){};
virtual ~CUccEventHandler(){};
public:
virtual bool Do(LPCTSTR lpMsg) = 0{};
};class CUccEvent
{
public:
CUccEvent(void):m_pEventHder(NULL){}CUccEvent(CUccEventHandler* pEventHder){
m_pEventHder = pEventHder;
}virtual ~CUccEvent(void){
m_pEventHder = NULL;
}public:
void Attach(const CUccEventHandler* pEventHder){
m_pEventHder = (CUccEventHandler*)pEventHder;
}CUccEventHandler* Detach(void){
CUccEventHandler* pTemp = m_pEventHder;
m_pEventHder = NULL;
return pTemp;
}public:
virtual bool Fire(LPCTSTR lpMsg) = 0{
if (NULL != m_pEventHder)
{
return m_pEventHder->Do(lpMsg);
}else{
return FALSE;
}
}
private:
CUccEventHandler* m_pEventHder;
};
class CUccGpEventHandler:public CUccEventHandler
{
public:
CUccGpEventHandler(void){};
virtual ~CUccGpEventHandler(){};
public:
virtual bool Do(LPCTSTR lpMsg)
{
return true;
}
};
class CUccGpEvent:public CUccEvent
{
public:
CUccGpEvent(CUccEventHandler* pEventHder):CUccEvent(pEventHder){};
~CUccGpEvent(){};
public:
virtual bool Fire(LPCTSTR lpMsg){
return CUccEvent::Fire(lpMsg);
}
};







