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.

184 lines
4.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1998.
  5. //
  6. // File: bmkmap.hxx
  7. //
  8. // Contents: Book Mark Map for mapping from bookmark to table row
  9. //
  10. // Classes: CWidBmkHashEntry
  11. // CBookMarkMap
  12. //
  13. // Functions:
  14. //
  15. // History: 11-22-94 srikants Created
  16. //
  17. //----------------------------------------------------------------------------
  18. #pragma once
  19. #include <twidhash.hxx>
  20. #include <tblalloc.hxx>
  21. class CRowIndex;
  22. //+---------------------------------------------------------------------------
  23. //
  24. // Class: CWidBmkHashEntry
  25. //
  26. // Purpose: A WorkID hash table entry for the value of a bookmark.
  27. //
  28. // History: 09 Nov 1998 AlanW Created from CWidValueHashEntry
  29. //
  30. // Notes:
  31. //
  32. //----------------------------------------------------------------------------
  33. class CWidBmkHashEntry : public CWidHashEntry
  34. {
  35. public:
  36. CWidBmkHashEntry( WORKID wid=widInvalid, TBL_OFF value = 0 )
  37. : CWidHashEntry( wid ), _value(value)
  38. {
  39. }
  40. void SetValue( TBL_OFF value )
  41. {
  42. _value = value;
  43. }
  44. void Get( WORKID & wid, TBL_OFF & value ) const
  45. {
  46. wid = _wid;
  47. value = _value;
  48. }
  49. TBL_OFF Value() const
  50. {
  51. return _value;
  52. }
  53. private:
  54. TBL_OFF _value; // The value for the BookMark (hash Value)
  55. };
  56. //+---------------------------------------------------------------------------
  57. //
  58. // Class: CBookMarkMap
  59. //
  60. // Purpose: Maps a BookMark (WorkId) to a row in the row table and
  61. // a row index.
  62. //
  63. // History: 11-22-94 srikants Created
  64. //
  65. // Notes:
  66. //
  67. //----------------------------------------------------------------------------
  68. class CBookMarkMap
  69. {
  70. public:
  71. CBookMarkMap( CRowIndex & rowIndex ) : _rowIndex(rowIndex) {}
  72. BOOL IsBookMarkPresent( WORKID wid );
  73. void AddBookMark( WORKID wid, TBL_OFF oTableRow );
  74. void AddReplaceBookMark( WORKID wid, TBL_OFF oTableRow );
  75. BOOL FindBookMark( WORKID wid, TBL_OFF & obTableRow, ULONG &riRowIndex );
  76. BOOL FindBookMark( WORKID wid, TBL_OFF & obTableRow );
  77. BOOL DeleteBookMark( WORKID wid );
  78. CRowIndex * GetRowIndex() const { return &_rowIndex; }
  79. void DeleteAllEntries()
  80. {
  81. _widHash.DeleteAllEntries();
  82. }
  83. private:
  84. CRowIndex & _rowIndex;
  85. TWidHashTable<CWidBmkHashEntry> _widHash;
  86. };
  87. //+---------------------------------------------------------------------------
  88. //
  89. // Function: IsBookMarkPresent
  90. //
  91. // Synopsis: Checks if a given book mark is present in the mapping or not.
  92. //
  93. // Arguments: [wid] -- WorkId (BookMark) to check.
  94. //
  95. // Returns: TRUE if found; FALSE o/w
  96. //
  97. // History: 11-23-94 srikants Created
  98. //
  99. // Notes:
  100. //
  101. //----------------------------------------------------------------------------
  102. inline BOOL CBookMarkMap::IsBookMarkPresent( WORKID wid )
  103. {
  104. return _widHash.IsWorkIdPresent( wid );
  105. }
  106. //+---------------------------------------------------------------------------
  107. //
  108. // Function: DeleteBookMark
  109. //
  110. // Synopsis: Deletes an existing book mark mapping.
  111. //
  112. // Arguments: [wid] -- WorkId to delete from the mapping.
  113. //
  114. // History: 11-23-94 srikants Created
  115. //
  116. // Notes:
  117. //
  118. //----------------------------------------------------------------------------
  119. inline BOOL CBookMarkMap::DeleteBookMark( WORKID wid )
  120. {
  121. return _widHash.DeleteWorkId( wid );
  122. }
  123. //+---------------------------------------------------------------------------
  124. //
  125. // Function: FindBookMark
  126. //
  127. // Synopsis: Locates the requested bookmark mapping.
  128. //
  129. // Arguments: [wid] -- WorkId to locate.
  130. // [obTableRow] -- (Output) Offset of the table row in the
  131. // window.
  132. //
  133. // Returns: TRUE if the bookmark was found; FALSE o/w
  134. //
  135. // History: 11-23-94 srikants Created
  136. //
  137. // Notes:
  138. //
  139. //----------------------------------------------------------------------------
  140. inline BOOL CBookMarkMap::FindBookMark( WORKID wid, TBL_OFF & obTableRow )
  141. {
  142. CWidBmkHashEntry entry( wid );
  143. BOOL fFound = _widHash.LookUpWorkId( entry );
  144. obTableRow = entry.Value();
  145. return fFound;
  146. }