| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- #include "StdAfx.h"
- #include "TrunkContainer.h"
- #include "TrunkBase.h"
- CMap<int, int, TrunkType, TrunkType> CTrunkContainer::m_MapTrunkType;
- CMap<UINT, UINT, CTrunkBase*, CTrunkBase*> CTrunkContainer::m_MapTrunk;
- CTrunkContainer::CTrunkContainer(void)
- {
- }
- CTrunkContainer::~CTrunkContainer(void)
- {
- }
- /*****************************************************************
- **【函数名称】 registTrunk
- **【函数功能】 注册中继类型
- **【参数】
- **【返回值】
- ****************************************************************/
- void CTrunkContainer::registTrunk( int LineNum, TrunkType Type )
- {
- m_MapTrunkType.SetAt(LineNum, Type);
- }
- /*****************************************************************
- **【函数名称】 getTrunkType
- **【函数功能】 由线路号判断线路类型
- **【参数】
- **【返回值】
- ****************************************************************/
- TrunkType CTrunkContainer::getTrunkType( int LineNum )
- {
- TrunkType Type = TRUNK_UNKNOWN;
- m_MapTrunkType.Lookup(LineNum, Type);
- return Type;
- }
- /*****************************************************************
- **【函数名称】 addTrunk
- **【函数功能】 添加线路
- **【参数】
- **【返回值】
- ****************************************************************/
- void CTrunkContainer::addTrunk( CTrunkBase* pTrunk )
- {
- m_MapTrunk.SetAt(pTrunk->id(), pTrunk);
- }
- /*****************************************************************
- **【函数名称】 getTrunk
- **【函数功能】 获取线路
- **【参数】
- **【返回值】
- ****************************************************************/
- CTrunkBase* CTrunkContainer::getTrunk( UINT TrunkId )
- {
- CTrunkBase* pTrunk = NULL;
- m_MapTrunk.Lookup(TrunkId, pTrunk);
- return pTrunk;
- }
- /*****************************************************************
- **【函数名称】 getTrunkByCallId
- **【函数功能】 根据DevLink CallId 查找线路
- **【参数】
- **【返回值】
- ****************************************************************/
- CTrunkBase* CTrunkContainer::getTrunkByCallId( int DevLinkCallId )
- {
- POSITION pos = m_MapTrunk.GetStartPosition();
- while(pos != NULL)
- {
- CTrunkBase* pTrunk = NULL;
- UINT TrunkId = 0;
- m_MapTrunk.GetNextAssoc(pos, TrunkId, pTrunk);
- if(pTrunk->getDevLinkCallId() == DevLinkCallId)
- return pTrunk;
- } // end while
- return NULL;
- }
- /*****************************************************************
- **【函数名称】 isTrunkExist
- **【函数功能】 判断指定线路是否存在
- **【参数】
- **【返回值】
- ****************************************************************/
- bool CTrunkContainer::isTrunkExist( UINT TrunkId )
- {
- return getTrunk(TrunkId) != NULL;
- }
- /*****************************************************************
- **【函数名称】 clear
- **【函数功能】 释放线路
- **【参数】
- **【返回值】
- ****************************************************************/
- void CTrunkContainer::clear( void )
- {
- UINT TrunkId = 0;
- CTrunkBase* pTrunk = NULL;
- POSITION Pos = m_MapTrunk.GetStartPosition();
- while(Pos != NULL)
- {
- m_MapTrunk.GetNextAssoc(Pos, TrunkId, pTrunk);
- ASSERT(pTrunk != NULL);
- delete pTrunk;
- }
- m_MapTrunk.RemoveAll();
- m_MapTrunkType.RemoveAll();
- }
|