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.

224 lines
6.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation.
  4. //
  5. // File: PhysIndex.HXX
  6. //
  7. // Contents: FAT Buffer/Index package
  8. //
  9. // Classes: CPhysBuffer -- Buffer
  10. //
  11. // History: 05-Mar-92 KyleP Created
  12. //
  13. //----------------------------------------------------------------------------
  14. #pragma once
  15. #include <phystr.hxx>
  16. //+-------------------------------------------------------------------------
  17. //
  18. // Class: CPhysIndex
  19. //
  20. // Purpose: Provides physical access to index pages
  21. //
  22. // History: 17-Feb-92 KyleP Subclass for PhysIndex / PhysHash
  23. //
  24. //--------------------------------------------------------------------------
  25. class CPhysIndex : public CPhysStorage
  26. {
  27. public:
  28. inline CPhysIndex( PStorage & storage,
  29. PStorageObject& obj,
  30. WORKID objectId,
  31. unsigned cpageReqSize,
  32. XPtr<PMmStream> & stream );
  33. inline CPhysIndex( PStorage & storage,
  34. PStorageObject& obj,
  35. WORKID objectId,
  36. PStorage::EOpenMode mode,
  37. XPtr<PMmStream> & stream );
  38. inline CPhysIndex( CPhysIndex & readIndex,
  39. PStorage::EOpenMode mode,
  40. XPtr<PMmStream> & stream );
  41. inline PMmStream * DupReadWriteStream( PStorage::EOpenMode mode )
  42. {
  43. return _storage.DupExistingIndexStream( _obj, _stream.GetReference(), mode );
  44. }
  45. PStorage & GetStorage() { return _storage; }
  46. private:
  47. virtual void ReOpenStream();
  48. };
  49. //+-------------------------------------------------------------------------
  50. //
  51. // Class: CPhysHash
  52. //
  53. // Purpose: Provides physical access to hash pages
  54. //
  55. // History: 17-Feb-92 KyleP Subclass for PhysIndex / PhysHash
  56. //
  57. //--------------------------------------------------------------------------
  58. class CPhysHash : public CPhysStorage
  59. {
  60. public:
  61. inline CPhysHash( PStorage & storage,
  62. PStorageObject& obj,
  63. WORKID objectId,
  64. unsigned cpageReqSize,
  65. XPtr<PMmStream> & stream );
  66. inline CPhysHash( PStorage & storage,
  67. PStorageObject& obj,
  68. WORKID objectId,
  69. PStorage::EOpenMode mode,
  70. XPtr<PMmStream> & stream );
  71. private:
  72. virtual void ReOpenStream();
  73. };
  74. //+-------------------------------------------------------------------------
  75. //
  76. // Method: CPhysIndex::CPhysIndex
  77. //
  78. // Synopsis: Ctor for an existing index in readable or writeable mode.
  79. //
  80. // History: 17-Feb-1994 KyleP Created
  81. // 10-Apr-1994 SrikantS Added the ability to open an
  82. // existing stream for write
  83. // access.
  84. //
  85. //--------------------------------------------------------------------------
  86. inline CPhysIndex::CPhysIndex( PStorage & storage,
  87. PStorageObject& obj,
  88. WORKID objectid,
  89. PStorage::EOpenMode mode,
  90. XPtr<PMmStream> & stream )
  91. : CPhysStorage( storage,
  92. obj,
  93. objectid,
  94. stream.Acquire(),
  95. mode,
  96. FALSE )
  97. {
  98. }
  99. //+-------------------------------------------------------------------------
  100. //
  101. // Method: CPhysIndex::CPhysIndex
  102. //
  103. // Synopsis: Ctor for new writeable index
  104. //
  105. // History: 17-Feb-1994 KyleP Created
  106. //
  107. //--------------------------------------------------------------------------
  108. inline CPhysIndex::CPhysIndex( PStorage & storage,
  109. PStorageObject & obj,
  110. WORKID objectid,
  111. unsigned cpageReqSize,
  112. XPtr<PMmStream> & stream )
  113. : CPhysStorage( storage,
  114. obj,
  115. objectid,
  116. cpageReqSize,
  117. stream.Acquire(),
  118. FALSE )
  119. {
  120. }
  121. //+---------------------------------------------------------------------------
  122. //
  123. // Function: CPhysIndex::CPhysIndex
  124. //
  125. // Synopsis: Clones an existing CPhysIndex by duplicating the stream.
  126. // This is used during master merge to have a separate
  127. // CPhysIndex for queries and the merge process.
  128. //
  129. // Arguments: [readIndex] -- An existing index.
  130. // [mode] -- Mode in which to open.
  131. //
  132. // History: 8-23-94 srikants Created
  133. //
  134. // Notes:
  135. //
  136. //----------------------------------------------------------------------------
  137. inline CPhysIndex::CPhysIndex( CPhysIndex & readIndex,
  138. PStorage::EOpenMode mode,
  139. XPtr<PMmStream> & stream )
  140. : CPhysStorage( readIndex._storage,
  141. readIndex._obj,
  142. readIndex.ObjectId(),
  143. stream.Acquire(),
  144. mode,
  145. FALSE )
  146. {
  147. Win4Assert( PStorage::eOpenForWrite == mode );
  148. }
  149. //+-------------------------------------------------------------------------
  150. //
  151. // Method: CPhysHash::CPhysHash
  152. //
  153. // Synopsis: Ctor for an existing hash stream.
  154. //
  155. // History: 17-Feb-1994 KyleP Created
  156. // 20-Apr-1994 Srikants Optionally open in write mode.
  157. //
  158. //--------------------------------------------------------------------------
  159. inline CPhysHash::CPhysHash( PStorage & storage,
  160. PStorageObject& obj,
  161. WORKID objectid,
  162. PStorage::EOpenMode mode,
  163. XPtr<PMmStream> & stream )
  164. : CPhysStorage( storage,
  165. obj,
  166. objectid,
  167. stream.Acquire(),
  168. mode,
  169. FALSE )
  170. {
  171. }
  172. //+-------------------------------------------------------------------------
  173. //
  174. // Method: CPhysHash::CPhysHash
  175. //
  176. // Synopsis: Ctor for a new writeable hash
  177. //
  178. // History: 17-Feb-1994 KyleP Created
  179. //
  180. //--------------------------------------------------------------------------
  181. inline CPhysHash::CPhysHash( PStorage & storage,
  182. PStorageObject & obj,
  183. WORKID objectid,
  184. unsigned cpageReqSize,
  185. XPtr<PMmStream> & stream )
  186. : CPhysStorage( storage,
  187. obj,
  188. objectid,
  189. cpageReqSize,
  190. stream.Acquire(),
  191. FALSE )
  192. {
  193. }