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.

167 lines
5.1 KiB

  1. //+------------------------------------------------------------------
  2. //
  3. // Copyright (C) Microsoft Corporation, 1991 - 1997
  4. //
  5. // File: idxnotif.hxx
  6. //
  7. // Contents: Document notification interfaces
  8. //
  9. // Classes: CIndexNotificationTable
  10. //
  11. // History: 24-Feb-97 SitaramR Created
  12. //
  13. //-------------------------------------------------------------------
  14. #pragma once
  15. #include <ciintf.h>
  16. const NOTIF_HASH_TABLE_SIZE = 97; // Size of hash table for notifications
  17. class CIndexNotificationEntry;
  18. class CCiManager;
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Class: CHashTableEntry
  22. //
  23. // Purpose: A hash table entry that maps workids to CIndexNotificationEntries
  24. //
  25. // History: 24-Feb-97 SitaramR Created
  26. //
  27. //----------------------------------------------------------------------------
  28. class CHashTableEntry
  29. {
  30. public:
  31. CHashTableEntry( WORKID wid,
  32. CIndexNotificationEntry *pIndexNotifEntry )
  33. : _wid( wid ),
  34. _pIndexNotifEntry( pIndexNotifEntry ),
  35. _pHashEntryNext( 0 )
  36. {
  37. }
  38. WORKID GetWorkId() { return _wid; }
  39. CIndexNotificationEntry *GetNotifEntry() { return _pIndexNotifEntry; }
  40. CHashTableEntry * GetNextHashEntry() { return _pHashEntryNext; }
  41. void SetNextHashEntry(CHashTableEntry *pEntry) { _pHashEntryNext = pEntry; }
  42. private:
  43. WORKID _wid;
  44. CIndexNotificationEntry * _pIndexNotifEntry;
  45. CHashTableEntry * _pHashEntryNext; // Link to next entry
  46. };
  47. //+---------------------------------------------------------------------------
  48. //
  49. // Class: CIndexNotificationTable
  50. //
  51. // Purpose: Hash table for document notifications
  52. //
  53. // History: 24-Feb-97 SitaramR Created
  54. //
  55. //----------------------------------------------------------------------------
  56. class CIndexNotificationTable : INHERIT_VIRTUAL_UNWIND,
  57. public ICiIndexNotification,
  58. public ICiCFilterClient
  59. {
  60. INLINE_UNWIND( CIndexNotificationTable );
  61. public:
  62. //
  63. // From IUnknown
  64. //
  65. virtual SCODE STDMETHODCALLTYPE QueryInterface( REFIID riid, void **ppvObject );
  66. virtual ULONG STDMETHODCALLTYPE AddRef();
  67. virtual ULONG STDMETHODCALLTYPE Release();
  68. //
  69. // From ICiIndexNotification
  70. //
  71. virtual SCODE STDMETHODCALLTYPE AddNotification(
  72. WORKID wid,
  73. ICiCIndexNotificationStatus *pIndexNotifStatus,
  74. ICiIndexNotificationEntry **ppIndexNotifEntry );
  75. virtual SCODE STDMETHODCALLTYPE ModifyNotification(
  76. WORKID wid,
  77. ICiCIndexNotificationStatus *pIndexNotifStatus,
  78. ICiIndexNotificationEntry **ppIndexNotifEntry );
  79. virtual SCODE STDMETHODCALLTYPE DeleteNotification(
  80. WORKID wid,
  81. ICiCIndexNotificationStatus *pIndexNotifStatus );
  82. //
  83. // From ICiCFilterClient
  84. //
  85. virtual SCODE STDMETHODCALLTYPE Init( BYTE const * pbData,
  86. ULONG cbData,
  87. ICiAdminParams * pICiAdminParams );
  88. virtual SCODE STDMETHODCALLTYPE GetConfigInfo( CI_CLIENT_FILTER_CONFIG_INFO * pConfigInfo );
  89. virtual SCODE STDMETHODCALLTYPE GetOpenedDoc( ICiCOpenedDoc ** ppICiCOpenedDoc );
  90. //
  91. // Local methods
  92. //
  93. CIndexNotificationTable( CCiManager * pCiManager,
  94. XInterface<ICiCDocStore> & xDocStore );
  95. BOOL Lookup( WORKID wid,
  96. CIndexNotificationEntry * & IndexNotifEntry );
  97. void Remove( WORKID wid,
  98. XInterface<CIndexNotificationEntry> & xIndexNotifEntry );
  99. void CommitWids( CDynArrayInPlace<WORKID> & aWidsInPersIndex );
  100. void AbortWid( WORKID wid, USN usn );
  101. void Shutdown();
  102. private :
  103. virtual ~CIndexNotificationTable( );
  104. void CheckForUsnOverflow();
  105. ULONG Hash( WORKID wid );
  106. BOOL LokLookup( WORKID wid,
  107. CIndexNotificationEntry * & pIndexNotifEntry );
  108. void LokNoFailAdd( CHashTableEntry *pHashTableEntry );
  109. void LokRemove( WORKID wid,
  110. XInterface<CIndexNotificationEntry> & xIndexNotifEntry );
  111. CCiManager * _pCiManager;
  112. XInterface<ICiCDocStore> _xDocStore;
  113. BOOL _fInitialized; // Has Init() been called ?
  114. BOOL _fShutdown; // Are we shutting down ?
  115. LONG _usnCtr; // Usn generator
  116. ULONG _cRefs; // Ref count
  117. CMutexSem _mutex; // Adds and removes can be concurrent
  118. CHashTableEntry * _aHashTable[NOTIF_HASH_TABLE_SIZE]; // Buffer of notifications
  119. };