Source code of Windows XP (NT5)
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.

157 lines
4.0 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: CRSEmbed.hxx
  7. //
  8. // Contents: IUnknown embedder for temptable.
  9. //
  10. // Functions:
  11. //
  12. // Notes:
  13. //
  14. //
  15. // History: 08/30/96 | RenatoB | Created
  16. //----------------------------------------------------------------------------
  17. #ifndef _CREMBED_H_
  18. #define _CREMBED_H_
  19. //-----------------------------------------------------------------------------
  20. // @class CRowsetInfo | ADSI embedding of Rowset,
  21. // to give our IrowsetInfo interface
  22. //
  23. //
  24. //-----------------------------------------------------------------------------
  25. class CRowProvider;
  26. class CRowsetInfo;
  27. class CCommandObject;
  28. class CSessionObject;
  29. class CRowsetInfo : INHERIT_TRACKING,
  30. public IRowsetInfo
  31. {
  32. friend HRESULT CreateTempTable(
  33. IRowProvider*,
  34. IUnknown*, IUnknown* ,
  35. CSessionObject* ,
  36. CCommandObject* ,
  37. ULONG,DBPROPSET[],
  38. ULONG,
  39. HACCESSOR[],
  40. REFIID,
  41. IUnknown**
  42. );
  43. public:
  44. DECLARE_STD_REFCOUNTING
  45. DECLARE_IRowsetInfo_METHODS
  46. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  47. CRowsetInfo(
  48. IUnknown *pUnkOuter,
  49. IUnknown *pParentObject,
  50. CSessionObject *pCSession,
  51. CCommandObject *pCCommand
  52. );
  53. ~CRowsetInfo();
  54. STDMETHODIMP FInit(
  55. IUnknown *pRowset //@parm IN| TmpTable interface
  56. );
  57. private:
  58. STDMETHODIMP InitProperties(void);
  59. // Frees the memory of an array of PropertySets
  60. STDMETHODIMP_(void)
  61. FreePropertySets(
  62. ULONG cPropertySets, // Count of property sets
  63. DBPROPSET *rgPropertySets // Array of property sets to be freed
  64. );
  65. STDMETHODIMP_(LONG )SearchGuid(
  66. GUID riid // GUID of the DBPROPSET
  67. );
  68. STDMETHODIMP_(LONG )SearchPropid(
  69. ULONG ibPropertySet,
  70. DWORD dwPropertyID
  71. );
  72. IUnknown *_pUnkOuter;
  73. IUnknown *_pRowset;
  74. IUnknown *_pParentObject;
  75. CSessionObject *_pCSession;
  76. CCommandObject *_pCCommand;
  77. CRITICAL_SECTION _csRowsetInfo;
  78. IMalloc* _pMalloc;
  79. ULONG _cPropertySets;
  80. DBPROPSET *_pPropertySets;
  81. // Status word.
  82. enum Status {
  83. STAT_UNINIT = 0x0000, //GetProperties Not initialized
  84. STAT_DIDINIT = 0x0001, //Get Properties initialized successfully
  85. STAT_INITERROR = 0x0002, //Get Properties Failed initialization
  86. };
  87. DWORD _dwStatus;
  88. };
  89. class CAutoBlock {
  90. friend class CRowsetInfo;
  91. friend class CRowsetInfo;
  92. friend class CImpIAccessor;
  93. private:
  94. CAutoBlock( CRITICAL_SECTION *pCrit );
  95. ~CAutoBlock();
  96. void UnBlock();
  97. CRITICAL_SECTION *_pCrit;
  98. };
  99. inline CAutoBlock::CAutoBlock(
  100. CRITICAL_SECTION *pCrit ) //@parm IN | The critical section.
  101. {
  102. // It is OK to pass a NULL ptr to this routine. It is a NOOP.
  103. // Note that passing NULL to EnterCriticalSection blows up.
  104. if (pCrit)
  105. ::EnterCriticalSection( pCrit );
  106. _pCrit = pCrit;
  107. };
  108. inline CAutoBlock::~CAutoBlock()
  109. {
  110. if (_pCrit)
  111. ::LeaveCriticalSection( _pCrit );
  112. }
  113. //-----------------------------------------------------------------------------
  114. // @mfunc
  115. // Ends blocking explicitly. Thereafter, the destructor does nothing.
  116. //-----------------------------------------------------------------------------------
  117. inline void CAutoBlock::UnBlock()
  118. {
  119. // Clear the critical-section member,
  120. // so that the destructor doesn't do anything.
  121. if (_pCrit)
  122. ::LeaveCriticalSection( _pCrit );
  123. _pCrit = NULL;
  124. }
  125. #endif //_CRSEMBED_H_