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.

228 lines
6.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1994-1994, Microsoft Corporation.
  4. //
  5. // File: regtrans.hxx
  6. //
  7. // Contents: Watch region transformer
  8. //
  9. // Classes: CRegionTransformer
  10. //
  11. // History: 20-Jul-95 BartoszM Created
  12. //
  13. //----------------------------------------------------------------------------
  14. #pragma once
  15. //+-------------------------------------------------------------------------
  16. //
  17. // Class: CRegionTransformer
  18. //
  19. // Purpose: Transforms old watch region into new watch region
  20. //
  21. // History: 20-Jul-95 BartoszM Created
  22. //
  23. //--------------------------------------------------------------------------
  24. class CWatchRegion;
  25. class CTableSegment;
  26. class CTableSegList;
  27. class CWatchList;
  28. class CFwdTableSegIter;
  29. class CTableRowLocator;
  30. const LONGLONG eSigRegTrans = 0x534E415254474552i64; // "REGTRANS"
  31. class CRegionTransformer
  32. {
  33. public:
  34. CRegionTransformer (CWatchRegion* pRegion,
  35. DBROWCOUNT offFetch,
  36. ULONG_PTR cFetch,
  37. BOOL fFwdFetch)
  38. : _sigRegTrans(eSigRegTrans),
  39. _iWatch (0),
  40. _cWatch(-1),
  41. _pRegion (pRegion),
  42. _iFetchBmk (0),
  43. _iFetch(-1),
  44. _offFetch (offFetch),
  45. _cFetch (cFetch),
  46. _fFwdFetch(fFwdFetch),
  47. _pSegmentBookmark (0),
  48. _iWatchNew (0),
  49. _cWatchNew (0),
  50. _isContiguous (FALSE),
  51. _isExtendForward (FALSE),
  52. _isExtendBackward (FALSE),
  53. _pSegmentLowFetch(0),
  54. _offLowFetchInSegment(-1)
  55. {
  56. }
  57. void SetWatchPos (DBROWCOUNT iWatch) { _iWatch = iWatch; }
  58. void SetFetchBmkPos (DBROWCOUNT iFetchBmk) { _iFetchBmk = iFetchBmk; }
  59. void SetFetchBmkSegment (CTableSegment* pSeg) { _pSegmentBookmark = pSeg; }
  60. void SetFetchRowPosFromBmk(DBROWCOUNT iFetch) { _iFetch = iFetch; }
  61. void SetLowFetchPos(CTableSegment* pSegmentLowFetch, DBROWCOUNT iLowFetchRowInSeg)
  62. {
  63. _pSegmentLowFetch = pSegmentLowFetch;
  64. _offLowFetchInSegment = iLowFetchRowInSeg;
  65. }
  66. BOOL IsContiguous() const { return _isContiguous; }
  67. BOOL IsExtendForward () const { return _isExtendForward; }
  68. BOOL IsExtendBackward () const { return _isExtendBackward; }
  69. CWatchRegion* Region () { return _pRegion; }
  70. BOOL Validate ();
  71. void Transform (CTableSegList& segList, CWatchList& watchList);
  72. DBROWCOUNT GetFetchOffsetFromAnchor() const { return _offFetch; }
  73. DBROWCOUNT GetFetchOffsetFromOrigin() const { return _iFetch; }
  74. void AddToWatchPos(DBROWCOUNT cDelta);
  75. void MoveOrigin( DBROWCOUNT cDelta );
  76. DBROWCOUNT GetFetchCount () const { return _cFetch; }
  77. BOOL GetFwdFetch() { return _fFwdFetch; }
  78. void DecrementFetchCount( CTableRowLocator & rowLocator,
  79. CFwdTableSegIter &iter,
  80. CTableSegList & list );
  81. BOOL HasOldRegion (DBROWCOUNT iWindow, DBROWCOUNT cWindow) const
  82. {
  83. return !(iWindow + cWindow <= _iWatch || iWindow >= _iWatch + _cWatch);
  84. }
  85. BOOL HasNewRegion (DBROWCOUNT iWindow, DBROWCOUNT cWindow) const
  86. {
  87. return !(iWindow + cWindow <= _iWatchNew || iWindow >= _iWatchNew + _cWatchNew);
  88. }
  89. BOOL HasEndOldRegion (DBROWCOUNT iWindow, DBROWCOUNT cWindow) const
  90. {
  91. return _iWatch + _cWatch > iWindow && _iWatch + _cWatch <= iWindow + cWindow;
  92. }
  93. BOOL HasEndNewRegion (DBROWCOUNT iWindow, DBROWCOUNT cWindow) const
  94. {
  95. return _iWatchNew + _cWatchNew > iWindow && _iWatchNew + _cWatchNew <= iWindow + cWindow;
  96. }
  97. inline void DumpState();
  98. BOOL IsWatched() const { return 0 != _pRegion; }
  99. #ifdef CIEXTMODE
  100. void CiExtDump(void *ciExtSelf);
  101. #endif
  102. private:
  103. BOOL ValidateMove ();
  104. BOOL ValidateExtend();
  105. //-----------------------------------------------
  106. // This MUST be the first variable in this class.
  107. //-----------------------------------------------
  108. const LONGLONG _sigRegTrans;
  109. // Watch region parameters
  110. DBROWCOUNT _iWatch;
  111. DBROWCOUNT _cWatch;
  112. CWatchRegion* _pRegion;
  113. // Fetch region parameters
  114. DBROWCOUNT _iFetchBmk;
  115. DBROWCOUNT _iFetch;
  116. DBROWCOUNT _offFetch;
  117. DBROWCOUNT _cFetch;
  118. BOOL _fFwdFetch; // Is direction of fetching rows forward ?
  119. CTableSegment* _pSegmentBookmark;
  120. // Properties of the transformation
  121. DBROWCOUNT _iWatchNew;
  122. DBROWCOUNT _cWatchNew;
  123. BOOL _isContiguous;
  124. BOOL _isExtendForward;
  125. BOOL _isExtendBackward;
  126. // lowest position in the fetch set
  127. CTableSegment* _pSegmentLowFetch;
  128. DBROWCOUNT _offLowFetchInSegment;
  129. };
  130. //+---------------------------------------------------------------------------
  131. //
  132. // Member: CRegionTransformer::AddToWatchPos
  133. //
  134. // Synopsis: For backward fetches, it adds to the relative position of
  135. // the watch position. _iWatch must always be WRT to the
  136. // beginning of the lowest fetch segment.
  137. //
  138. // Arguments: [cDelta] -
  139. //
  140. // History: 8-08-95 srikants Created
  141. //
  142. // Notes:
  143. //
  144. //----------------------------------------------------------------------------
  145. inline void CRegionTransformer::AddToWatchPos( DBROWCOUNT cDelta )
  146. {
  147. Win4Assert( cDelta >= 0 );
  148. Win4Assert( _iWatch >= 0 );
  149. tbDebugOut(( DEB_REGTRANS,
  150. "CRegTransformer::AddToWatchPos - _iWatch %ld _iWatchNew %ld cDelta %ld\n",
  151. _iWatch, _iWatchNew, cDelta ));
  152. _iWatch += cDelta;
  153. _iWatchNew += cDelta;
  154. }
  155. #if CIDBG==1
  156. inline void CRegionTransformer::DumpState()
  157. {
  158. tbDebugOut(( DEB_REGTRANS,
  159. "CRegionTransformer = 0x%X\n", this ));
  160. tbDebugOut(( DEB_REGTRANS | DEB_NOCOMPNAME,
  161. " _iWatch=%d \t\t_cWatch=%d\n", _iWatch, _cWatch ));
  162. tbDebugOut(( DEB_REGTRANS | DEB_NOCOMPNAME,
  163. " _iFetchBmk=%d \t_iFetch=%d \t_offFetch=%d \t_cFetch=%d \n",
  164. _iFetchBmk, _iFetch, _offFetch, _cFetch ));
  165. tbDebugOut(( DEB_REGTRANS | DEB_NOCOMPNAME,
  166. " _iWatchNew=%d \t_cWatchNew=%d \t_isContiguous=%d \n",
  167. _iWatchNew, _cWatchNew, _isContiguous ));
  168. tbDebugOut(( DEB_REGTRANS | DEB_NOCOMPNAME,
  169. " _isExtendForward=%d \t_isExtendBackward=%d\n",
  170. _isExtendForward, _isExtendBackward ));
  171. tbDebugOut(( DEB_REGTRANS | DEB_NOCOMPNAME,
  172. " _pSegmentLowFetch=0x%X \t\t_offLowFetchInSegment=%d\n",
  173. _pSegmentLowFetch, _offLowFetchInSegment ));
  174. }
  175. #else
  176. inline void CRegionTransformer::DumpState()
  177. {
  178. }
  179. #endif // CIDBG=1