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.

301 lines
9.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995 - 2000.
  5. //
  6. // File: Distrib.hxx
  7. //
  8. // Contents: Base class for distributed rowset
  9. //
  10. // Classes: CDistributedRowset
  11. //
  12. // History: 23-Feb-95 KyleP Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include <proprst.hxx>
  17. #include <impiunk.hxx>
  18. #include <accbase.hxx>
  19. #include <conpt.hxx>
  20. #include "rowman.hxx"
  21. #include "disnotfy.hxx"
  22. #include "bmkacc.hxx"
  23. //+---------------------------------------------------------------------------
  24. //
  25. // Class: CDistributedRowset
  26. //
  27. // Purpose: Base class for distributed rowset. Only implements
  28. // sequential methods.
  29. //
  30. // History: 05-Jun-95 KyleP Created.
  31. //
  32. //----------------------------------------------------------------------------
  33. class CDistributedRowset : public IRowset,
  34. public IColumnsInfo, public IRowsetIdentity,
  35. public IAccessor, public IRowsetInfo, public IConvertType,
  36. public IRowsetQueryStatus
  37. {
  38. public:
  39. //
  40. // IUnknown methods.
  41. //
  42. STDMETHOD(QueryInterface) ( THIS_ REFIID riid,
  43. LPVOID *ppiuk )
  44. {
  45. return _pControllingUnknown->QueryInterface(riid,ppiuk);
  46. }
  47. STDMETHOD_(ULONG, AddRef) (THIS) { return _pControllingUnknown->AddRef();}
  48. STDMETHOD_(ULONG, Release) (THIS) {return _pControllingUnknown->Release(); }
  49. //
  50. // IAccessor methods
  51. //
  52. STDMETHOD(AddRefAccessor) (HACCESSOR hAccessor,
  53. ULONG * pcRefCount);
  54. STDMETHOD(CreateAccessor) (DBACCESSORFLAGS dwAccessorFlags,
  55. DBCOUNTITEM cBindings,
  56. const DBBINDING rgBindings[],
  57. DBLENGTH cbRowSize,
  58. HACCESSOR * phAccessor,
  59. DBBINDSTATUS rgStatus[]);
  60. STDMETHOD(GetBindings) (HACCESSOR hAccessor,
  61. DBACCESSORFLAGS * pdwAccessorFlags,
  62. DBCOUNTITEM * pcBindings,
  63. DBBINDING * * prgBindings);
  64. STDMETHOD(ReleaseAccessor) (HACCESSOR hAccessor,
  65. ULONG * pcRefCount);
  66. //
  67. // IRowsetInfo methods
  68. //
  69. STDMETHOD(GetProperties) (const ULONG cPropertyIDSets,
  70. const DBPROPIDSET rgPropertyIDSets[],
  71. ULONG * pcProperties,
  72. DBPROPSET ** prgProperties);
  73. STDMETHOD(GetReferencedRowset) (DBORDINAL iOrdinal,
  74. REFIID riid,
  75. IUnknown ** ppReferencedRowset);
  76. //
  77. // IRowset methods
  78. //
  79. STDMETHOD(AddRefRows) (DBCOUNTITEM cRows,
  80. const HROW rghRows [],
  81. DBREFCOUNT rgRefCounts[],
  82. DBROWSTATUS rgRowStatus[]);
  83. STDMETHOD(GetData) (HROW hRow,
  84. HACCESSOR hAccessor,
  85. void * pData);
  86. STDMETHOD(GetNextRows) (HCHAPTER hChapter,
  87. DBROWOFFSET cRowsToSkip,
  88. DBROWCOUNT cRows,
  89. DBCOUNTITEM * pcRowsObtained,
  90. HROW ** pphRows);
  91. STDMETHOD(GetSpecification) (REFIID riid,
  92. IUnknown ** ppSpecification);
  93. STDMETHOD(ReleaseChapter) (HCHAPTER hChapter);
  94. STDMETHOD(ReleaseRows) (DBCOUNTITEM cRows,
  95. const HROW rghRows [],
  96. DBROWOPTIONS rgRowOptions[],
  97. DBREFCOUNT rgRefCounts[],
  98. DBROWSTATUS rgRowStatus[]);
  99. STDMETHOD(RestartPosition) (HCHAPTER hChapter);
  100. //
  101. // IColumnsInfo methods
  102. //
  103. STDMETHOD(GetColumnInfo) (DBORDINAL* pcColumns,
  104. DBCOLUMNINFO * * rrgInfo,
  105. WCHAR * * ppwchInfo );
  106. STDMETHOD(MapColumnIDs) (DBORDINAL cColumnIDs,
  107. const DBID rgColumnIDs[],
  108. DBORDINAL rgColumns[]);
  109. //
  110. // IRowsetIdentity methods
  111. //
  112. STDMETHOD(IsSameRow) ( HROW hThisRow, HROW hThatRow );
  113. //
  114. // IConvertType methods
  115. //
  116. STDMETHOD(CanConvert) ( DBTYPE wFromType,
  117. DBTYPE wToType,
  118. DBCONVERTFLAGS dwConvertFlags);
  119. //
  120. // IRowsetQueryStatus methods
  121. //
  122. STDMETHOD(GetStatus) (DWORD * pStatus);
  123. STDMETHOD(GetStatusEx) (DWORD * pStatus,
  124. DWORD * pcFilteredDocuments,
  125. DWORD * pcDocumentsToFilter,
  126. DBCOUNTITEM * pdwRatioFinishedDenominator,
  127. DBCOUNTITEM * pdwRatioFinishedNumerator,
  128. DBBKMARK cbBmk,
  129. const BYTE * pBmk,
  130. DBCOUNTITEM * piRowCurrent,
  131. DBCOUNTITEM * pcRowsTotal );
  132. //
  133. // Local methods
  134. //
  135. CDistributedRowset( IUnknown * pUnkOuter,
  136. IUnknown ** ppMyUnk,
  137. IRowset ** aChild,
  138. unsigned cChild,
  139. CMRowsetProps const & Props,
  140. unsigned cColumns,
  141. CAccessorBag & aAccessors,
  142. CCIOleDBError & DBErrorObj );
  143. protected:
  144. virtual ~CDistributedRowset();
  145. SCODE RealQueryInterface ( REFIID riid, LPVOID *ppiuk ); // used by _pControllingUnknown
  146. // in aggregation - does QI without delegating to outer unknown
  147. STDMETHOD(_GetNextRows) (HCHAPTER hChapter,
  148. DBROWOFFSET cRowsToSkip,
  149. DBROWCOUNT cRows,
  150. DBCOUNTITEM * pcRowsObtained,
  151. HROW ** pphRows) = 0;
  152. // This implementation includes all the extra columns that
  153. // we add for sorting, etc.
  154. STDMETHOD(_GetFullColumnInfo) (DBORDINAL* pcColumns,
  155. DBCOLUMNINFO * * rrgInfo,
  156. WCHAR * * ppwchInfo );
  157. CMutexSem _mutex;
  158. //
  159. // Event Notification Stuff...
  160. //
  161. // Array of child rowsets connection points
  162. XArray< XInterface<IConnectionPoint> > _xArrChildWatchCP;
  163. XArray< XInterface<IConnectionPoint> > _xArrChildAsynchCP;
  164. // Array of child rowsets watch regions
  165. XArray< XInterface<IRowsetWatchRegion> > _xArrChildRowsetWatchRegion;
  166. // Array of child rowsets advise cookies
  167. XArray<DWORD> _xArrWatchAdvise;
  168. XArray<DWORD> _xArrAsynchAdvise;
  169. // Distributed rowset connection point container which is
  170. // returned to the clients which try to connect to it
  171. XPtr<CConnectionPointContainer> _xServerCPC;
  172. // The sink which receives notifications from the child rowsets.
  173. // Also the Connection point to which the clients of distributed rowset
  174. // connect to.
  175. XPtr<CDistributedRowsetWatchNotify> _xChildNotify;
  176. // Distributed Bookmark Accessors
  177. XPtr<CDistributedBookmarkAccessor> _xDistBmkAcc;
  178. //
  179. // Child rowsets. One per point of distribution.
  180. //
  181. IRowset ** _aChild;
  182. unsigned _cChild;
  183. //
  184. // Number of columns originally given in Execute. We may add some for
  185. // management of the rowset, but these shouldn't be exposed to the client.
  186. //
  187. unsigned _cColumns;
  188. //
  189. // Distributed row manager, manages HROWs.
  190. //
  191. CHRowManager _RowManager;
  192. //
  193. // Cached info for IColumnsInfo::GetColumnInfo. This implementation needs
  194. // it. Why fetch it again for client?
  195. //
  196. DBORDINAL _cColInfo;
  197. DBCOLUMNINFO * _aColInfo;
  198. WCHAR * _awchInfo;
  199. //
  200. // Ordinal of bookmark column. Remove when ordinal 0 == bookmark.
  201. //
  202. DBORDINAL _iColumnBookmark;
  203. DBBKMARK _cbBookmark;
  204. //
  205. // Accessors created on rowset
  206. //
  207. CAccessorBag _aAccessors;
  208. //
  209. // Rowset Properties for base rowset.
  210. //
  211. CMRowsetProps _Props;
  212. CCIOleDBError & _DBErrorObj; // db error object
  213. IUnknown * _pControllingUnknown; // outer unknown
  214. friend class CImpIUnknown<CDistributedRowset>;
  215. CImpIUnknown<CDistributedRowset> _impIUnknown;
  216. DBROWCOUNT _cMaxResults; // The max row limit
  217. DBROWCOUNT _cFirstRows;
  218. DBROWCOUNT _iCurrentRow; // Used to limit rows in sequential rowsets
  219. private:
  220. friend class CScrollableSorted;
  221. void _SetupChildNotifications( BOOL fAsynchOnly );
  222. SCODE _SetupConnectionPointContainer( IRowset * pRowset, VOID * * ppiuk );
  223. };