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.

163 lines
4.3 KiB

  1. //******************************************************************************
  2. //
  3. // EVSINK.H
  4. //
  5. // Copyright (C) 1996-1999 Microsoft Corporation
  6. //
  7. //******************************************************************************
  8. #ifndef __WMI_ESS_SINKS__H_
  9. #define __WMI_ESS_SINKS__H_
  10. #include "eventrep.h"
  11. #include <sync.h>
  12. #include <unk.h>
  13. #include <newnew.h>
  14. #include <comutl.h>
  15. class CEventContext
  16. {
  17. protected:
  18. long m_lSDLength;
  19. BYTE* m_pSD;
  20. bool m_bOwning;
  21. static CReuseMemoryManager mstatic_Manager;
  22. CEventContext( const CEventContext& rOther );
  23. CEventContext& operator= ( const CEventContext& rOther );
  24. public:
  25. CEventContext() : m_lSDLength(0), m_pSD(NULL), m_bOwning(false) {}
  26. ~CEventContext();
  27. BOOL SetSD( long lSDLength, BYTE* pSD, BOOL bMakeCopy );
  28. const SECURITY_DESCRIPTOR* GetSD() const
  29. {return (SECURITY_DESCRIPTOR*)m_pSD;}
  30. long GetSDLength() const {return m_lSDLength;}
  31. void* operator new(size_t nSize);
  32. void operator delete(void* p);
  33. };
  34. class CEssNamespace;
  35. class CEventFilter;
  36. class CAbstractEventSink : public IWbemObjectSink
  37. {
  38. public:
  39. CAbstractEventSink(){}
  40. virtual ~CAbstractEventSink(){}
  41. STDMETHOD(QueryInterface)(REFIID riid, void** ppv);
  42. STDMETHOD(SetStatus)(long, long, BSTR, IWbemClassObject*);
  43. STDMETHOD(Indicate)(long lNumEvents, IWbemEvent** apEvents);
  44. STDMETHOD(IndicateWithSD)(long lNumEvents, IUnknown** apEvents,
  45. long lSDLength, BYTE* pSD);
  46. virtual HRESULT Indicate(long lNumEvemts, IWbemEvent** apEvents,
  47. CEventContext* pContext) = 0;
  48. virtual INTERNAL CEventFilter* GetEventFilter() {return NULL;}
  49. };
  50. class CEventSink : public CAbstractEventSink
  51. {
  52. protected:
  53. long m_lRef;
  54. public:
  55. CEventSink() : m_lRef(0){}
  56. virtual ~CEventSink(){}
  57. ULONG STDMETHODCALLTYPE AddRef();
  58. ULONG STDMETHODCALLTYPE Release();
  59. HRESULT Indicate(long lNumEvents, IWbemEvent** apEvents,
  60. CEventContext* pContext) = 0;
  61. virtual INTERNAL CEventFilter* GetEventFilter() {return NULL;}
  62. };
  63. class CObjectSink : public IWbemObjectSink
  64. {
  65. protected:
  66. long m_lRef;
  67. public:
  68. CObjectSink() : m_lRef(0){}
  69. virtual ~CObjectSink(){}
  70. ULONG STDMETHODCALLTYPE AddRef();
  71. ULONG STDMETHODCALLTYPE Release();
  72. STDMETHOD(QueryInterface)(REFIID riid, void** ppv);
  73. STDMETHOD(Indicate)(long lNumEvents, IWbemEvent** apEvents) = 0;
  74. STDMETHOD(SetStatus)(long, long, BSTR, IWbemClassObject*);
  75. };
  76. template <class TOuter, class TBase>
  77. class CEmbeddedSink : public TBase
  78. {
  79. protected:
  80. TOuter* m_pOuter;
  81. public:
  82. CEmbeddedSink(TOuter* pOuter) : m_pOuter(pOuter){}
  83. virtual ~CEmbeddedSink(){}
  84. ULONG STDMETHODCALLTYPE AddRef() {return m_pOuter->AddRef();}
  85. ULONG STDMETHODCALLTYPE Release() {return m_pOuter->Release();}
  86. STDMETHOD(QueryInterface)(REFIID riid, void** ppv)
  87. {
  88. if(riid == IID_IUnknown || riid == IID_IWbemObjectSink)
  89. {
  90. *ppv = (IWbemObjectSink*)this;
  91. AddRef();
  92. return S_OK;
  93. }
  94. // Hack to idenitfy ourselves to the core as a trusted component
  95. else if(riid == CLSID_WbemLocator)
  96. return S_OK;
  97. else
  98. return E_NOINTERFACE;
  99. }
  100. STDMETHOD(SetStatus)(long, long, BSTR, IWbemClassObject*)
  101. {
  102. return E_NOTIMPL;
  103. }
  104. };
  105. template <class TOuter>
  106. class CEmbeddedObjectSink : public CEmbeddedSink<TOuter, IWbemObjectSink>
  107. {
  108. public:
  109. CEmbeddedObjectSink(TOuter* pOuter)
  110. : CEmbeddedSink<TOuter, IWbemObjectSink>(pOuter)
  111. {}
  112. };
  113. template <class TOuter>
  114. class CEmbeddedEventSink : public CEmbeddedSink<TOuter, CAbstractEventSink>
  115. {
  116. public:
  117. CEmbeddedEventSink(TOuter* pOuter)
  118. : CEmbeddedSink<TOuter, CAbstractEventSink>(pOuter)
  119. {}
  120. };
  121. class COwnedEventSink : public CAbstractEventSink
  122. {
  123. protected:
  124. CAbstractEventSink* m_pOwner;
  125. CCritSec m_cs;
  126. long m_lRef;
  127. bool m_bReleasing;
  128. public:
  129. COwnedEventSink(CAbstractEventSink* pOwner);
  130. ~COwnedEventSink(){}
  131. ULONG STDMETHODCALLTYPE AddRef();
  132. ULONG STDMETHODCALLTYPE Release();
  133. void Disconnect();
  134. };
  135. #endif