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.

123 lines
3.6 KiB

  1. //---------------------------------------------------------------------------
  2. // RowsetSource.cpp : RowsetSource implementation
  3. //
  4. // Copyright (c) 1996 Microsoft Corporation, All Rights Reserved
  5. // Developed by Sheridan Software Systems, Inc.
  6. //---------------------------------------------------------------------------
  7. #include "stdafx.h"
  8. #include "Notifier.h"
  9. #include "RSSource.h"
  10. #include "MSR2C.h"
  11. SZTHISFILE
  12. //=--------------------------------------------------------------------------=
  13. // CVDRowsetSource - Constructor
  14. //
  15. CVDRowsetSource::CVDRowsetSource()
  16. {
  17. m_bool.fRowsetReleased = FALSE;
  18. m_bool.fInitialized = FALSE;
  19. m_pRowset = NULL;
  20. m_pAccessor = NULL;
  21. m_pRowsetLocate = NULL;
  22. m_pRowsetScroll = NULL;
  23. m_pRowsetChange = NULL;
  24. m_pRowsetUpdate = NULL;
  25. m_pRowsetFind = NULL;
  26. m_pRowsetInfo = NULL;
  27. m_pRowsetIdentity = NULL;
  28. #ifdef _DEBUG
  29. g_cVDRowsetSourceCreated++;
  30. #endif
  31. }
  32. //=--------------------------------------------------------------------------=
  33. // ~CVDRowsetSource - Destructor
  34. //
  35. CVDRowsetSource::~CVDRowsetSource()
  36. {
  37. if (IsRowsetValid())
  38. {
  39. RELEASE_OBJECT(m_pAccessor)
  40. RELEASE_OBJECT(m_pRowsetLocate)
  41. RELEASE_OBJECT(m_pRowsetScroll)
  42. RELEASE_OBJECT(m_pRowsetChange)
  43. RELEASE_OBJECT(m_pRowsetUpdate)
  44. RELEASE_OBJECT(m_pRowsetFind)
  45. RELEASE_OBJECT(m_pRowsetInfo)
  46. RELEASE_OBJECT(m_pRowsetIdentity)
  47. m_pRowset->Release();
  48. }
  49. #ifdef _DEBUG
  50. g_cVDRowsetSourceDestroyed++;
  51. #endif
  52. }
  53. //=--------------------------------------------------------------------------=
  54. // Initialize - Initialize rowset source object
  55. //=--------------------------------------------------------------------------=
  56. // This function QI's and store the IRowset pointers
  57. //
  58. // Parameters:
  59. // pRowset - [in] original IRowset pointer
  60. //
  61. // Output:
  62. // HRESULT - S_OK if successful
  63. // E_INVALIDARG bad parameter
  64. // E_FAIL if already initialized
  65. // VD_E_CANNOTGETMANDATORYINTERFACE unable to get required interface
  66. //
  67. // Notes:
  68. // This function should only be called once
  69. //
  70. HRESULT CVDRowsetSource::Initialize(IRowset * pRowset)
  71. {
  72. ASSERT_POINTER(pRowset, IRowset)
  73. if (!pRowset)
  74. return E_INVALIDARG;
  75. if (m_bool.fInitialized)
  76. {
  77. ASSERT(FALSE, VD_ASSERTMSG_ROWSRCALREADYINITIALIZED)
  78. return E_FAIL;
  79. }
  80. // mandatory interfaces (IAccessor is required for us)
  81. HRESULT hr = pRowset->QueryInterface(IID_IAccessor, (void**)&m_pAccessor);
  82. if (FAILED(hr))
  83. return VD_E_CANNOTGETMANDATORYINTERFACE;
  84. // mandatory interfaces (IRowsetLocate is required for us)
  85. hr = pRowset->QueryInterface(IID_IRowsetLocate, (void**)&m_pRowsetLocate);
  86. if (FAILED(hr))
  87. {
  88. m_pAccessor->Release();
  89. m_pAccessor = NULL;
  90. return VD_E_CANNOTGETMANDATORYINTERFACE;
  91. }
  92. // optional interfaces
  93. pRowset->QueryInterface(IID_IRowsetScroll, (void**)&m_pRowsetScroll);
  94. pRowset->QueryInterface(IID_IRowsetChange, (void**)&m_pRowsetChange);
  95. pRowset->QueryInterface(IID_IRowsetUpdate, (void**)&m_pRowsetUpdate);
  96. pRowset->QueryInterface(IID_IRowsetFind, (void**)&m_pRowsetFind);
  97. pRowset->QueryInterface(IID_IRowsetInfo, (void**)&m_pRowsetInfo);
  98. pRowset->QueryInterface(IID_IRowsetIdentity, (void**)&m_pRowsetIdentity);
  99. m_pRowset = pRowset;
  100. m_pRowset->AddRef();
  101. m_bool.fInitialized = TRUE;
  102. return S_OK;
  103. }