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.

294 lines
7.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1992.
  5. //
  6. // File: index.hxx
  7. //
  8. // Contents: Internal classes related to index manipulation
  9. //
  10. // Classes: CIndex
  11. //
  12. // History: 06-Mar-91 KyleP Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #ifdef DISPLAY_INCLUDES
  17. #pragma message( "#include <" __FILE__ ">..." )
  18. #endif
  19. #include <keycur.hxx>
  20. #include <idxids.hxx>
  21. #include <querble.hxx>
  22. //+---------------------------------------------------------------------------
  23. //
  24. // Class: CIndex (ind)
  25. //
  26. // Purpose: Pure virtual class for all indexes (wordlist, shadow, master)
  27. //
  28. // Interface: Init - Initialize index.
  29. // QueryCursor - Obtain a cursor into the index
  30. //
  31. // History: 06-Mar-91 KyleP Created.
  32. // 30-Sep-91 BartoszM Added range cursor
  33. // 31-Jan-92 AmyA Added synonym cursor
  34. //
  35. // Notes:
  36. //
  37. //----------------------------------------------------------------------------
  38. class CKeyCursor;
  39. class CKeyArray;
  40. class CIndexSnapshot;
  41. class CWKeyList;
  42. class PStorage;
  43. class PSaveProgressTracker;
  44. const LONGLONG eSigIndex = 0x2020205845444e49i64; // "INDEX"
  45. class CIndex: INHERIT_VIRTUAL_UNWIND, public CDoubleLink, public CQueriable
  46. {
  47. public:
  48. virtual ~CIndex();
  49. virtual unsigned Size() const = 0;
  50. virtual void Remove () = 0;
  51. virtual void Reference();
  52. virtual void Release ();
  53. BOOL InUse () const;
  54. void Zombify ();
  55. BOOL IsZombie() const;
  56. INDEXID GetId () const;
  57. void SetId ( INDEXID iid ) { _id = iid; }
  58. BOOL IsMaster () const { return _isMaster; }
  59. void MakeMaster () { _isMaster = TRUE; }
  60. void MakeShadow () { _isMaster = FALSE; }
  61. virtual WORKID MaxWorkId () const { return _widMax; }
  62. BOOL IsPersistent() const { return CIndexId(_id).IsPersistent();}
  63. BOOL IsWordlist() const { return !IsPersistent();}
  64. virtual BOOL IsMasterMergeIndex() const { return FALSE; }
  65. void SetUsn( USN usn ) { _usn = usn; }
  66. USN Usn() const { return _usn; }
  67. BOOL InMasterMerge() const { return _inMasterMerge; }
  68. void SetInMasterMerge()
  69. {
  70. Win4Assert( !_inMasterMerge );
  71. _inMasterMerge = TRUE;
  72. }
  73. virtual CKeyCursor* QueryCursor() = 0;
  74. virtual CKeyCursor* QueryKeyCursor(const CKey * pKey) { return 0; }
  75. virtual void DebugDump(FILE *pfOut, ULONG fSummaryOnly );
  76. virtual void MakeBackupCopy( PStorage & storage,
  77. WORKID wid,
  78. PSaveProgressTracker & tracker )
  79. {
  80. Win4Assert( !"Must not be called" );
  81. }
  82. #ifdef CIEXTMODE
  83. void CiExtDump(void *ciExtSelf);
  84. #endif
  85. protected:
  86. CIndex ();
  87. CIndex ( INDEXID id );
  88. CIndex ( INDEXID id, WORKID widMax, BOOL isMaster );
  89. virtual void SetMaxWorkId ( WORKID widMax )
  90. {
  91. _widMax = widMax;
  92. ciDebugOut (( DEB_ITRACE, "SetWidMax %ld\n", _widMax ));
  93. }
  94. const LONGLONG _sigIndex;
  95. unsigned _refCount;
  96. INDEXID _id;
  97. USN _usn;
  98. WORKID _widMax;
  99. BOOL _zombie;
  100. BOOL _isMaster;
  101. BOOL _inMasterMerge;
  102. };
  103. //+---------------------------------------------------------------------------
  104. //
  105. // Member: CIndex::CIndex, protected
  106. //
  107. // History: 08-Oct-91 BartoszM Created.
  108. //
  109. //----------------------------------------------------------------------------
  110. inline CIndex::CIndex ()
  111. :
  112. _sigIndex(eSigIndex),
  113. _id(0),
  114. _refCount(0),
  115. _zombie ( FALSE ),
  116. _isMaster ( FALSE ),
  117. _widMax (0),
  118. _inMasterMerge(FALSE)
  119. {}
  120. //+---------------------------------------------------------------------------
  121. //
  122. // Member: CIndex::CIndex, protected
  123. //
  124. // History: 08-Oct-91 BartoszM Created.
  125. //
  126. //----------------------------------------------------------------------------
  127. inline CIndex::CIndex ( INDEXID id, WORKID widMax, BOOL isMaster )
  128. :
  129. _sigIndex(eSigIndex),
  130. _id(id),
  131. _refCount(0),
  132. _zombie (FALSE),
  133. _isMaster(isMaster),
  134. _widMax(widMax),
  135. _inMasterMerge(FALSE)
  136. {}
  137. //+---------------------------------------------------------------------------
  138. //
  139. // Member: CIndex::CIndex, protected
  140. //
  141. // History: 08-Oct-91 BartoszM Created.
  142. //
  143. //----------------------------------------------------------------------------
  144. inline CIndex::CIndex ( INDEXID id )
  145. :
  146. _sigIndex(eSigIndex),
  147. _id(id),
  148. _refCount(0),
  149. _zombie (FALSE),
  150. _isMaster(FALSE),
  151. _widMax(0),
  152. _inMasterMerge(FALSE)
  153. {}
  154. //+---------------------------------------------------------------------------
  155. //
  156. // Member: CIndex::~CIndex, public
  157. //
  158. // History: 08-Oct-91 BartoszM Created.
  159. //
  160. //----------------------------------------------------------------------------
  161. inline CIndex::~CIndex()
  162. {
  163. ciDebugOut (( DEB_ITRACE, "\t\tDeleting index %lx\n", GetId()));
  164. }
  165. //+---------------------------------------------------------------------------
  166. //
  167. // Member: CIndex::GetId, public
  168. //
  169. // History: 08-Oct-91 BartoszM Created.
  170. //
  171. //----------------------------------------------------------------------------
  172. inline INDEXID CIndex::GetId () const
  173. {
  174. return _id;
  175. }
  176. //+---------------------------------------------------------------------------
  177. //
  178. // Member: CIndex::IsDeleted, public
  179. //
  180. // History: 08-Oct-91 BartoszM Created.
  181. //
  182. //----------------------------------------------------------------------------
  183. inline BOOL CIndex::IsZombie() const
  184. {
  185. return _zombie;
  186. }
  187. //+---------------------------------------------------------------------------
  188. //
  189. // Member: CIndex::Reference, public
  190. //
  191. // History: 08-Oct-91 BartoszM Created.
  192. //
  193. //----------------------------------------------------------------------------
  194. inline void CIndex::Reference()
  195. {
  196. _refCount++;
  197. }
  198. //+---------------------------------------------------------------------------
  199. //
  200. // Member: CIndex::Release, public
  201. //
  202. // History: 08-Oct-91 BartoszM Created.
  203. //
  204. //----------------------------------------------------------------------------
  205. inline void CIndex::Release ()
  206. {
  207. ciDebugOut (( DEB_ITRACE, "\trelease %lx\n", _id ));
  208. Win4Assert( _refCount > 0 );
  209. _refCount--;
  210. }
  211. //+---------------------------------------------------------------------------
  212. //
  213. // Member: CIndex::InUse, public
  214. //
  215. // History: 08-Oct-91 BartoszM Created.
  216. //
  217. //----------------------------------------------------------------------------
  218. inline BOOL CIndex::InUse () const
  219. {
  220. return _refCount != 0;
  221. }
  222. //+---------------------------------------------------------------------------
  223. //
  224. // Member: CIndex::Delete, public
  225. //
  226. // History: 08-Oct-91 BartoszM Created.
  227. //
  228. //----------------------------------------------------------------------------
  229. inline void CIndex::Zombify ()
  230. {
  231. _zombie = TRUE;
  232. }