中间件标准版5.1git,去除基础模块

TrunkContainer.cpp 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #include "StdAfx.h"
  2. #include "TrunkContainer.h"
  3. #include "TrunkBase.h"
  4. CMap<int, int, TrunkType, TrunkType> CTrunkContainer::m_MapTrunkType;
  5. CMap<UINT, UINT, CTrunkBase*, CTrunkBase*> CTrunkContainer::m_MapTrunk;
  6. CTrunkContainer::CTrunkContainer(void)
  7. {
  8. }
  9. CTrunkContainer::~CTrunkContainer(void)
  10. {
  11. }
  12. /*****************************************************************
  13. **【函数名称】 registTrunk
  14. **【函数功能】 注册中继类型
  15. **【参数】
  16. **【返回值】
  17. ****************************************************************/
  18. void CTrunkContainer::registTrunk( int LineNum, TrunkType Type )
  19. {
  20. m_MapTrunkType.SetAt(LineNum, Type);
  21. }
  22. /*****************************************************************
  23. **【函数名称】 getTrunkType
  24. **【函数功能】 由线路号判断线路类型
  25. **【参数】
  26. **【返回值】
  27. ****************************************************************/
  28. TrunkType CTrunkContainer::getTrunkType( int LineNum )
  29. {
  30. TrunkType Type = TRUNK_UNKNOWN;
  31. m_MapTrunkType.Lookup(LineNum, Type);
  32. return Type;
  33. }
  34. /*****************************************************************
  35. **【函数名称】 addTrunk
  36. **【函数功能】 添加线路
  37. **【参数】
  38. **【返回值】
  39. ****************************************************************/
  40. void CTrunkContainer::addTrunk( CTrunkBase* pTrunk )
  41. {
  42. m_MapTrunk.SetAt(pTrunk->id(), pTrunk);
  43. }
  44. /*****************************************************************
  45. **【函数名称】 getTrunk
  46. **【函数功能】 获取线路
  47. **【参数】
  48. **【返回值】
  49. ****************************************************************/
  50. CTrunkBase* CTrunkContainer::getTrunk( UINT TrunkId )
  51. {
  52. CTrunkBase* pTrunk = NULL;
  53. m_MapTrunk.Lookup(TrunkId, pTrunk);
  54. return pTrunk;
  55. }
  56. /*****************************************************************
  57. **【函数名称】 getTrunkByCallId
  58. **【函数功能】 根据DevLink CallId 查找线路
  59. **【参数】
  60. **【返回值】
  61. ****************************************************************/
  62. CTrunkBase* CTrunkContainer::getTrunkByCallId( int DevLinkCallId )
  63. {
  64. POSITION pos = m_MapTrunk.GetStartPosition();
  65. while(pos != NULL)
  66. {
  67. CTrunkBase* pTrunk = NULL;
  68. UINT TrunkId = 0;
  69. m_MapTrunk.GetNextAssoc(pos, TrunkId, pTrunk);
  70. if(pTrunk->getDevLinkCallId() == DevLinkCallId)
  71. return pTrunk;
  72. } // end while
  73. return NULL;
  74. }
  75. /*****************************************************************
  76. **【函数名称】 isTrunkExist
  77. **【函数功能】 判断指定线路是否存在
  78. **【参数】
  79. **【返回值】
  80. ****************************************************************/
  81. bool CTrunkContainer::isTrunkExist( UINT TrunkId )
  82. {
  83. return getTrunk(TrunkId) != NULL;
  84. }
  85. /*****************************************************************
  86. **【函数名称】 clear
  87. **【函数功能】 释放线路
  88. **【参数】
  89. **【返回值】
  90. ****************************************************************/
  91. void CTrunkContainer::clear( void )
  92. {
  93. UINT TrunkId = 0;
  94. CTrunkBase* pTrunk = NULL;
  95. POSITION Pos = m_MapTrunk.GetStartPosition();
  96. while(Pos != NULL)
  97. {
  98. m_MapTrunk.GetNextAssoc(Pos, TrunkId, pTrunk);
  99. ASSERT(pTrunk != NULL);
  100. delete pTrunk;
  101. }
  102. m_MapTrunk.RemoveAll();
  103. m_MapTrunkType.RemoveAll();
  104. }