Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
3.3 KiB

  1. //---------------------------------------------------------------------------
  2. // enumcnpt.cpp : CVDEnumConnPoints implementation file
  3. //
  4. // Copyright (c) 1996 Microsoft Corporation, All Rights Reserved
  5. // Developed by Sheridan Software Systems, Inc.
  6. //---------------------------------------------------------------------------
  7. #include "stdafx.h"
  8. #include "enumcnpt.h"
  9. // needed for ASSERTs and FAIL
  10. //
  11. SZTHISFILE
  12. //=--------------------------------------------------------------------------=
  13. // CVDEnumConnPoints constructor
  14. //
  15. CVDEnumConnPoints::CVDEnumConnPoints(IConnectionPoint* pConnPt)
  16. {
  17. m_dwRefCount = 1;
  18. m_dwCurrentPosition = 0;
  19. m_pConnPt = pConnPt;
  20. ADDREF_OBJECT(m_pConnPt);
  21. #ifdef _DEBUG
  22. g_cVDEnumConnPointsCreated++;
  23. #endif
  24. }
  25. //=--------------------------------------------------------------------------=
  26. // CVDEnumConnPoints destructor
  27. //
  28. CVDEnumConnPoints::~CVDEnumConnPoints()
  29. {
  30. RELEASE_OBJECT(m_pConnPt);
  31. #ifdef _DEBUG
  32. g_cVDEnumConnPointsDestroyed++;
  33. #endif
  34. }
  35. //=--------------------------------------------------------------------------=
  36. // IUnknown QueryInterface
  37. //
  38. HRESULT CVDEnumConnPoints::QueryInterface(REFIID riid, void **ppvObjOut)
  39. {
  40. ASSERT_POINTER(ppvObjOut, IUnknown*)
  41. *ppvObjOut = NULL;
  42. if (DO_GUIDS_MATCH(riid, IID_IUnknown) ||
  43. DO_GUIDS_MATCH(riid, IID_IEnumConnectionPoints) )
  44. {
  45. *ppvObjOut = this;
  46. AddRef();
  47. return S_OK;
  48. }
  49. return E_NOINTERFACE;
  50. }
  51. //=--------------------------------------------------------------------------=
  52. // IUnknown AddRef
  53. //
  54. ULONG CVDEnumConnPoints::AddRef(void)
  55. {
  56. return ++m_dwRefCount;
  57. }
  58. //=--------------------------------------------------------------------------=
  59. // IUnknown Release
  60. //
  61. ULONG CVDEnumConnPoints::Release(void)
  62. {
  63. if (1 > --m_dwRefCount)
  64. {
  65. delete this;
  66. return 0;
  67. }
  68. return m_dwRefCount;
  69. }
  70. //=--------------------------------------------------------------------------=
  71. // IEnumConnectionPoints Methods
  72. //=--------------------------------------------------------------------------=
  73. //=--------------------------------------------------------------------------=
  74. // IEnumConnectionPoints Next
  75. //
  76. HRESULT CVDEnumConnPoints::Next(ULONG cConnections, LPCONNECTIONPOINT FAR* rgpcn,
  77. ULONG FAR* lpcFetched)
  78. {
  79. ASSERT_POINTER(rgpcn, LPCONNECTIONPOINT)
  80. ASSERT_NULL_OR_POINTER(lpcFetched, ULONG)
  81. if (cConnections > 0 && m_dwCurrentPosition == 0 && m_pConnPt)
  82. {
  83. *rgpcn = m_pConnPt;
  84. if (lpcFetched)
  85. *lpcFetched = 1;
  86. m_dwCurrentPosition = 1;
  87. return S_OK;
  88. }
  89. else
  90. return S_FALSE;
  91. }
  92. //=--------------------------------------------------------------------------=
  93. // IEnumConnectionPoints Skip
  94. //
  95. HRESULT CVDEnumConnPoints::Skip(ULONG cConnections)
  96. {
  97. m_dwCurrentPosition = 1;
  98. return S_FALSE;
  99. }
  100. //=--------------------------------------------------------------------------=
  101. // IEnumConnectionPoints Reset
  102. //
  103. HRESULT CVDEnumConnPoints::Reset()
  104. {
  105. m_dwCurrentPosition = 0;
  106. return S_OK;
  107. }
  108. //=--------------------------------------------------------------------------=
  109. // IEnumConnectionPoints Clone
  110. //
  111. HRESULT CVDEnumConnPoints::Clone(LPENUMCONNECTIONPOINTS FAR* ppEnum)
  112. {
  113. ASSERT_POINTER(ppEnum, LPENUMCONNECTIONPOINTS)
  114. *ppEnum = new CVDEnumConnPoints(m_pConnPt);
  115. return (*ppEnum != NULL) ? S_OK : E_OUTOFMEMORY;
  116. }