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.

249 lines
7.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 2000.
  5. //
  6. // File: DREP.HXX
  7. //
  8. // Contents: Data Repository
  9. //
  10. // Classes: CDataRepository
  11. //
  12. // History: 17-Apr-91 BartoszM Created.
  13. //
  14. //-----------------------------------------------------------------------------
  15. #pragma once
  16. #include <plang.hxx>
  17. #include <occarray.hxx>
  18. #include <norm.hxx>
  19. #include <keymak.hxx>
  20. class CFullPropSpec;
  21. class CWordList;
  22. class CLangList;
  23. class CValueNormalizer;
  24. class CPidMapper;
  25. //+---------------------------------------------------------------------------
  26. //
  27. // Class: CCumulTimer
  28. //
  29. // Purpose: Cumulative timing for debugging
  30. //
  31. // History: 07-Dec-93 BartoszM Created
  32. //
  33. //----------------------------------------------------------------------------
  34. #if CIDBG == 1
  35. class CCumulTimer
  36. {
  37. public:
  38. CCumulTimer ( WCHAR* szActivity )
  39. :_szActivity ( szActivity ), _count(0), _totalTime(0)
  40. {
  41. END_CONSTRUCTION ( CCumulTimer );
  42. }
  43. ~CCumulTimer();
  44. void Start()
  45. {
  46. _startTime = GetTickCount();
  47. }
  48. void Stop ()
  49. {
  50. ULONG stopTime = GetTickCount();
  51. _totalTime += stopTime - _startTime;
  52. _count++;
  53. }
  54. private:
  55. ULONG _startTime;
  56. ULONG _totalTime;
  57. ULONG _count;
  58. WCHAR* _szActivity;
  59. };
  60. #endif // CIDBG
  61. // Macros to be used with the timer
  62. #if CIDBG == 1
  63. #define TSTART(timer) timer.Start()
  64. #define TSTOP(timer) timer.Stop()
  65. #else
  66. #define TSTART(timer)
  67. #define TSTOP(timer)
  68. #endif
  69. //+---------------------------------------------------------------------------
  70. //
  71. // Class: CDataRepository
  72. //
  73. // Purpose: Data repository for filter
  74. //
  75. // History: 7-Apr-91 BartoszM Created
  76. // 30-May-91 t-WadeR Changed to be input-driven
  77. // 01-July-91 t-WadeR Added _fIgnore
  78. // 18-Sep-92 AmyA Added PutObject
  79. // 23-Sep-92 AmyA Overloaded PutPhrase
  80. // 20-Oct-92 AmyA Changed PutWord to Unicode
  81. // 04-Feb-93 KyleP Use LARGE_INTEGER
  82. // 21-Oct-93 DwightKr Added new methods; made PutPropID
  83. // public
  84. //
  85. // Notes: Data Repository is a sink for data in the form
  86. // of streams, phrases, words, numbers, and dates.
  87. // Data is processed internally and it ends up
  88. // in the key repository in the form of normalized
  89. // keys. Internal processing is done in two pipelines:
  90. // some data goes to the language dependednt key maker,
  91. // some (date, number) to the language independent
  92. // value normalizer. The language dependent key maker
  93. // may dynamically change when PutLanguage is called.
  94. // Both key makers are initialized with the key
  95. // repository as their key sink.
  96. //
  97. //----------------------------------------------------------------------------
  98. class CDataRepository
  99. {
  100. public:
  101. CDataRepository ( PKeyRepository& krep, IPhraseSink* pPhraseSink,
  102. BOOL fQuery, ULONG fuzzy, CPidMapper & pidMap,
  103. CLangList & langList);
  104. void PutStream ( TEXT_SOURCE * stm );
  105. void PutPhrase ( const WCHAR* str, unsigned cwc );
  106. void PutPhrase ( const char* str, unsigned cc );
  107. BOOL PutLanguage ( LCID lcid );
  108. BOOL PutPropName ( CFullPropSpec const & Prop );
  109. void PutValue ( CStorageVariant const & var );
  110. inline BOOL StoreValue ( CFullPropSpec const & ps, CStorageVariant const & var );
  111. inline BOOL StoreSecurity ( PSECURITY_DESCRIPTOR pSD, ULONG cbSD );
  112. inline void PutWorkId ( WORKID wid );
  113. inline const ULONG GetFilteredBlockCount() const { return _krep.GetFilteredBlockCount(); }
  114. void InitFilteredBlockCount( ULONG ulMaxFilteredBlocks ) { _krep.InitFilteredBlockCount( ulMaxFilteredBlocks ); }
  115. BOOL ContainedNoiseWords();
  116. inline PROPID GetPropId ( ) const { return _pid; }
  117. void NormalizeWStr( BYTE *pbOutBuf, unsigned *pcbOutBuf );
  118. private:
  119. BOOL PutPropId( PROPID pid );
  120. BOOL LoadKeyMaker();
  121. // Two key makers
  122. XPtr<CKeyMaker> _xKeyMaker;
  123. CValueNormalizer _valueNorm; // never changes
  124. // Sink for keys
  125. PKeyRepository& _krep;
  126. // Pidmapper for pids
  127. CPidMapper & _pidMap;
  128. // Sink for phrases
  129. IPhraseSink* _pPhraseSink;
  130. // Source of key makers
  131. WORKID _wid;
  132. PROPID _pid; // Current property
  133. PROPID _prevPid; // PROPID of previous _xKeyMaker
  134. CSparseOccArray _occArray;
  135. BOOL _fQuery;
  136. ULONG _ulGenerateMethod;
  137. LCID _lcid; // Current locale
  138. LCID _prevLcid; // Locale of previous _xKeyMaker
  139. LCID _lcidSystemDefault; // Default locale of system
  140. ULONG _ulCodePage; // Codepage of current locale
  141. CLangList & _langList;
  142. #if CIDBG == 1
  143. public:
  144. CCumulTimer timerBind;
  145. CCumulTimer timerNoBind;
  146. CCumulTimer timerFilter;
  147. #endif
  148. unsigned _cwcFoldedPhrase;
  149. XArray<WCHAR> _xwcsFoldedPhrase;
  150. };
  151. //+---------------------------------------------------------------------------
  152. //
  153. // Member: CDataRepository::PutWorkId
  154. //
  155. // Synopsis: Sets work id
  156. //
  157. // Arguments: [wid] -- work id
  158. //
  159. // History: 18-Apr-91 BartoszM Created
  160. //
  161. //----------------------------------------------------------------------------
  162. inline void CDataRepository::PutWorkId ( WORKID wid )
  163. {
  164. _wid = wid;
  165. _occArray.ReInitialize();
  166. _krep.PutWorkId( wid );
  167. }
  168. //+---------------------------------------------------------------------------
  169. //
  170. // Member: CDataRepository::StoreValue
  171. //
  172. // Synopsis: Store a property value.
  173. //
  174. // Arguments: [prop] -- Property descriptor
  175. // [var] -- Value
  176. //
  177. // History: 21-Dec-95 KyleP Created
  178. //
  179. //----------------------------------------------------------------------------
  180. inline BOOL CDataRepository::StoreValue( CFullPropSpec const & ps,
  181. CStorageVariant const & var )
  182. {
  183. return _krep.StoreValue( ps, var );
  184. }
  185. //+---------------------------------------------------------------------------
  186. //
  187. // Member: CDataRepository::StoreSecurity
  188. //
  189. // Synopsis: Store a security identifier
  190. //
  191. // Arguments: [pSD] -- Security descriptor
  192. // [cbSD] -- size in bytes of pSD
  193. //
  194. // Notes: Effective for the down-level CI only.
  195. //
  196. // History: 06 Feb 96 AlanW Created
  197. //
  198. //----------------------------------------------------------------------------
  199. inline BOOL CDataRepository::StoreSecurity( PSECURITY_DESCRIPTOR pSD, ULONG cbSD )
  200. {
  201. return _krep.StoreSecurity( pSD, cbSD );
  202. }