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.

249 lines
6.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: IDXIDS.HXX
  7. //
  8. // Contents: Index ID's
  9. //
  10. // Classes: CIndexID, CIndexIdList
  11. //
  12. // History: 29-Mar-91 BartoszM Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #ifdef DISPLAY_INCLUDES
  17. #pragma message( "#include <" __FILE__ ">..." )
  18. #endif
  19. #define MAX_PERS_ID 0xff
  20. #define MAX_PART_ID 0xfffe
  21. #define MAX_VOL_ID 0xffff
  22. const INDEXID iidDeleted1 = 0xffff00ff;
  23. const INDEXID iidDeleted2 = 0xffff00fe;
  24. const INDEXID iidInvalid = 0;
  25. //+---------------------------------------------------------------------------
  26. //
  27. // Class: CIndexId
  28. //
  29. // Purpose: Bit field for index id
  30. //
  31. // Interface:
  32. //
  33. // History: 3-Apr-91 BartoszM Created.
  34. //
  35. // Notes: Persistent index id contains one byte per partition ID
  36. // Volatile index id uses two bytes for per partition ID.
  37. // Both contain two byte partition ID
  38. //
  39. // volatile: | part ID | volat ID > 256 |
  40. //
  41. // persistent: | part ID | zero | pers ID|
  42. //
  43. // invalid: | part ID | zero | (is persistent)
  44. //
  45. // deleted: | ffff | zero | ff | (is persistent)
  46. //
  47. //----------------------------------------------------------------------------
  48. class CIndexId
  49. {
  50. public:
  51. inline CIndexId ( ULONG l = 0L );
  52. inline CIndexId ( ULONG iid, PARTITIONID pid );
  53. inline operator INDEXID () { return *( INDEXID* ) this; }
  54. inline BOOL IsPersistent();
  55. inline PARTITIONID PartId ();
  56. inline BYTE PersId ();
  57. private:
  58. ULONG _pers_id:8; // persistent index ID
  59. ULONG _vol_id:8; // high byte of volatile index ID
  60. ULONG _part_id:16; // partition ID
  61. };
  62. //+---------------------------------------------------------------------------
  63. //
  64. // Member: CIndexId::CIndexId, public
  65. //
  66. // Arguments: [iid] -- short index ID
  67. // [pid] -- partition ID
  68. //
  69. // History: 4-Apr-91 BartoszM Created.
  70. //
  71. //----------------------------------------------------------------------------
  72. inline CIndexId::CIndexId ( ULONG iid, PARTITIONID pid )
  73. {
  74. _part_id = (USHORT) pid;
  75. if ( iid > MAX_PERS_ID )
  76. {
  77. _pers_id = (BYTE)iid;
  78. _vol_id = (BYTE)( iid >> 8);
  79. }
  80. else
  81. {
  82. _pers_id = (BYTE)iid;
  83. _vol_id = 0;
  84. }
  85. }
  86. //+---------------------------------------------------------------------------
  87. //
  88. // Member: CIndexId::CIndexId, public
  89. //
  90. // Arguments: [l] -- another index ID
  91. //
  92. // History: 4-Apr-91 BartoszM Created.
  93. //
  94. //----------------------------------------------------------------------------
  95. inline CIndexId::CIndexId ( ULONG l )
  96. {
  97. ciAssert ( sizeof(CIndexId) == sizeof ( ULONG ) );
  98. *( ULONG*) this = l;
  99. }
  100. //+---------------------------------------------------------------------------
  101. //
  102. // Member: CIndexId::IsPersistent, public
  103. //
  104. // Returns: TRUE if persistent index ID, FALSE otherwise
  105. //
  106. // History: 4-Apr-91 BartoszM Created.
  107. //
  108. //----------------------------------------------------------------------------
  109. inline BOOL CIndexId::IsPersistent()
  110. {
  111. return _vol_id == 0;
  112. }
  113. //+---------------------------------------------------------------------------
  114. //
  115. // Member: CIndexId::PartId, public
  116. //
  117. // Returns: Partition ID encoded in index ID
  118. //
  119. // History: 4-Apr-91 BartoszM Created.
  120. //
  121. //----------------------------------------------------------------------------
  122. inline PARTITIONID CIndexId::PartId()
  123. {
  124. return (PARTITIONID)_part_id;
  125. }
  126. //+---------------------------------------------------------------------------
  127. //
  128. // Member: CIndexId::PersId, public
  129. //
  130. // Returns: Persistent index ID (per partition unique)
  131. //
  132. // History: 4-Apr-91 BartoszM Created.
  133. //
  134. //----------------------------------------------------------------------------
  135. inline BYTE CIndexId::PersId()
  136. {
  137. return (BYTE)_pers_id;
  138. }
  139. #if 0
  140. //+---------------------------------------------------------------------------
  141. //
  142. // Class: CIndexIdList
  143. //
  144. // Purpose: Array of index id's
  145. //
  146. // History: 29-Mar-91 BartoszM Created.
  147. //
  148. // Notes: Auxiliary data structure passed between partition table
  149. // and partition. Contains a counted array of byte sized
  150. // short index id's (per partition unique).
  151. //
  152. //----------------------------------------------------------------------------
  153. #define MAX_BIN_SIZE 255
  154. class CIndexIdList
  155. {
  156. friend class CPartList;
  157. public:
  158. int Count() const { return _count; }
  159. INDEXID GetNext( PARTITIONID pid );
  160. private:
  161. CIndexIdList (): _cur (0) {}
  162. BYTE* GetBuf() { return (BYTE*)_ids; }
  163. void SetCount ( int c ) { _count = c; }
  164. int _cur;
  165. int _count;
  166. BYTE _ids[MAX_BIN_SIZE];
  167. };
  168. //+---------------------------------------------------------------------------
  169. //
  170. // Member: CIndextIdList::GetNext(), public
  171. //
  172. // Synopsis: Gets next index ID.
  173. //
  174. // Arguments: [pid] -- partition ID
  175. //
  176. // History: 1-Apr-91 BartoszM Created.
  177. //
  178. //----------------------------------------------------------------------------
  179. inline INDEXID CIndexIdList::GetNext( PARTITIONID pid )
  180. {
  181. return CIndexId (_ids[_cur++], pid );
  182. }
  183. #endif // 0
  184. //+---------------------------------------------------------------------------
  185. //
  186. // Class: CDeletedIndex
  187. //
  188. // Purpose: Keeps track of which index is the current deleted index
  189. //
  190. // History: 12-jul-94 DwightKr Created
  191. //
  192. //----------------------------------------------------------------------------
  193. class CDeletedIndex
  194. {
  195. public:
  196. CDeletedIndex( INDEXID iid ) : _iid(iid) {}
  197. void SwapIndex()
  198. {
  199. _iid = GetNewIndex();
  200. }
  201. const INDEXID GetIndex() const { return _iid; }
  202. const INDEXID GetNewIndex() const
  203. {
  204. if ( _iid == iidDeleted1 )
  205. return iidDeleted2;
  206. else
  207. return iidDeleted1;
  208. }
  209. private:
  210. INDEXID _iid;
  211. };