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.

234 lines
7.2 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. OfflineCache.h
  5. Abstract:
  6. To speed up the start time of the Help Center, we cache in the registry the most
  7. common queries.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 07/16/2000
  10. created
  11. ******************************************************************************/
  12. #if !defined(__INCLUDED___HCP___OFFLINECACHE_H___)
  13. #define __INCLUDED___HCP___OFFLINECACHE_H___
  14. #include <QueryResult.h>
  15. #include <ProjectConstants.h>
  16. #include <TaxonomyDatabase.h>
  17. namespace OfflineCache
  18. {
  19. typedef enum
  20. {
  21. ET_INVALID = 0,
  22. ET_NODE ,
  23. ET_SUBNODES ,
  24. ET_SUBNODES_VISIBLE ,
  25. ET_NODESANDTOPICS ,
  26. ET_NODESANDTOPICS_VISIBLE ,
  27. ET_TOPICS ,
  28. ET_TOPICS_VISIBLE ,
  29. //
  30. // Not cached...
  31. //
  32. ET_LOCATECONTEXT ,
  33. ET_SEARCH ,
  34. ET_NODES_RECURSIVE ,
  35. ET_TOPICS_RECURSIVE ,
  36. } Entry_Type;
  37. class Query;
  38. class SetOfHelpTopics;
  39. class Handle;
  40. class Root;
  41. class Query
  42. {
  43. friend class SetOfHelpTopics;
  44. friend class Root;
  45. ////////////////////////////////////////
  46. MPC::wstring m_strID;
  47. int m_iType;
  48. int m_iSequence;
  49. bool m_fNull;
  50. ////////////////////////////////////////
  51. friend HRESULT operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ Query& val );
  52. friend HRESULT operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const Query& val );
  53. HRESULT InitFile( /*[in]*/ const MPC::wstring& strDir, /*[out]*/ MPC::wstring& strFile );
  54. HRESULT Store ( /*[in]*/ const MPC::wstring& strDir, /*[in]*/ const CPCHQueryResultCollection* pColl );
  55. HRESULT Retrieve( /*[in]*/ const MPC::wstring& strDir, /*[in]*/ CPCHQueryResultCollection* *pColl );
  56. HRESULT Remove ( /*[in]*/ const MPC::wstring& strDir );
  57. public:
  58. ////////////////////////////////////////
  59. Query();
  60. };
  61. class SetOfHelpTopics
  62. {
  63. friend class Root;
  64. typedef std::list<Query> QueryList;
  65. typedef QueryList::iterator QueryIter;
  66. typedef QueryList::const_iterator QueryIterConst;
  67. ////////////////////////////////////////
  68. Root* m_parent;
  69. Taxonomy::Instance m_inst;
  70. QueryList m_lstQueries;
  71. int m_iLastSeq;
  72. ////////////////////////////////////////
  73. friend HRESULT operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ SetOfHelpTopics& val );
  74. friend HRESULT operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const SetOfHelpTopics& val );
  75. HRESULT InitDir( /*[in]*/ MPC::wstring& strDir );
  76. HRESULT Find( /*[in/out]*/ LPCWSTR& szID, /*[in]*/ int iType, /*[out]*/ QueryIter& it );
  77. void ConnectToParent( /*[in]*/ Root* parent );
  78. public:
  79. SetOfHelpTopics();
  80. const Taxonomy::Instance& Instance() { return m_inst; }
  81. ////////////////////
  82. bool AreYouInterested( /*[in]*/ LPCWSTR szID, /*[in]*/ int iType );
  83. HRESULT Retrieve ( /*[in]*/ LPCWSTR szID, /*[in]*/ int iType, /*[in]*/ CPCHQueryResultCollection* *pColl );
  84. HRESULT Store ( /*[in]*/ LPCWSTR szID, /*[in]*/ int iType, /*[in]*/ const CPCHQueryResultCollection* pColl );
  85. HRESULT RemoveQueries ( );
  86. };
  87. class Handle
  88. {
  89. friend class Root;
  90. Root* m_main; // We have a lock on it.
  91. SetOfHelpTopics* m_sht;
  92. void Attach ( /*[in]*/ Root* main, /*[in]*/ SetOfHelpTopics* sht );
  93. void Release( );
  94. public:
  95. Handle();
  96. ~Handle();
  97. operator SetOfHelpTopics*() { return m_sht; }
  98. SetOfHelpTopics* operator->() { return m_sht; }
  99. };
  100. class Root : public CComObjectRootEx<MPC::CComSafeMultiThreadModel> // Just to have locking...
  101. {
  102. typedef CComObjectRootEx<MPC::CComSafeMultiThreadModel> super;
  103. friend class SetOfHelpTopics;
  104. typedef std::list<SetOfHelpTopics> SKUList;
  105. typedef SKUList::iterator SKUIter;
  106. typedef SKUList::const_iterator SKUIterConst;
  107. static const DWORD s_dwVersion = 0x02324351; // QC2 02
  108. ////////////////////////////////////////
  109. MPC::NamedMutex m_nmSharedLock;
  110. bool m_fReady; // PERSISTED
  111. Taxonomy::Instance m_instMachine; // PERSISTED
  112. SKUList m_lstSKUs; // PERSISTED
  113. bool m_fMaster; // VOLATILE
  114. bool m_fLoaded; // VOLATILE
  115. bool m_fDirty; // VOLATILE
  116. DWORD m_dwDisableSave; // VOLATILE
  117. HANDLE m_hChangeNotification; // VOLATILE
  118. ////////////////////////////////////////
  119. friend HRESULT operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ Root& val );
  120. friend HRESULT operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const Root& val );
  121. HRESULT GetIndexFile( /*[out]*/ MPC::wstring& strIndex );
  122. HRESULT Load ( );
  123. HRESULT Save ( );
  124. HRESULT Clean ( );
  125. HRESULT SetDirty ( );
  126. HRESULT Find( /*[in]*/ const Taxonomy::HelpSet& ths, /*[out]*/ SKUIter& it );
  127. public:
  128. Root( /*[in]*/ bool fMaster = false );
  129. ~Root();
  130. ////////////////////////////////////////////////////////////////////////////////
  131. static Root* s_GLOBAL;
  132. static HRESULT InitializeSystem( /*[in]*/ bool fMaster );
  133. static void FinalizeSystem ( );
  134. ////////////////////////////////////////////////////////////////////////////////
  135. void Lock ();
  136. void Unlock();
  137. ////////////////////
  138. bool IsReady ();
  139. const Taxonomy::Instance& MachineInstance() { return m_instMachine; }
  140. ////////////////////
  141. HRESULT SetReady ( /*[in]*/ bool fReady );
  142. HRESULT SetMachineInfo( /*[in]*/ const Taxonomy::Instance& inst );
  143. ////////////////////
  144. HRESULT DisableSave();
  145. HRESULT EnableSave ();
  146. HRESULT Import( /*[in]*/ const Taxonomy::Instance& inst );
  147. HRESULT Locate( /*[in]*/ const Taxonomy::HelpSet & ths, /*[out]*/ Handle& handle );
  148. HRESULT Remove( /*[in]*/ const Taxonomy::HelpSet & ths );
  149. HRESULT Flush( /*[in]*/ bool fForce = false );
  150. ////////////////////
  151. HRESULT FindMatch( /*[in]*/ LPCWSTR szSKU ,
  152. /*[in]*/ LPCWSTR szLanguage ,
  153. /*[out]*/ Taxonomy::HelpSet& ths );
  154. };
  155. };
  156. #endif // !defined(__INCLUDED___HCP___OFFLINECACHE_H___)