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.

141 lines
4.6 KiB

  1. //=============================================================================
  2. //
  3. // Copyright (c) 1996-1999, Microsoft Corporation, All rights reserved
  4. //
  5. // CONPROV.H
  6. //
  7. // This file defines the classes for event consumer provider caching.
  8. //
  9. // Classes defined:
  10. //
  11. // CConsumerProviderRecord --- a single consumer provider record
  12. // CConsumerProviderCache --- a collection of records.
  13. //
  14. // History:
  15. //
  16. // 11/27/96 a-levn Compiles.
  17. //
  18. //=============================================================================
  19. #ifndef __CONSUMER_PROVIDER_CACHE
  20. #define __CONSUMER_PROVIDER_CACHE
  21. #include <arrtempl.h>
  22. #include <wbemidl.h>
  23. #include <parmdefs.h>
  24. #include <unload.h>
  25. class CEssNamespace;
  26. class CConsumerProviderRecord
  27. {
  28. private:
  29. long m_lRef;
  30. CEssNamespace* m_pNamespace;
  31. IWbemClassObject* m_pLogicalProvider;
  32. LPWSTR m_wszMachineName;
  33. LPWSTR m_wszProviderName;
  34. LPWSTR m_wszProviderRef;
  35. CLSID m_clsid;
  36. IWbemEventConsumerProvider* m_pConsumerProvider;
  37. IWbemEventConsumerProviderEx* m_pConsumerProviderEx;
  38. IWbemUnboundObjectSink* m_pSink;
  39. BOOL m_bResolved;
  40. CWbemTime m_LastAccess;
  41. CCritSec m_cs;
  42. BOOL m_bAnonymous;
  43. CConsumerProviderRecord(CEssNamespace* pNamespace);
  44. HRESULT Initialize(IWbemClassObject* pLogicalProvider,
  45. LPCWSTR wszProviderRef,
  46. LPCWSTR wszProviderName,
  47. LPCWSTR wszMachineName);
  48. void Enter() {EnterCriticalSection(&m_cs);}
  49. void Leave() {LeaveCriticalSection(&m_cs);}
  50. friend class CConsumerProviderCache;
  51. protected:
  52. HRESULT ResolveAndCache(IWbemUnboundObjectSink** ppSink,
  53. IWbemEventConsumerProvider** ppConsumerProvider,
  54. IWbemEventConsumerProviderEx** ppConsumerProviderEx);
  55. HRESULT Resolve(IWbemUnboundObjectSink** ppSink,
  56. IWbemEventConsumerProvider** ppConsumerProvider,
  57. IWbemEventConsumerProviderEx** ppConsumerProviderEx);
  58. public:
  59. ~CConsumerProviderRecord();
  60. HRESULT GetGlobalObjectSink(OUT IWbemUnboundObjectSink** ppSink,
  61. IN IWbemClassObject *pLogicalConsumer);
  62. HRESULT FindConsumer(IN IWbemClassObject* pLogicalConsumer,
  63. OUT IWbemUnboundObjectSink** ppSink);
  64. HRESULT ValidateConsumer(IWbemClassObject* pLogicalConsumer);
  65. void Invalidate();
  66. CWbemTime GetLastAccess() {return m_LastAccess;}
  67. void Touch() {m_LastAccess = CWbemTime::GetCurrentTime();}
  68. BOOL IsActive() {return m_bResolved;}
  69. LPCWSTR GetMachineName() {return m_wszMachineName;}
  70. REFCLSID GetCLSID() {return m_clsid;}
  71. LPCWSTR GetProviderName() {return m_wszProviderName;}
  72. LPCWSTR GetProviderRef() {return m_wszProviderRef;}
  73. void FireNCSinkEvent(DWORD dwIndex, IWbemClassObject *pLogicalConsumer);
  74. long AddRef();
  75. long Release();
  76. };
  77. class CEssNamespace;
  78. class CConsumerProviderCache
  79. {
  80. public:
  81. friend class CConsumerProviderRecord;
  82. friend class CConsumerProviderWatchInstruction;
  83. CConsumerProviderCache(CEssNamespace* pNamespace)
  84. : m_pNamespace(pNamespace), m_pInstruction(NULL){}
  85. ~CConsumerProviderCache();
  86. RELEASE_ME CConsumerProviderRecord* GetRecord(
  87. IN IWbemClassObject* pLogicalConsumer);
  88. HRESULT RemoveConsumerProvider(LPCWSTR wszProvider);
  89. static SYSFREE_ME BSTR GetProviderRefFromRecord(IWbemClassObject* pReg);
  90. HRESULT GetConsumerProviderRegFromProviderReg(
  91. IWbemClassObject* pProv, IWbemClassObject** ppConsProv);
  92. void DumpStatistics(FILE* f, long lFlags);
  93. void Clear();
  94. protected:
  95. HRESULT UnloadUnusedProviders(CWbemInterval Interval);
  96. void EnsureUnloadInstruction();
  97. BOOL DoesContain(IWbemClassObject* pProvReg, IWbemClassObject* pConsumer);
  98. protected:
  99. CRefedPointerArray<CConsumerProviderRecord> m_apRecords;
  100. CEssNamespace* m_pNamespace;
  101. CCritSec m_cs;
  102. class CConsumerProviderWatchInstruction* m_pInstruction;
  103. friend CConsumerProviderWatchInstruction;
  104. friend class CProviderRegistrationSink;
  105. };
  106. class CConsumerProviderWatchInstruction : public CBasicUnloadInstruction
  107. {
  108. protected:
  109. CConsumerProviderCache* m_pCache;
  110. static CWbemInterval mstatic_Interval;
  111. public:
  112. CConsumerProviderWatchInstruction(CConsumerProviderCache* pCache);
  113. virtual ~CConsumerProviderWatchInstruction() {}
  114. HRESULT Fire(long, CWbemTime);
  115. static void staticInitialize(IWbemServices* pRoot);
  116. };
  117. #endif