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.

157 lines
2.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1992.
  5. //
  6. // File: INDSNAP.HXX
  7. //
  8. // Contents: Array of Indexes
  9. //
  10. // Classes: CIndexSnapshot
  11. //
  12. // History: 28-Apr-92 BartoszM Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include <curstk.hxx>
  17. #include "index.hxx"
  18. #include "mmerglog.hxx"
  19. enum MergeType
  20. {
  21. mtMaster,
  22. mtShadow,
  23. mtWordlist,
  24. mtAnnealing,
  25. mtIncrBackup,
  26. mtDeletes
  27. };
  28. class CPartition;
  29. class CResManager;
  30. class CFreshTest;
  31. class CKeyCursor;
  32. class CIndexSnapshot
  33. {
  34. public:
  35. CIndexSnapshot (CResManager& resman);
  36. CIndexSnapshot (CIndexSnapshot& src );
  37. ~CIndexSnapshot ();
  38. void LokInit( CPartition& part, MergeType mt );
  39. void LokInitForBackup( CPartition & part, BOOL fFull );
  40. void LokRestart( CPartition & part, PRcovStorageObj & mMergeLog );
  41. void Init( unsigned cPart, PARTITIONID* aPartId, ULONG cPendingUpdates, ULONG* pFlags );
  42. CKeyCursor* QueryMergeCursor(const CKey * pKey = 0);
  43. void AppendPendingUpdates( XCursor & cur );
  44. CIndex* Get ( unsigned i )
  45. {
  46. ciAssert(i < _cInd );
  47. return(_apIndex[i]);
  48. }
  49. INDEXID GetId ( unsigned i ) const
  50. {
  51. ciAssert ( i < _cInd );
  52. return(_apIndex[i]->GetId());
  53. }
  54. USN GetUsn ( unsigned i ) const
  55. {
  56. ciAssert ( i < _cInd );
  57. return(_apIndex[i]->Usn());
  58. }
  59. WORKID MaxWorkId();
  60. unsigned TotalSizeInPages();
  61. CFreshTest* GetFresh()
  62. {
  63. return(_pFreshTest);
  64. }
  65. unsigned Count() const
  66. {
  67. return(_cInd);
  68. }
  69. CIndex ** LokGiveIndexes( unsigned & cInd );
  70. void LokTakeIndexes( CIndexSnapshot & src );
  71. void LokInitFreshTest();
  72. void SetFreshTest( CFreshTest * pFreshTest )
  73. {
  74. Win4Assert( 0 == _pFreshTest );
  75. _pFreshTest = pFreshTest;
  76. }
  77. void ResetFreshTest()
  78. {
  79. _pFreshTest = 0;
  80. }
  81. CIndex ** LokGetIndexes( unsigned & cind )
  82. {
  83. cind = _cInd;
  84. return _apIndex;
  85. }
  86. private:
  87. CFreshTest* _pFreshTest;
  88. CIndex** _apIndex;
  89. unsigned _cInd;
  90. CCurStack _curPending; // For pending updates
  91. CResManager& _resman;
  92. };
  93. class SIndexSnapshot
  94. {
  95. public:
  96. SIndexSnapshot( CIndexSnapshot * pIndSnap ) : _pIndSnap(pIndSnap)
  97. {
  98. END_CONSTRUCTION( SIndexSnapshot );
  99. }
  100. ~SIndexSnapshot()
  101. {
  102. delete _pIndSnap;
  103. }
  104. CIndexSnapshot* operator->() { return _pIndSnap; }
  105. CIndexSnapshot& operator*() { return *_pIndSnap; }
  106. CIndexSnapshot * Acquire()
  107. {
  108. CIndexSnapshot *pTemp = _pIndSnap;
  109. _pIndSnap = 0;
  110. return(pTemp);
  111. }
  112. BOOL operator !() { return 0 == _pIndSnap; }
  113. private:
  114. CIndexSnapshot * _pIndSnap;
  115. };