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.

129 lines
4.2 KiB

  1. // RSIMP.H: Definition of CITResultSet
  2. #ifndef __RSIMP_H__
  3. #define __RSIMP_H__
  4. #include "verinfo.h"
  5. class CHeader
  6. {
  7. public:
  8. PROPID dwPropID;
  9. DWORD dwType;
  10. union
  11. {
  12. LPVOID lpvData;
  13. DWORD dwValue;
  14. };
  15. PRIORITY Priority;
  16. LPVOID lpvHeap;
  17. PFNCOLHEAPFREE pfnHeapFree;
  18. };
  19. // Implemenation of IITResultSet
  20. class CITResultSet:
  21. public IITResultSet,
  22. public CComObjectRootEx<CComMultiThreadModel>,
  23. public CComCoClass<CITResultSet, &CLSID_IITResultSet>
  24. {
  25. BEGIN_COM_MAP(CITResultSet)
  26. COM_INTERFACE_ENTRY(IITResultSet)
  27. END_COM_MAP()
  28. DECLARE_REGISTRY(CLSID_IITResultSet, "ITIR.ResultSet.4",
  29. "ITIR.ResultSet", 0, THREADFLAGS_BOTH)
  30. public:
  31. CITResultSet();
  32. ~CITResultSet();
  33. public:
  34. // Initialization
  35. STDMETHOD(SetColumnPriority)(LONG lColumnIndex, PRIORITY ColumnPriority);
  36. STDMETHOD(SetColumnHeap)(LONG lColumnIndex, LPVOID lpvHeap,
  37. PFNCOLHEAPFREE pfnColHeapFree);
  38. inline STDMETHOD(SetKeyProp)(PROPID KeyPropID);
  39. STDMETHOD(Add)(LPVOID lpvHdr);
  40. STDMETHOD(Add)(PROPID PropID, LPVOID lpvDefaultData, DWORD cbData, PRIORITY Priority);
  41. STDMETHOD(Add)(PROPID PropID, LPCWSTR lpszwDefault, PRIORITY Priority);
  42. STDMETHOD(Add)(PROPID PropID, DWORD dwDefaultData, PRIORITY Priority);
  43. // Build result set
  44. STDMETHOD(Append)(LPVOID lpvHdr, LPVOID lpvData);
  45. STDMETHOD(Set)(LONG lRowIndex, LPVOID lpvHdr, LPVOID lpvData);
  46. STDMETHOD(Set)(LONG lRowIndex, LONG lColumnIndex, DWORD dwData);
  47. STDMETHOD(Set)(LONG lRowIndex, LONG lColumnIndex, LPCWSTR lpwStr);
  48. STDMETHOD(Set)(LONG lRowIndex, LONG lColumnIndex, LPVOID lpvData, DWORD cbData);
  49. STDMETHOD(Set)(LONG lRowIndex, LONG lColumnIndex, DWORD_PTR dwData);
  50. STDMETHOD(Copy)(IITResultSet* pRSCopy);
  51. STDMETHOD(AppendRows)(IITResultSet* pResSrc, LONG lRowSrcFirst, LONG cSrcRows,
  52. LONG& lRowFirstDest);
  53. // Obtain info about result set
  54. STDMETHOD(Get)(LONG lRowIndex, LONG lColumnIndex, CProperty& Prop);
  55. inline STDMETHOD(GetKeyProp)(DWORD& KeyPropID);
  56. STDMETHOD(GetColumnPriority)(LONG lColumnIndex, PRIORITY& ColumnPriority);
  57. inline STDMETHOD(GetColumnCount)(LONG& lNumberOfColumns);
  58. inline STDMETHOD(GetRowCount)(LONG& lNumberOfRows);
  59. STDMETHOD(GetColumn)(LONG lColumnIndex, PROPID& PropID);
  60. STDMETHOD(GetColumn)(LONG lColumnIndex, PROPID& PropID, DWORD& dwType, LPVOID& lpvDefaultValue,
  61. DWORD& cbSize, PRIORITY& ColumnPriority);
  62. STDMETHOD(GetColumnFromPropID)(PROPID PropID, LONG& lColumnIndex);
  63. // Clear result set
  64. STDMETHOD(Clear)();
  65. STDMETHOD(ClearRows)();
  66. STDMETHOD(Free)();
  67. // Asynchronous support
  68. STDMETHOD(IsCompleted)(); // returns S_OK or S_FALSE
  69. STDMETHOD(Cancel)();
  70. STDMETHOD(Pause)(BOOL fPause);
  71. STDMETHOD(GetRowStatus)(LONG lRowFirst, LONG cRows, LPROWSTATUS lpRowStatus);
  72. STDMETHOD(GetColumnStatus)(LPCOLUMNSTATUS lpColStatus);
  73. // STDMETHOD(Merge)();
  74. // Private methods and data
  75. private:
  76. // Methods for memory management
  77. HRESULT WINAPI Reserve();
  78. HRESULT WINAPI Commit(LONG RowNum);
  79. HRESULT WINAPI FreeMem();
  80. // Data
  81. LONG m_cProp; // Number of properties (column count)
  82. DWORD m_dwKeyProp; // Key property
  83. CHeader m_Header[MAX_COLUMNS]; // Result set header
  84. HANDLE m_hResultSet; // Handle to result set
  85. DWORD_PTR** m_ResultSet; // Result set data - an array of pointers to chunks
  86. // of rows
  87. LONG m_Chunk; // Keeps track of which chunk we need to access
  88. LONG m_NumChunks; // Number of chunks accessible via m_ResultSet
  89. LONG m_AppendRow; // Next row for appending
  90. // data to keep calculations to a minimum
  91. BOOL m_fInit; // Have we calculated numbers and allocated page map yet?
  92. LONG m_BytesReserved; // Number of bytes reserved at a time
  93. LONG m_RowsPerPage; // Number of rows in a page of memory
  94. LONG m_NumberOfPages; // Number of pages in a result set chunk
  95. BOOL* m_PageMap; // Keeps track of which pages have been allocated (per chunk)
  96. LONG m_RowsReserved; // Total number of rows that have been reserved
  97. _ThreadModel::AutoCriticalSection m_cs; // Critical section obj.
  98. LPVOID m_pMemPool; // Memory pool for data
  99. };
  100. #endif