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.

216 lines
4.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1998
  5. //
  6. // File: DOCLIST.HXX
  7. //
  8. // Contents: List of documents (wid,usn) pairs
  9. //
  10. // Classes: CDocItem, CDocList
  11. //
  12. // History: 11-Nov-91 BartoszM Created
  13. // 08-Feb-94 DwightKr Added code to keep track of retries
  14. //
  15. //----------------------------------------------------------------------------
  16. #pragma once
  17. #include <pfilter.hxx> // STATUS
  18. struct CDocItem
  19. {
  20. USN usn;
  21. VOLUMEID volumeId;
  22. WORKID wid;
  23. STATUS status;
  24. inline ULONG GetPriQRetries() const
  25. {
  26. return cPriQRetries;
  27. }
  28. inline ULONG GetSecQRetries() const
  29. {
  30. return cSecQRetries;
  31. }
  32. inline void SetPriQRetries( ULONG cPriQRetries )
  33. {
  34. Win4Assert( cPriQRetries <= USHRT_MAX );
  35. this->cPriQRetries = (USHORT)cPriQRetries;
  36. }
  37. inline void SetSecQRetries( ULONG cSecQRetries )
  38. {
  39. Win4Assert( cSecQRetries <= USHRT_MAX );
  40. this->cSecQRetries = (USHORT)cSecQRetries;
  41. }
  42. private:
  43. USHORT cPriQRetries;
  44. USHORT cSecQRetries;
  45. };
  46. //
  47. // The default copy constructor is being used for this class.
  48. //
  49. class CDocList
  50. {
  51. public:
  52. CDocList ();
  53. void LokClear();
  54. unsigned Count() const { return _count; }
  55. void LokSetCount ( unsigned count );
  56. void SetPartId ( PARTITIONID partid ) { _partid = partid; }
  57. WORKID Wid ( unsigned i ) const;
  58. STATUS Status ( unsigned i ) const;
  59. USN Usn(unsigned i) const;
  60. VOLUMEID VolumeId( unsigned i ) const;
  61. PARTITIONID PartId() const { return(_partid); }
  62. ULONG Retries ( unsigned i ) const;
  63. ULONG SecQRetries ( unsigned i ) const;
  64. void Set ( unsigned i,
  65. WORKID wid,
  66. USN usn,
  67. VOLUMEID volId,
  68. STATUS status = PENDING,
  69. ULONG cPriQretries = 1,
  70. ULONG cSecQRetries = 0);
  71. void SetStatus ( unsigned i, STATUS status );
  72. void LokIncrementRetryCount( unsigned i );
  73. void LokIncrementSecQRetryCount( unsigned i );
  74. void LokSortOnWid();
  75. WORKID WidMax() const;
  76. void LokGetWids( XArray<WORKID> & widArray ) const;
  77. private:
  78. unsigned _count;
  79. PARTITIONID _partid;
  80. CDocItem _array[CI_MAX_DOCS_IN_WORDLIST];
  81. };
  82. inline CDocList::CDocList ()
  83. : _count(0), _partid(partidInvalid)
  84. {
  85. }
  86. inline void CDocList::LokClear ()
  87. {
  88. _count = 0;
  89. _partid = partidInvalid;
  90. }
  91. inline void CDocList::LokSetCount ( unsigned count )
  92. {
  93. Win4Assert( count <= CI_MAX_DOCS_IN_WORDLIST );
  94. _count = count;
  95. }
  96. inline WORKID CDocList::Wid ( unsigned i ) const
  97. {
  98. Win4Assert( i < CI_MAX_DOCS_IN_WORDLIST );
  99. return _array[i].wid;
  100. }
  101. inline USN CDocList::Usn ( unsigned i ) const
  102. {
  103. Win4Assert( i < CI_MAX_DOCS_IN_WORDLIST );
  104. return _array[i].usn;
  105. }
  106. inline VOLUMEID CDocList::VolumeId ( unsigned i ) const
  107. {
  108. Win4Assert( i < CI_MAX_DOCS_IN_WORDLIST );
  109. return _array[i].volumeId;
  110. }
  111. inline STATUS CDocList::Status ( unsigned i ) const
  112. {
  113. Win4Assert( i < CI_MAX_DOCS_IN_WORDLIST );
  114. return _array[i].status;
  115. }
  116. inline ULONG CDocList::Retries ( unsigned i ) const
  117. {
  118. Win4Assert( i < CI_MAX_DOCS_IN_WORDLIST );
  119. return _array[i].GetPriQRetries();
  120. }
  121. inline ULONG CDocList::SecQRetries ( unsigned i ) const
  122. {
  123. Win4Assert( i < CI_MAX_DOCS_IN_WORDLIST );
  124. return _array[i].GetSecQRetries();
  125. }
  126. inline void CDocList::Set ( unsigned i,
  127. WORKID wid,
  128. USN usn,
  129. VOLUMEID volId,
  130. STATUS s,
  131. ULONG cPriQRetries,
  132. ULONG cSecQRetries)
  133. {
  134. Win4Assert( i < CI_MAX_DOCS_IN_WORDLIST );
  135. _array[i].wid = wid;
  136. _array[i].usn = usn;
  137. _array[i].volumeId = volId;
  138. _array[i].status = s;
  139. _array[i].SetPriQRetries( cPriQRetries );
  140. _array[i].SetSecQRetries( cSecQRetries );
  141. }
  142. inline void CDocList::SetStatus ( unsigned i, STATUS s )
  143. {
  144. Win4Assert( i < CI_MAX_DOCS_IN_WORDLIST );
  145. _array[i].status = s;
  146. }
  147. inline void CDocList::LokIncrementRetryCount ( unsigned i )
  148. {
  149. Win4Assert( i < CI_MAX_DOCS_IN_WORDLIST );
  150. _array[i].SetPriQRetries (
  151. _array[i].GetPriQRetries() + 1 );
  152. }
  153. inline void CDocList::LokIncrementSecQRetryCount ( unsigned i )
  154. {
  155. Win4Assert( i < CI_MAX_DOCS_IN_WORDLIST );
  156. _array[i].SetSecQRetries (
  157. _array[i].GetSecQRetries() + 1 );
  158. }
  159. inline void CDocList::LokGetWids( XArray<WORKID> & widArray ) const
  160. {
  161. Win4Assert( widArray.Count() == _count );
  162. for ( unsigned i = 0; i < _count; i++ )
  163. {
  164. widArray[i] = _array[i].wid;
  165. }
  166. }