| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- #include "StdAfx.h"
- #include "ViewMgr.h"
- #include "resource.h"
- #include "DisplayWnd.h"
- #include "Config.h"
- #include "MsgCenter.h"
- SINGLETON_IMPLEMENT(CViewMgr)
- CViewMgr::CViewMgr(void)
- {
- }
- CViewMgr::~CViewMgr(void)
- {
- }
- /*****************************************************************
- **【函数名称】 __getView
- **【函数功能】 查找指定资源的视图
- **【参数】
- **【返回值】
- ****************************************************************/
- CViewResBase* CViewMgr::__getView( UINT ResType )
- {
- switch(ResType)
- {
- case DEV_RES_TYPE_TRUNK: return &m_ViewDti;
- case DEV_RES_TYPE_VOIP: return &m_ViewVoip;
- case DEV_RES_TYPE_IPM: return &m_ViewIpm;
- case DEV_RES_TYPE_DSP: return &m_ViewDsp;
- }
- return NULL;
- }
- /*****************************************************************
- **【函数名称】 setup
- **【函数功能】 视图管理器创建
- **【参数】
- **【返回值】
- ****************************************************************/
- bool CViewMgr::setup( CDisplayWnd* pWnd )
- {
- ASSERT(pWnd != NULL);
- m_pWnd = pWnd;
- if(!m_ViewLog.create(pWnd))
- {
- AfxMessageBox(_T("日志视图创建失败!"));
- return false;
- }
- if(!m_ViewDti.create(m_pWnd, IDS_STR_VIEW_DTI))
- {
- AfxMessageBox(_T("DTI视图创建失败!"));
- return false;
- }
- if(!m_ViewVoip.create(m_pWnd, IDS_STR_VIEW_VOIP))
- {
- AfxMessageBox(_T("VOIP视图创建失败!"));
- return false;
- }
- if(!m_ViewIpm.create(m_pWnd, IDS_STR_VIEW_IPM))
- {
- AfxMessageBox(_T("IPM视图创建失败!"));
- return false;
- }
- if(!m_ViewDsp.create(m_pWnd, IDS_STR_VIEW_DSP))
- {
- AfxMessageBox(_T("DSP视图创建失败!"));
- return false;
- }
- ILogger::getInstance().init(&m_ViewLog, LOG_DEV_SC, CConfig::logFilePath());
- ILogger::getInstance().start();
- CMsgCenter& MsgCenter = CMsgCenter::GetInstance();
- MsgCenter.regist(SYS_MSG_RES_NEW, this);
- MsgCenter.regist(SYS_MSG_RES_DEL, this);
- MsgCenter.regist(SYS_MSG_RES_STATE, this);
- return true;
- }
- /*****************************************************************
- **【函数名称】 showResView
- **【函数功能】 显示指定资源视图
- **【参数】
- **【返回值】
- ****************************************************************/
- void CViewMgr::showResView( UINT ResType )
- {
- CViewResBase* pView = __getView(ResType);
- ASSERT(pView != NULL);
- if(pView != NULL)
- pView->show();
- }
- /*****************************************************************
- **【函数名称】 onMessage
- **【函数功能】 消息事件处理函数
- **【参数】 MsgType: 消息事件类型
- lpContent: 消息内容
- **【返回值】
- ****************************************************************/
- void CViewMgr::onMessage( UINT MsgType, PARAM lpContent )
- {
- ASSERT(lpContent != NULL);
- DEV_RES_ID* pResId = new DEV_RES_ID(*(DEV_RES_ID*)lpContent);
- ASSERT(pResId != NULL);
-
- switch(MsgType)
- {
- case SYS_MSG_RES_NEW:
- AfxGetMainWnd()->PostMessage(WM_CORE_EVENT, CORE_EVENT_DEV_RES_NEW, (LPARAM)pResId);
- break;
- case SYS_MSG_RES_DEL:
- AfxGetMainWnd()->PostMessage(WM_CORE_EVENT, CORE_EVENT_DEV_RES_DEL, (LPARAM)pResId);
- break;
- case SYS_MSG_RES_STATE:
- AfxGetMainWnd()->PostMessage(WM_CORE_EVENT, CORE_EVENT_DEV_RES_STATE, (LPARAM)pResId);
- break;
- }
- }
- /*****************************************************************
- **【函数名称】 onResNew
- **【函数功能】 添加资源处理函数
- **【参数】
- **【返回值】
- ****************************************************************/
- void CViewMgr::onResNew( DEV_RES_ID*& pResId )
- {
- CViewResBase* pView = __getView(pResId->ResType);
- ASSERT(pView != NULL);
- if(pView != NULL)
- pView->onResNew(*pResId);
- delete pResId;
- pResId = NULL;
- }
- /*****************************************************************
- **【函数名称】 onResDel
- **【函数功能】 删除资源处理函数
- **【参数】
- **【返回值】
- ****************************************************************/
- void CViewMgr::onResDel( DEV_RES_ID*& pResId )
- {
- CViewResBase* pView = __getView(pResId->ResType);
- ASSERT(pView != NULL);
- if(pView != NULL)
- pView->onResDel(*pResId);
- delete pResId;
- pResId = NULL;
- }
- /*****************************************************************
- **【函数名称】 onResState
- **【函数功能】 资源状态更新处理函数
- **【参数】
- **【返回值】
- ****************************************************************/
- void CViewMgr::onResState( DEV_RES_ID*& pResId )
- {
- CViewResBase* pView = __getView(pResId->ResType);
- ASSERT(pView != NULL);
- if(pView != NULL)
- pView->onResState(*pResId);
- delete pResId;
- pResId = NULL;
- }
|