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.

126 lines
3.1 KiB

  1. /*===================================================================
  2. Microsoft Denali
  3. Microsoft Confidential.
  4. Copyright 1997 Microsoft Corporation. All Rights Reserved.
  5. Component: Typelibrary cache
  6. File: tlbcache.h
  7. Owner: DmitryR
  8. This is the typelibrary cache header file.
  9. ===================================================================*/
  10. #ifndef _ASP_TLBCACHE_H
  11. #define _ASP_TLBCACHE_H
  12. /*===================================================================
  13. Includes
  14. ===================================================================*/
  15. #include "compcol.h"
  16. #include "hashing.h"
  17. #include "idhash.h"
  18. #include "dbllink.h"
  19. #include "util.h"
  20. #include "viperint.h"
  21. #include "memcls.h"
  22. /*===================================================================
  23. Defines
  24. ===================================================================*/
  25. class CHitObj;
  26. /*===================================================================
  27. C T y p e l i b C a c h e E n t r y
  28. ===================================================================*/
  29. class CTypelibCacheEntry : public CLinkElem
  30. {
  31. friend class CTypelibCache;
  32. private:
  33. DWORD m_fInited : 1;
  34. DWORD m_fIdsCached : 1;
  35. DWORD m_fStrAllocated : 1;
  36. WCHAR *m_wszProgId;
  37. CLSID m_clsid;
  38. CompModel m_cmModel;
  39. DISPID m_idOnStartPage;
  40. DISPID m_idOnEndPage;
  41. DWORD m_gipTypelib;
  42. // buffer to keep prog id (when it fits)
  43. WCHAR m_rgbStrBuffer[60];
  44. CTypelibCacheEntry();
  45. ~CTypelibCacheEntry();
  46. HRESULT StoreProgID(LPWSTR wszProgid, DWORD cbProgid);
  47. HRESULT InitByProgID(LPWSTR wszProgid, DWORD cbProgid);
  48. HRESULT InitByCLSID(const CLSID &clsid, LPWSTR wszProgid);
  49. // Cache on per-class basis
  50. ACACHE_INCLASS_DEFINITIONS()
  51. };
  52. /*===================================================================
  53. C T y p e l i b C a c h e
  54. ===================================================================*/
  55. class CTypelibCache
  56. {
  57. private:
  58. DWORD m_fInited : 1;
  59. CHashTableStr m_htProgIdEntries;
  60. CHashTableCLSID m_htCLSIDEntries;
  61. CRITICAL_SECTION m_csLock;
  62. void Lock() { EnterCriticalSection(&m_csLock); }
  63. void UnLock() { LeaveCriticalSection(&m_csLock); }
  64. public:
  65. CTypelibCache();
  66. ~CTypelibCache();
  67. HRESULT Init();
  68. HRESULT UnInit();
  69. // to be called from Server.CreateObject
  70. HRESULT CreateComponent
  71. (
  72. BSTR bstrProgID,
  73. CHitObj *pHitObj,
  74. IDispatch **ppdisp,
  75. CLSID *pclsid
  76. );
  77. // to be called from template after mapping ProgId to CLSID
  78. HRESULT RememberProgidToCLSIDMapping
  79. (
  80. WCHAR *wszProgid,
  81. const CLSID &clsid
  82. );
  83. // to be called from object creation code to update CLSID
  84. // if changed since mapping
  85. HRESULT UpdateMappedCLSID
  86. (
  87. CLSID *pclsid
  88. );
  89. };
  90. /*===================================================================
  91. Globals
  92. ===================================================================*/
  93. extern CTypelibCache g_TypelibCache;
  94. #endif